I'm trying to setup flyway-migration on Websphere server.
My project consists of the modules:
--projectwar.war
--projectsql.jar
--java
--MyFlywayUtil.class
-- resources
-- myscripts
--projectmodel.jar
--java
--MyRiskDataSourceConfig.class
MyRiskDataSourceConfig contains flyway migration declaration:
#Bean(initMethod = "migrate")
public Flyway flyway(#Qualifier("myDataSource") DataSource dataSource) {
Flyway flyway = new Flyway();
flyway.setBaselineOnMigrate(true);
flyway.setClassLoader(MyFlywayUtil.class.getClassLoader());
flyway.setLocations("classpath:"+"myscripts");
flyway.setDataSource(dataSource);
return flyway;
}
When executed under Tomcat using bootRun comand, migration works fine and location is found.
However under Websphere I receive the following:
com.ibm.ws.classloader.CompoundClassLoader#bb6f8b91[app]
Local ClassPath
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/cell01/project.ear/project.war/WEB-INF/classes
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/cell01/project.ear/project.war/WEB-INF/lib/projectmodel.jar
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/cell01/project.ear/project.war/WEB-INF/lib/projectsql.jar
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/cell01/project.ear/project.war
Parent com.ibm.ws.classloader.ProtectionClassLoader#c26663d6 Delegation Mode PARENT_FIRST)
On WebSphere an empty file named flyway.location must be present on the classpath location for WebSphere to find it!
o.f.c.i.u.s.classpath.ClassPathScanner Unable to resolve location classpath myscripts
I've tried configuration with and without flyway.setClassLoader();
Any help would be appreciated.
Did you also add an (empty) file with the name flyway.location to the folder(s) containing your migrations, in my cases this fixed the problem.
Because of the way the IBM class-loader works this file has to be added as a workaround, see also the source
And of course the warning which is given:
On WebSphere an empty file named flyway.location must be present on the classpath location for WebSphere to find it!
According to this git issue, the problem was fixed in flyway 4.0.1
Related
I am using Spring Boot 2.2.2 with Flyway 5.2.4 and I tried to configure flyway to use a differente location for the scripts, but spring.flyway.locations=filesystem:db_other/migration/{vendor} neither flyway.locations=filesystem:db_other/migration/{vendor} configurations on application.properties worked.
When running the program, the following exception appear in the log:
FlywayMigrationScriptMissingException: Cannot find migration scripts in: [classpath:db/migration]
I already tried using Spring Boot 2.2.1, 2.2.0, 2.1.11 and Flyway 6.1.0 and 6.1.3, but the result is the same.
The default value for that property is classpath:db/migration as shown here (search for flyway).
Since you're using a different folder in the resources directory you should only need to change "filesystem" to "classpath" in your application.properties value.
Actually if was my fault: as I used to work with just spring (not spring boot) I configured my test class with the annotations #ExtendWith(SpringExtension.class) AND #ContextConfiguration(classes = { MyConfiguration.class }) instead of just use #SpringBootTest. When making this change the test worked.
I am using JMeter version 5.0 r and I am following [this tutorial]
(https://docs.wso2.com/display/EI630/Point-to-Point+Messaging#865c10b8d4d64ac688d6a0799cfb6012),
jndiqueues.properties
# register some connection factories
# connectionfactory.[jndiname] = [ConnectionURL]
connectionfactory.QueueConnectionFactory = amqp://admin:admin#clientID/carbon?brokerlist='tcp://localhost:5675'
# register some queues in JNDI using the form
# queue.[jndiName] = [physicalName]
queue.FirstQueue = myfirstqueue
when I am running this JMS publisher I am getting error as:
Response message: javax.naming.NamingException: javax.naming.NoInitialContextException: Cannot instantiate class: org.wso2.andes.jndi.PropertiesFileInitialContextFactory [Root exception is java.lang.ClassNotFoundException: org.wso2.andes.jndi.PropertiesFileInitialContextFactory ]
This jar is already there in lib folder still I added want to add it in classpath because it was giving this error. So I edited user.properties file, like mentioned in an answer here:
user.classpath=../classes;../lib;../app1/jar1.jar;../app2/jar2.jar;../lib/andes-client-4.0.0.jar
But still I am getting same error. What am I doing wrong?
If you copied andes-client-4.0.0.jar to "lib" folder of your JMeter installation there is no need to set up user.classpath property, JMeter will automatically pick it up.
Remember that you need to restart JMeter for any property change application and when you add .jars under JMeter Classpath, otherwise the changes will not be picked up.
More information:
JMeter Properties Reference
Apache JMeter Properties Customization Guide
You can also add the libraries to JMeter Classpath at Test Plan level like:
in that case JMeter restart will not be required
try the same you did but using absolute class paths instead of relative ones
What it worked for me was to use:
<propertiesJMeter>
<search_paths>${project.basedir}/some_path</search_paths>
<user.classpath>${project.basedir}/some_path</user.classpath>
</propertiesJMeter>
Hope it helps
I just started right now a new project in Intellij using Spring Boot ver 2.1.3 and Flyway 5.2.4 with Java 11.
After try to start my project i got :
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flyway' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'flyway' threw exception; nested exception is java.lang.IllegalStateException: Cannot find migrations location in: [classpath:db/migration] (please add migrations or check your Flyway configuration)
I have the following folders:
As you can see i have "db/migration" but without any migration, i just started right now. Debugging the class FlywayAutoConfiguration i got the following:
So, i tried to return all files in "classpath:", see:
Note that i just have "application.properties" file.
It is not that much useful or accurate answer.
But This issue make you frustrated so that i give this solution.
Note: Strange but it's true, Sometime it's not allow copy paste because your folder created db.migration and it expact db->migration(It's not same in this scenario). So whenever you start from scratch. Go to the resource folder -> Create DB folder -> Create migration folder -> Create database file with Version_SubVersion__Name(As defined below).
Normally this happens in following cases,
Path is not proper try using set locations param value.
db.migrate folder not contain any file.
Check name of file : V1_1__(short_desc)
Try to run using, mvn compile flyway:migrate
In my case i already place sql file over there but still it gives same error,
Basically i place this sql file using copy paste from somewhere.
When i try to add one new file on same place using IDE (Intellij : Right click on migration folder -> new -> Flyway migration -> versioned migration), then it ask me(warning) about some delicate allowance(normally we mention in database configuration i also place there still), and it start working.
Flyway requires at-least one script, disable it until u need it by using following command in application.properties file
spring.flyway.enabled=false
I believe that Flyway requires at least one migration script to initialize. Try adding a simple sql creation script into your migration folder and give it another try. Alternatively you can disable the flyway dependency until you need it.
I had a similar error, and solved it as follows: I added these commands
spring.flyway.baselineOnMigrate=true
spring.flyway.check-location=true
spring.flyway.locations=classpath:db/migration
spring.flyway.schemas=public
spring.flyway.enabled=true
to application.properties
I had the same issue. When I created the directory, I simply typed db.migration - the same way one would do with package names. InteliJ will display both db.migration and db/migration directories as db.migration, so while it may look correct in IntelliJ, flyway requires the latter.
Even when having your migration files in the db/migration folder, flyway won't detect it.
Then you will have to fix this by explicitly setting the locations in your application.properties (or appliocation.yml) by adding:
spring.flyway.locations=classpath:db/migration
N.B: Also you need to have at least one script to initialize flyway, you can even put an empty one. But you need to have at least one script
As #Guy suggested in his answer, I created an SQL file in the migration folder and left it empty. Named v1_0__mock_flyway.sql in the migration folder classpath:db/migration. Error solved.
If you have tried everything above and it still does not apply the migrations.
Be sure you have followed the steps in the previous answers
A db.migration folder exists in your resources folder
The sql scripts are named with respect to the correct naming convention, such as V1__init.sql
The following config exists in your application.properties/application.yml
spring.flyway.locations=classpath:db/migration
Do a clean build
-> mvn clean
Then restart your spring boot app, this worked for me.
I have the Generic installation of Oracle WebLogic Server 12.2.1.3 on my MacBook.
I am trying to setup a Netezza datasource and I am having an issue getting it to recognize the nzjdbc.jar I am trying to use.
Some installation paths:
WL_HOME="/Users/cpritcha/oracle/Middleware/Oracle_Home/wlserver"
DOMAIN_HOME="/Users/cpritcha/oracle/Middleware/Oracle_Home/user_projects/domains/wl_server"
I have my jar placed in {WL_HOME}/server/lib
But when I launch
{DOMAIN_HOME}/bin/startWebLogic.sh
and try to configure my datasource, it says
weblogic.common.resourcepool.ResourceSystemException: Cannot load driver class org.netezza.Driver for datasource 'gdwDS'
I have tried going to startWebLogic.sh and doing
SAVE_CLASSPATH="${CLASSPATH}:/Users/cpritcha/oracle/Middleware/Oracle_Home/wlserver/server/lib/nzjdbc.jar"
But that still had no effect.
Is there something I am missing? How can I make WebLogic recognize and load this 3rd Party driver?
try modifying: ${WL_HOME}/oracle_common/bin/commEnv.sh
and adding the same full path (and jar file) to WEBLOGIC_CLASSPATH
I am trying to establish a JMS connection. In connectionFactory.createContext, I get an error that the ActiveMQ version loader reports that a properties file is missing:
Caused by: java.lang.RuntimeException: activemq-version.properties is not available
at org.apache.activemq.artemis.utils.VersionLoader.getVersion(VersionLoader.java:87)
I am running the project from Eclipse - so it's most likely an eclipse classpath issue, but I can't find which library is missing.
Full stacktrace:
javax.jms.JMSRuntimeException: Failed to create session factory
at org.apache.activemq.artemis.jms.client.JmsExceptionUtils.convertToRuntimeException(JmsExceptionUtils.java:88)
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createContext(ActiveMQConnectionFactory.java:262)
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createContex t(ActiveMQConnectionFactory.java:248)
at at.cone.health.dispo.online.DispoServerFacadeImpl$JMSReceiverThread.run(DispoServerFacadeImpl.java:109)
Caused by: javax.jms.JMSException: Failed to create session factory
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnectionInternal(ActiveMQConnectionFactory.java:727)
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createContext(ActiveMQConnectionFactory.java:255)
... 2 more
Caused by: java.lang.RuntimeException: activemq-version.properties is not available
at org.apache.activemq.artemis.utils.VersionLoader.getVersion(VersionLoader.java:87)
at org.apache.activemq.artemis.core.protocol.core.impl.ActiveMQClientProtocolManager.<init>(ActiveMQClientProtocolManager.java:81)
at org.apache.activemq.artemis.core.protocol.core.impl.ActiveMQClientProtocolManagerFactory.newProtocolManager(ActiveMQClientProtocolManagerFactory.java:49)
at org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl.newProtocolManager(ServerLocatorImpl.java:575)
at org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl.<init>(ClientSessionFactoryImpl.java:173)
at org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:757)
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnectionInternal(ActiveMQConnectionFactory.java:724)
... 3 more
The code where I try to set up the connection:
InitialContext namingContext = new InitialContext(env);
ConnectionFactory connectionFactory = (ConnectionFactory) namingContext.lookup(CONNECTION_FACTORY);
System.out.println("Got ConnectionFactory " + CONNECTION_FACTORY);
destination = (Destination) namingContext.lookup(DESTINATION);
System.out.println("Got JMS Endpoint " + DESTINATION);
final JMSContext context = connectionFactory.createContext("internal", "internal");
this.context = context;
JMSConsumer consumer = context.createConsumer(destination, "client='" + clientUID + "'", true);
// Then receive the same number of messages that were sent
The project is ANT based, so I cannot use maven dependency management. Nevertheless, the server part uses a maven build, so I have a local maven repository and an eclipse build path variable M2_REPO pointing to the .m2 directory. I tried to set up a library dependency in my eclipse project. I am running the project from eclipse, so we can - at first - ignore ANT related dependencies, and focus just on eclipse (but without maven).
I added a library dependency to the wildfly-client-all-10.0.0.Final.jar from my maven repo (using my M2_REPO variable, extended by the path). The library is correctly displayed as referenced library in the eclipse project.
I implemented a demo with same lines of codes in an eclipse maven project. Here I didn't get an exception, in the demo I was able to receive messages. So I assume it's a classpath issue.
I also searched for the missing activemq-version.properties on google and on stackoverflow, but didn't find anything related. I also didn't find a resource called activemq-version.properties, even not in the demo project (and its dependencied) where it was executed successfully.
After some more investigation, I did now identify the reason.
In the run config, I had a different classpath. This classpath remained from an elder configuration. Here, I didn't use the same jar as the maven build. The run configuration contained both the jboss-client.jar and the jboss-cli-client.jar from wildfly/bin/client directory.
This configuration was wrong, and caused an additional warning which I didn't recognize in my logs, but which was also a hint to the solution:
WARN: EJB client integration will not be available due to a problem setting up the EJB client handler
I changed it to the wildfly-client-all-10.0.0.Final.jar which is also contained in maven project runtimes, but it again didn't solve the issue.
Then I found this article: https://developer.jboss.org/thread/267824
Solution: back to the first configuration approach for the runtime config, using the JAR from wildfly\bin\client directory, but only the jboss-cli-client.jar AND NOT the jboss-client-jar.