How to execute multiple class defined under test method in testng.xml from POM.xml - maven

Below is my testng.xml file code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="SaferSystem" >
<parameter name="dev_URL" value="http://localhost:8383/" />
<test name="ChromeTest">
<parameter name="browser" value="Chrome" />
<parameter name="username" value="jayeshdp#weblineindia.com" />
<parameter name="password" value="System123" />
<classes>
<class name="com.safer.login.LoginTest" />
<class name="com.safer.login.DashboardTest"/>
</classes>
</test>
And below is my POM.xml code:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>SaferSystem</groupId>
<artifactId>SaferMavenProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>SaferMavenProject</name>
<url>http://maven.apache.org</url>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.1</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.11</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.7</version>
</dependency>
</dependencies>
</project>
I want to execute "DashboardTest" java file but when I add "DashboardTest" line code does not executes. But if I keep only "LoginTest" class then code executes properly. How can I solve this issue as I have multiple classes to add under test.Please help as I am quite new for Maven and working on Maven project. Thanks in advance.

Related

Getting "testng.xml is not a valid file" error in Jenkins

I'm getting the following error when trying to run a Selenium/TestNg test from Jenkins.
[ERROR] Suite file /development/apps/config/jenkins/jobs/teste-automatizado/workspace/Juvo/testng.xml is not a valid file
Below are my POM and testng.xml files. I’m able to launch the testng.xml successfully from eclipse and comand line but from Jenkins I get this error.
Any help? Thanks in advance.
pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.aoki</groupId>
<artifactId>Juvo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>ISO-8859-1</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.4</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>19.3.0.0</version>
</dependency>
</dependencies>
</project>
testng.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="Suite">
<test name="Test">
<classes>
<class name="tests.TestCreateAssistTest"/>
</classes>
</test>
</suite>
This problem was reported in the stackoverflow already.
I guess your file testng.xml appears in src/test/resources.
The error says
Suite file
/development/apps/config/jenkins/jobs/teste-automatizado/workspace/Juvo/testng.xml
is not a valid file
It does not say Juvo/src/test/resources/testng.xml.
Obviously it cannot, because you placed the file in src/test/resources but the configuration says that the file is read at the root:
<suiteXmlFile>testng.xml</suiteXmlFile>
You have to rewrite the config with
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
because it has to match the real location of the file.
In Maven the paths are use to be relative to the project root.

java src path in pom.xml while there are multiple modules

I have a two modules project with following pom.xml files but intellij idea does not detect java files and treat them as general file, where did I make mistake?
and the pom file for module-a is
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>myproj</groupId>
<artifactId>parent</artifactId>
<version>0.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>module-a</artifactId>
<name>module-a</name>
<packaging>jar</packaging>
<description>module-a</description>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
and the pom file for the module-b is
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>myproj</groupId>
<artifactId>parent</artifactId>
<version>0.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>module-b</artifactId>
<name>module-b</name>
<packaging>jar</packaging>
<description>module-b</description>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
and the parent pom file is
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>myproj</groupId>
<artifactId>parent</artifactId>
<name>myproj.parent</name>
<packaging>pom</packaging>
<version>0.4.0-SNAPSHOT</version>
<scm>
<connection>scm:svn:http://localhost:7070/svn/myproj/branches/test</connection>
<developerConnection>scm:svn:http://localhost:7070/svn/myproj/branches/test</developerConnection>
</scm>
<modules>
<module>module-a</module>
<module>module-b</module>
</modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<configuration>
<encoding>utf-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>utf-8</encoding>
<showWarnings>true</showWarnings>
<fork>true</fork>
<optimize>true</optimize>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.2.2</version>
<configuration>
<useReleaseProfile>true</useReleaseProfile>
<releaseProfiles>complete</releaseProfiles>
<username>${username}</username>
<password>${password}</password>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<!-- Dependency(s) Versions -->
<org.slf4j>1.7.21</org.slf4j>
<kotlin.version>1.2.21</kotlin.version>
<!-- Dependency(s) Versions -->
<!-- Configurations -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<proguard.skip>true</proguard.skip>
<debug.skip>false</debug.skip>
<product.name>myproj</product.name>
</properties>
</project>
The default sources directory would be src/main/java. In your case, it is just src in each module.
You can include following line in each module's pom file.
<sourceDirectory>${project.build.directory}/src</sourceDirectory>
Or you can try marking each src directory as Sources Root.

How to execute maven project from command line

Below is the message I received every time when I ran MVN TEST on the project folder from command line.
[INFO] No tests to run.
[INFO] ----------------
[INFO] BUILD SUCCESS
My Testscripts location is below. I went to the below folder and ran mvn test from the command line.
/Copy of naukri/src/testScripts/NewTest.java
Below is the POM file of the project
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>naukri</groupId>
<artifactId>NewTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>NaukriUpdate</name>
<description>----------------</description>
<build>
<sourceDirectory>../src/testScripts/</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<testSourceDirectory>../src/testScripts/</testSourceDirectory>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
<manifest>
<mainClass>testScripts.NewTest</mainClass>
</manifest>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<systemPropertyVariables>
<propertyName>firefox</propertyName>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.5.3</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.10</version>
<exclusions>
<exclusion>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
Move your test in
src/test/java
Please look at see documentation https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html

jOOQ 3.1 prints logs, but jOOQ 3.4 doesn't

I'm having a strange problem in my project (Spring, log4j, maven, jOOQ). The project is a multi-jar with a parent and a common poms shared by all the children projects.
The problem
If I use jOOQ 3.1 in one of the child projects, the rolling file is created and updated with all the logs. If I recompile the project using jOOQ 3.4 (jar is a dependency of the common pom project) my rolling file is not created and I don't get any logs.
Why did I upgrade from 3.1 to 3.4? Because I was getting this error.
My log4j.properties file is as follows:
log4j.rootCategory=DEBUG, stdout, rollingFile
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t %c] - %m%n
log4j.appender.stdout.layout.ConversionPattern=%p [%c{3}] %m%n
log4j.appender.rollingFile=org.apache.log4j.RollingFileAppender
log4j.appender.rollingFile.File=${catalina.base}/logs/my_file.log
log4j.appender.rollingFile.layout.ConversionPattern=%5p %d{dd MMM yyyy HH:mm:ss} [%c] - %m%n
log4j.appender.rollingFile.Append=true
log4j.appender.rollingFile.layout=org.apache.log4j.PatternLayout
log4j.appender.rollingFile.DatePattern='.'yyyy-MM-dd
log4j.appender.rollingFile.MaxFileSize=10MB
log4j.appender.rollingFile.MaxBackupIndex=99
I can't think of a relation between the jOOQ version and printing / not printing logs, especially as the jOOQ documentation makes clear that it's very easy to log. So that's why I have to ask you guys.
Please don't hesitate to ask for more details.
Thanks everyone!
UPDATE 1 - Pom sources
These are all the concerned poms (some details have been modified for obvious reasons)
super_parent_module
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>my_group_id</groupId>
<artifactId>super_parent_module</artifactId>
<version>1.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>name</name>
<description>description</description>
<url>http://maven.apache.org</url>
<scm>
<developerConnection>XXXXX</developerConnection>
</scm>
<distributionManagement>
<!-- repository -->
</distributionManagement>
<profiles>
<!-- profiles -->
</profiles>
<properties>
<deployment.local.directory>XXXXX</deployment.local.directory>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.10</version>
<configuration>
<configLocation>XXXXXXX</configLocation>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<configuration>
<instrumentation>
<excludes>
<exclude>**/generated/**</exclude>
</excludes>
</instrumentation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<tagNameFormat>v#{project.version}</tagNameFormat>
<autoVersionSubmodules>true</autoVersionSubmodules>
<releaseProfiles>releases</releaseProfiles>
<remoteTagging>true</remoteTagging>
<tagBase>XXXXXXXX</tagBase>
</configuration>
</plugin>
</plugins>
</build>
</project>
super_common_module
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>my_group_id</groupId>
<artifactId>super_parent_module</artifactId>
<version>1.0.1-SNAPSHOT</version>
<relativePath />
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>super_common_module</artifactId>
<version>1.0.10-SNAPSHOT</version>
<name>name</name>
<url>http://maven.apache.org</url>
<scm>
<developerConnection>XXXXXX</developerConnection>
</scm>
<dependencies>
<dependency>
<!-- guava 15 -->
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>3.2.4.RELEASE</version>
</dependency>
<dependency>
<groupId>args4j</groupId>
<artifactId>args4j</artifactId>
<version>2.0.26</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ojdbc</groupId>
<artifactId>ojdbc</artifactId>
<version>14</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>${project.build.sourceDirectory}</directory>
</resource>
<resource>
<directory>${basedir}/src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
</transformers>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>with-deps</shadedClassifierName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
parent_module
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>my_group_id</groupId>
<artifactId>super_parent_module</artifactId>
<version>1.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>my_group_id.client</groupId>
<artifactId>parent_module</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>parent_module</name>
<description>description</description>
<url>http://maven.apache.org</url>
<scm>
<developerConnection>XXXXXX</developerConnection>
</scm>
<modules>
<module>common_module</module>
<module>my_problematic_module</module>
<module>other_module</module>
<module>other_module</module>
</modules>
<profiles>
<!-- profiles -->
</profiles>
<properties>
<springws.version>2.1.3.RELEASE</springws.version>
<spring.version>3.2.4.RELEASE</spring.version>
<jooq.version>3.4.0</jooq.version>
<jooq-codegen.url>XXXXX</jooq-codegen.url>
<jooq-codegen.user>XXXXX</jooq-codegen.user>
<jooq-codegen.password>XXXX</jooq-codegen.password>
</properties>
<dependencies>
<dependency>
<groupId>my_group_id</groupId>
<artifactId>super_common_module</artifactId>
<version>1.0.10-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
common_module
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>my_group_id.client</groupId>
<artifactId>parent_module</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>common_module</artifactId>
<description>description</description>
<packaging>jar</packaging>
<name>name</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>${jooq.version}</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq</artifactId>
<version>${jooq.version}</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-meta</artifactId>
<version>${jooq.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- jOOQ configuration -->
<plugin>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>${jooq.version}</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>ojdbc</groupId>
<artifactId>ojdbc</artifactId>
<version>14</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.6</version>
</dependency>
<dependency>
<groupId>my_group_id</groupId>
<artifactId>jooq-ext</artifactId>
<version>1.0.3-SNAPSHOT</version>
</dependency>
</dependencies>
<configuration>
<jdbc>
<driver>oracle.jdbc.OracleDriver</driver>
<url>${jooq-codegen.url}</url>
<user>${jooq-codegen.user}</user>
<password>${jooq-codegen.password}</password>
</jdbc>
<generator>
<name>org.jooq.util.MyGenerator</name>
<database>
<name>org.jooq.util.oracle.OracleDatabase</name>
<includes>tables and packages</includes>
<excludes />
<inputSchema>my_schema</inputSchema>
</database>
<generate>
<relations>true</relations>
<deprecated>false</deprecated>
<instanceFields>true</instanceFields>
<generatedAnnotation>false</generatedAnnotation>
<records>true</records>
<pojos>false</pojos>
<immutablePojos>false</immutablePojos>
<interfaces>false</interfaces>
<daos>false</daos>
<jpaAnnotations>false</jpaAnnotations>
<validationAnnotations>false</validationAnnotations>
<globalObjectReferences>false</globalObjectReferences>
</generate>
<target>
<packageName>my_group_id.model.generated</packageName>
<directory>${project.build.directory}/generated-xxxxx/jooq</directory>
</target>
</generator>
</configuration>
</plugin>
</plugins>
</build>
</project>
my_problematic_module
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>my_group_id.client</groupId>
<artifactId>parent_module</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>my_problematic_module</artifactId>
<packaging>war</packaging>
<name>name</name>
<description>description</description>
<url>http://www.springframework.org/spring-ws</url>
<profiles>
<!-- profiles... -->
</profiles>
<scm>
<connection>XXXXXX</connection>
</scm>
<build>
<finalName>${project.artifactId}-${project.version}-${lane}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<attachClasses>true</attachClasses>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<url>http://localhost:8084/manager</url>
<server>mytomcat</server>
<path>/project_path</path>
</configuration>
</plugin>
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.3</version>
<dependencies>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.6.5</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>exec_id</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<target>2.0</target>
<wsdlDirectory>src/main/resources/wsdl</wsdlDirectory>
<wsdlFiles>
<wsdlFile>exec_id.wsdl</wsdlFile>
</wsdlFiles>
<extension>true</extension>
<xjcArgs>
<!-- xjcArg>some args</xjcArg -->
</xjcArgs>
</configuration>
</execution>
<execution>
<!-- another execution -->
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<configuration>
<instrumentation>
<excludes>
<exclude>XXXXX</exclude>
<exclude>**/generated/**</exclude>
</excludes>
</instrumentation>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>common_module</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-test</artifactId>
<version>${springws.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.6.5</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<configuration>
<instrumentation>
<excludes>
<exclude>XXXXX</exclude>
<exclude>**/generated/**</exclude>
</excludes>
</instrumentation>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
I found a solution:
I have noticed that jooq-codegen-maven-3.4.0.jar has a log4j.xml and that jooq-codegen-maven-3.1.0.jar doesn't.
I have then created a log4j.xml file to replace my log4j.properties and the rollingFile has started writing again!
I believe log4j was using the xml version in jooq-codegen-maven-3.4.0.jar (which writes in console only) and not my log4j.properties. Maybe there's a way to tell log4j which file has more priority, but apparently creating this other log4j.xml has overriden jooq's.
#LukasEder, do you think this should be taken care of in jooq?
Thanks
It looks like you're missing the log4j dependency in your pom.xml file. jOOQ tries to find that dependency on the classpath, but you haven't added it (at least not in that module).
Try adding
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
(It's curious that this would have worked prior to jOOQ 3.4)

EclipseLink + Maven: java.lang.NoClassDefFoundError: javax/persistence/Persistence

My Persistence.xml is as follows:
<persistence-unit name="SARMPersistentUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>edu.deakin.sarms.model.StudentAccount</class>
<class>edu.deakin.sarms.model.LecturerAccount</class>
<class>edu.deakin.sarms.model.Unit</class>
<class>edu.deakin.sarms.model.Enrollment</class>
<class>edu.deakin.sarms.model.Attendance</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://xx.yy.ss:3306/t2"/>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.user" value="xx"/>
<property name="javax.persistence.jdbc.password" value="ee"/>
<property name="eclipselink.ddl-generation" value="drop-create-tables"/>
</properties>
</persistence-unit>
pom.xml is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>edu.deakin.sarms</groupId>
<artifactId>sarms2</artifactId>
<version>1.0-SNAPSHOT</version>
<repositories>
<repository>
<id>oss.sonatype.org</id>
<name>OSS Sonatype Staging</name>
<url>https://oss.sonatype.org/content/groups/staging</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.5.0</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.persistence</groupId>
<artifactId>commonj.sdo</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
<encoding>UTF-8</encoding>
<fork>true</fork>
<meminitial>128M</meminitial>
<maxmem>512M</maxmem>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>edu.deakin.sarms.service.SarmsControl</mainClass>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
Still I am getting "java.lang.NoClassDefFoundError: javax/persistence/Persistence", on the line:
public static EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("SARMPersistentUnit");
Can anyone please suggest what am I doing wrong?
Cheers
Ayesha
I was doing a mvn clean install and then java -jar . Then I used the command mentioned by #ajozwk in the comment, but I had another issue, the persistence.xml file was under src/main/ instead of src/main/resources. So now my problem is fixed!

Resources