For some reason the Liquibase maven plugin is not using my property when I set it in my liquibase.properties file. When I run mvn liquibase:update I get the following INFO.
[INFO] there are no resolved artifacts for the Maven project.
[INFO] Parsing Liquibase Properties File
[INFO] File: target/classes/liquibase.properties
[INFO] 'classpath' in properties file is not being used by this task.
Due to this, the update fails as liquibase can't find the driver and can't connect to the database.
I saw this SO question but they are using the liquibase executable and not maven. I used it as an example on how to use the liquibase.properties file.
Setting up Liquibase with MS-SQL Server
I see where it is hitting an exception L571 to L588 the exception but the actual exception isn't printed out so I don't know the cause of the error.
https://github.com/liquibase/liquibase/blob/9ae7f90a0bbbbcec229a0788afa74831db348ced/liquibase-maven-plugin/src/main/java/org/liquibase/maven/plugins/AbstractLiquibaseMojo.java#L573
Rather than setting the classpath in a properties file, you must put the driver jar as a dependency in your maven POM.
See the documentation for the Liquibase Maven Task, and especially the section that describes different JDBC dependencies. Here's a snippet:
Example of Maven Liquibase Update
You need to ensure that you include the relevant JDBC driver for your
database in the dependency section of Maven POM file.
MySQL example:
<project>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<!-- Replace with the version of the MySQL driver you want to use -->
<version>${mysql-version}</version>
</dependency>
</dependencies>
</project>
In my case it was a simple copy and paste issue.
The property driver in liquibase.properties ends with a space. after deleting the space everything was fine.
driver: com.mysql.cj.jdbc.Driver
vs
driver: com.mysql.cj.jdbc.Driver
This answer put me in the right direction. In my case, it was that I needed to declare the Maven resource.
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
Hope it helps!
Related
My application is failing because of the following issue :
Source '/.../.ivy2/jars/org.apache.zookeeper_zookeeper-3.4.6.jar' does not exist
But I see, there exists a jar in that folder with "tests" suffix - org.apache.zookeeper_zookeeper-3.4.6-tests.jar
If I remove -tests from the name manually, the application runs fine.
I need to understand how can I place the jar my application is expecting in .ivy folder through my program/dependency.
Also, when are the all jars loaded in .ivy/jars folder, is it during the build?
I am using java with maven.
<!-- https://mvnrepository.com/artifact/org.apache.zookeeper/zookeeper -->
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.6</version>
<type>pom</type>
</dependency>
add this to your maven dependencies also the org.apache.zookeeper_zookeeper-3.4.6-tests.jar is for the test environment.
I have a Java Maven web app project that I'm trying to clean up. In the <build> section of my pom.xml, I have the following:
<build>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
</resource>
</resources>
<filters>
<filter>profiles/${build.profile.id}.profile.properties</filter>
</filters>
[...other properties...]
</build>
In my project, which on my Mac is /Users/anthony/workspace/my-project/, i src/main/resources/profiles/I have local.profile.properties and qa.profile.properties.
Then, in my maven profiles in my pom, I define ${build.profile.id} as the following:
<profile>
<id>local</id>
[...stuff...]
<properties>
<build.profile.id>local</build.profile.id> <!-- or qa -->
[...stuff...]
</properties>
</properties>
When I am in my console and run $ mvn clean install -Plocal, I get the following error:
Failed to execute goal ... on project my-project: Error loading property file '/Users/anthony/workspace/my-project/profiles/local.profile.properties'.
It seems like Maven is not recognizing the resource directory for my filtering profile properties file. This only works when I explicitly put the entire path of my properties file, like so:
<filters>
<filter>src/main/resources/profiles/${build.profile.id}.profile.properties</filter>
</filters>
Is there a way for me to not have to explicitly state src/main/resources? I thought that the point of me declaring a resources directory was that I could use it, especially for declaring filtering.
The resource directory only has a meaning as "resources" for the Java artifact being built, but not for Maven itself. For Maven, the "resources" directory has a special meaning in the sense that Maven knows where to copy those files to in the resulting jar-file. But for Maven working with files or filtering files, you have to tell Maven the exact path, as Maven does not know if the filtered file is a resource, a source file, or something else. Also, you could have multiple source or resource directory defined, and Maven would not know, in which one to filter. Thus you always need to specify the full path for Maven.
So, in short:
Is there a way for me to not have to explicitly state src/main/resources?
No.
I have successfully deployed alfresco community 4.2.f in a Tomcat 7.0.59 with a database MySQL5.6 and jdk1.8.0_141
No problems thus far, now, I got a module developed by our company which I need to be deployed in alfresco. This module invokes a WS which will send a PDF to some place.
I got this module in a jar compiled with jdk1.8.0_141
I tried to put it inside the alfresco.war before deployment in Tomcat in WEB-INF/lib but when I do that and deploy with startup.bat from Tomcat it pops in the console
instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/codehaus/xfire/XFireRuntimeException
I understand this exception is caused by putting the jar inside the war.
I was told that the jar was compiled also in jdk8.
Also, tell you that if instead of this jar I put inside the alfresco.war in WEB-INF/classes a properties file to get our database in deployment it works fine.
The problem is when I try to deploy the module.
I saw there are quite tutorials pointing to do something like:
java -jar bin/alfresco-mmt.jar
I can't do that because this is done installing alfresco with its wizard I assume. I did it deploying alfresco in a fresh tomcat installation.
Does anyone know how to deploy our module with the way we deployed alfresco? Thank you.
You have two ways to install your amp :
The first traditional one :
This is the one installed with the apply amp procédure (alfresco-mmt).
To me, this is not true that it is not compatible with your installation. You can easily find the bin folder (containing the alfresco-mmt.jar file) here in the alfresco packaging : https://download.alfresco.com/release/community/4.2.f-build-00012/alfresco-community-4.2.f.zip
When you have it, you can follow the documentation : http://docs.alfresco.com/4.2/tasks/amp-install.html
And apply your amp for example following this way :
java -jar alfresco-mmt.jar install <AMPFileLocation> <WARFileLocation>
The second one :
You can recreate the war with the alfresco sdk and include in the build the module you created.
If you follow this documentation : http://docs.alfresco.com/4.2/tasks/dev-extensions-maven-sdk-tutorials-all-in-one-archetype.html
the war produced in the target folder of the repo part will contain your module, since the pom of this module will contains a dependency to the amp module :
...
<dependencies>
<dependency>
<groupId>${alfresco.groupId}</groupId>
<artifactId>alfresco</artifactId>
<type>war</type>
</dependency>
<!-- Demonstrating the dependency on the repo AMP developed in the 'amp'
module -->
<dependency>
<groupId>x.y.z</groupId>
<artifactId>my-amp</artifactId>
<version>${my-amp.version}</version>
<type>amp</type>
</dependency>
</dependencies>
...
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<!-- Here is can control the order of overlay of your (WAR, AMP, etc.)
dependencies | NOTE: At least one WAR dependency must be uncompressed first
| NOTE: In order to have a dependency effectively added to the WAR you need
to | explicitly mention it in the overlay section. | NOTE: First-win resource
strategy is used by the WAR plugin -->
<overlays>
<!-- Current project customizations -->
<overlay />
<!-- The Alfresco WAR -->
<overlay>
<groupId>${alfresco.groupId}</groupId>
<artifactId>alfresco</artifactId>
<type>war</type>
<!-- To allow inclusion of META-INF -->
<excludes />
</overlay>
<!-- Add / order your AMPs here -
<overlay>
<groupId>x.y.z</groupId>
<artifactId>my-amp</artifactId>
<type>amp</type>
</overlay>
</overlays>
</configuration>
</plugin>
</plugins>
</build>
Good evening!
Using Cargo via Maven, I've configured my pom.xml to create an instance of glassfish and then deploy my project to it, before running integration tests. I'm most of the way there, in that I've got my code deployed, I've setup a datasource and a JNDI resource for it, but when I attempt to actually use the resource, I get the following exception:
Wrong class name or classpath for Datasource Object
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
On a regular installation of glassfish, I can easily install the connector, but the installation of glassfish in this case is automated and a new instance is created each time I run the tests.
Is there any way that I can provide the mysql connector, either on a classpath that glassfish can read, or by installing it in the new instance of glassfish that's created each build?
Thanks!
Scouring the docs a little more, I found out that I can do this by providing maven dependencies in the container configuration, like so:
<configuration>
<container>
<containerId>glassfish3x</containerId>
<artifactInstaller>
<groupId>org.glassfish.main.distributions</groupId>
<artifactId>glassfish</artifactId>
<version>${glassfish.version}</version>
</artifactInstaller>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
</dependencies>
</container>
<configuration>
<properties>
<cargo.datasource.datasource.mysql>
cargo.datasource.jndi=jdbc/MysqlPool|
cargo.datasource.driver=com.mysql.jdbc.Driver|
cargo.datasource.url=jdbc:mysql://localhost/databasename|
cargo.datasource.transactionsupport=LOCAL_TRANSACTION|
cargo.datasource.username=username|
cargo.datasource.password=password
</cargo.datasource.datasource.mysql>
</properties>
</configuration>
</configuration>
Take note of the mysql dependency. It needs to reference a dependency already defined in my project (which, for my project has a scope of "provided"). This works as expected. :)
Hi I have module inside a project which i'm trying to run from the modules directory as such:
mvn integration-test -PmyProps
in pom
<properties>
<user>admin</user>
</properties
in src/test/resources/test.properties
user=${user}
When i execute the test i get user={user} instead of user=admin
If i run it via intellij or eclipse i have no problems with it and properties get picked up?
is it because the property values are getting assigned to the target directory?
This is the class loader:
InputStream testPropertiesInput = WebDriverConfiguration.class.getClassLoader().getResourceAsStream("smoke.properties");
i've tried making it "target/classes/smoke.properties" but no luck.
First if you have unit tests which seemed to be in your case use simply:
mvn test
furthermore to get resource files beeing filtered you need to active filtering
<build>
<resources>
<resource>
<directory>...</directory>
<filtering>true</filtering>
</resource>
...
</build>