Dom4J IllegalAccessError - Seam on JBoss 7 deployment error - java

I'm migrating a legacy application to Maven (and hopefully later away from Seam). There already have been many hitches and glitches, AFAIK Seam is really fickle concerning dependency versions it will work with.
This latest error I can't figure out. So I have an EAR with my (EJB) Jar, a War and the Seam.jar, plus lib/ folder. Now I actually have Dom4J as a dependency with scope=provided, since JBoss AS 7.1 provides version 1.6.1. It gets included into lib/ anyway, which I haven't figured out why yet.
But I get the same error when deleting all superfluous jars from lib/.
Just to reiterate, this application was running before, when built with the Ant build files. The Maven produced EAR won't deploy though. I have heard about similar errors (but not the exact same) with dependencies doubled in the classpath. I have checked (after removing it from lib/) and there should be none but the one in JBoss' modules.
Update: POM structure:
Super-POM is parent of all modules, has DependencyManagement and also contains modules (for now).
Modules: Core-ejb has code and tons of dependencies, mostly with provided since they are in JBoss/modules. Core-web produces WAR, has dep on Core-EJB. Project-Web includes Core-Web, Project-EJB depends on Core-EJB and uses shade-plugin to merge them together (!).
Core-EAR generates ear from shaded-project-ejb and project-web.
(Structure is crazy, but dictated by legacy app).
12:42:37,694 INFO [javax.servlet.ServletContextListener] (MSC service thread 1-6) Welcome to Seam 2.3.1.Final
12:42:38,745 INFO [org.jboss.seam.init.Initialization] (MSC service thread 1-6) reading /WEB-INF/components.xml
12:42:38,749 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/]] (MSC service thread 1-6) Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener: java.lang.IllegalAccessError: tried to access class org.dom4j.io.SAXHelper from class org.dom4j.io.SAXReader
at org.dom4j.io.SAXReader.createXMLReader(SAXReader.java:894) [dom4j-1.6.1.jar:1.6.1]
at org.dom4j.io.SAXReader.getXMLReader(SAXReader.java:715) [dom4j-1.6.1.jar:1.6.1]
at org.dom4j.io.SAXReader.read(SAXReader.java:435) [dom4j-1.6.1.jar:1.6.1]
at org.dom4j.io.SAXReader.read(SAXReader.java:343) [dom4j-1.6.1.jar:1.6.1]
at org.jboss.seam.util.XML.getRootElement(XML.java:24) [jboss-seam-2.3.1.Final.jar:2.3.1.Final]
at org.jboss.seam.init.Initialization.initComponentsFromXmlDocument(Initialization.java:227) [jboss-seam-2.3.1.Final.jar:2.3.1.Final]
at org.jboss.seam.init.Initialization.create(Initialization.java:133) [jboss-seam-2.3.1.Final.jar:2.3.1.Final]
at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:36) [jboss-seam-2.3.1.Final.jar:2.3.1.Final]
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_80]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_80]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_80]
mvn dependency:tree output, after cleanin up one mistake (but same error still):
[INFO] ------------------------------------------------------------------------
[INFO] Building Core Framework 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # Core ---
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Core EJB module 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # Core-ejb ---
[INFO] com.mycomp:Core-ejb:ejb:1.0-SNAPSHOT
[INFO] +- org.hibernate:hibernate-core:jar:4.2.0.Final:provided
[INFO] | \- (dom4j:dom4j:jar:1.6.1:provided - omitted for duplicate)
[INFO] +- dom4j:dom4j:jar:1.6.1:provided
[INFO] \- org.jdom:jdom:jar:1.1.2:provided
[INFO] \- jaxen:jaxen:jar:1.1.3:provided
[INFO] \- (dom4j:dom4j:jar:1.6.1:provided - omitted for duplicate)
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Core Web module 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # Core-web ---
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Project EJB module 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # project-ejb ---
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Project Web module 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # project-web ---
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Core EAR module 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.10:tree (default-cli) # Core-ear ---
[WARNING] Using Maven 2 dependency tree to get verbose output, which may be inconsistent with actual Maven 3 resolution
core-ear POM:
...
<dependencies>
<!-- project specific dependencies -->
<dependency>
<groupId>com.mycomp</groupId>
<artifactId>project-web</artifactId>
<version>${logis.artifact.version}</version>
<type>war</type>
</dependency>
<dependency>
<groupId>com.mycomp</groupId>
<artifactId>project-ejb</artifactId>
<version>${logis.artifact.version}</version>
<type>ejb</type>
</dependency>
<!-- Seam dependency -->
<dependency>
<groupId>org.jboss.seam</groupId>
<artifactId>jboss-seam</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.6</version>
<configuration>
<!-- Tell Maven we are using Java EE 6 -->
<version>6</version>
<!-- Use Java EE ear libraries as needed. Java EE ear libraries are
in easy way to package any libraries needed in the ear, and automatically
have any modules (EJB-JARs and WARs) use them -->
<defaultLibBundleDir>lib</defaultLibBundleDir>
<!-- See maven docs; Necessary because we CAN'T have 2 jboss-seam.jars
in the same EAR -->
<skinnyWars>true</skinnyWars>
<initializeInOrder>true</initializeInOrder>
<modules>
<!-- Explicitly excluding core framework artifacts, as they get merged
(shaded) into the project artifacts -->
<ejbModule>
<groupId>com.mycomp</groupId>
<artifactId>core-ejb</artifactId>
<excluded>true</excluded>
</ejbModule>
<!-- <webModule>
<groupId>com.mycomp</groupId>
<artifactId>core-web</artifactId>
<excluded>true</excluded>
</webModule> -->
<!-- Project specific part -->
<ejbModule>
<groupId>com.mycomp</groupId>
<artifactId>project-ejb</artifactId>
<!-- Manually set jar name, because many JndiNames in logis hard-code
that name -->
<bundleFileName>core.jar</bundleFileName>
</ejbModule>
<webModule>
<groupId>com.mycomp</groupId>
<artifactId>project-web</artifactId>
<contextRoot>/</contextRoot>
</webModule>
<!-- Need to include Seam as a module so it will be "executed" and
can initialize itself -->
<jarModule>
<groupId>org.jboss.seam</groupId>
<artifactId>jboss-seam</artifactId>
<includeInApplicationXml>true</includeInApplicationXml>
<bundleDir>/</bundleDir>
</jarModule>
</modules>
</configuration>
</plugin>
...

It looks like it was some conflict with multiple versions on the classpath anyway.
There was a company specific module, which was just a bunch of jars rolled into one module. After making sure, that only one jdom-*.jar was on the path, it worked.

Related

maven profile should be activated but is not

I have been using maven for years now but I bumped into an issue.
As always I create a repo to illustrate my issue:
git clone https://github.com/clembo590/issues.git --branch mavenProfiles
I just created a multi module maven where I expect the QA profile to be active but it is not.
Here is how the parent pom look like:
<profiles>
<!-- build mdr-commons ONLY IF PRESENT -->
<profile>
<id>mdr-commons</id>
<activation>
<file>
<exists>mdr-commons/pom.xml</exists>
</file>
</activation>
<modules>
<module>mdr-commons</module>
</modules>
</profile>
<profile>
<id>QA</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<!-- this is to check that the coded is formatted : you can use 'apply' instead of 'check' to actually format the code -->
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
if you run mvn clean install you will get
those logs:
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] mdr-parent [pom]
[INFO] mdr-commons [pom]
[INFO]
[INFO] -----------------------< com.example:mdr-parent >-----------------------
[INFO] Building mdr-parent 1.0.0 [1/2]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # mdr-parent ---
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # mdr-parent ---
[INFO] Installing ...
[INFO]
[INFO] ----------------------< com.example:mdr-commons >-----------------------
[INFO] Building mdr-commons 1.0.0 [2/2]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # mdr-commons ---
[INFO]
[INFO] --- spotless-maven-plugin:2.11.1:check (default) # mdr-commons ---
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # mdr-commons ---
[INFO] Installing ...
[INFO] ------------------------------------------------------------------------
spotless-maven-plugin is not executed when building mdr-parent which means that QA profile is not active when build mdr-parent. (it is active when building mdr-commons)
question 1:
why is QA profile not active when building mdr-parent?
question 2:
just delete completely the folder called mdr-commons and re run mvn clean install
--> why is QA profile active this time ? (you will see in the logs that the spotless-maven-plugin is executed)
thanks in advance maven experts
The answer can be found in Details on profile activation of the Maven Guide.
TLDR; Profiles which are activeByDefault are deactivated whenever another profile was activated by any other method.
The mdr-commons profile is activated if file mdr-commons/pom.xml exists. In that case, the QA profile is deactivated. If this file does not exist, the QA profile is "active by default".
That is described in documentation:
This profile will automatically be active for all builds unless
another profile in the same POM is activated using one of the
previously described methods. All profiles that are active by default
are automatically deactivated when a profile in the POM is activated
on the command line or through its activation config.

Why does resolved dependencies differ between Java 8 and Java 11?

Given a very simple Maven project with a single pom-file containing a single dependency:
<?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>org.example</groupId>
<artifactId>maven-test</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.cxf.xjc-utils</groupId>
<artifactId>cxf-xjc-runtime</artifactId>
<version>3.3.0</version>
</dependency>
</dependencies>
</project>
When running mvn dependency:tree different results are given depending on Java version.
With Java 8:
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< org.example:maven-test >-----------------------
[INFO] Building maven-test 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # maven-test ---
[INFO] org.example:maven-test:jar:1.0-SNAPSHOT
[INFO] \- org.apache.cxf.xjc-utils:cxf-xjc-runtime:jar:3.3.0:compile
[INFO] \- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.2:compile
[INFO] \- jakarta.activation:jakarta.activation-api:jar:1.2.1:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.982 s
[INFO] Finished at: 2020-06-22T15:05:56+02:00
[INFO] ------------------------------------------------------------------------
With Java 11:
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< org.example:maven-test >-----------------------
[INFO] Building maven-test 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # maven-test ---
[INFO] org.example:maven-test:jar:1.0-SNAPSHOT
[INFO] \- org.apache.cxf.xjc-utils:cxf-xjc-runtime:jar:3.3.0:compile
[INFO] +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.2:compile
[INFO] | \- jakarta.activation:jakarta.activation-api:jar:1.2.1:compile
[INFO] +- javax.annotation:javax.annotation-api:jar:1.3.1:compile <-- This and below only with Java 11
[INFO] +- javax.xml.ws:jaxws-api:jar:2.3.0:compile
[INFO] | +- javax.xml.bind:jaxb-api:jar:2.3.0:compile
[INFO] | \- javax.xml.soap:javax.xml.soap-api:jar:1.4.0:compile
[INFO] \- javax.activation:activation:jar:1.1.1:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.261 s
[INFO] Finished at: 2020-06-22T15:05:51+02:00
[INFO] ------------------------------------------------------------------------
I would have expected the trees to be the same under the two Java versions.
Maven version is 3.6.0.
Why do the resolved dependencies differ between the Java versions?
The reason why the dependency tree differs between the Java versions is found in the dependency:
<dependency>
<groupId>org.apache.cxf.xjc-utils</groupId>
<artifactId>cxf-xjc-runtime</artifactId>
<version>3.3.0</version>
</dependency>
This in turn has xjc-utils as its parent:
<parent>
<groupId>org.apache.cxf.xjc-utils</groupId>
<artifactId>xjc-utils</artifactId>
<version>3.3.0</version>
</parent>
In this POM file, we find the dependencies that are excluded when building with Java 8:
<profile>
<id>java9-plus</id>
<activation>
<jdk>[9,)</jdk>
</activation>
<dependencies>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
</profile>
This pretty much speacks for itself, the dependencies will only be included if Java 9 or above is used, as stated in this range: <jdk>[9,)</jdk>. The documentation for the tag states:
Specifies that this profile will be activated when a matching JDK is detected. For example, 1.4 only activates on JDKs versioned 1.4, while !1.4 matches any JDK that is not version 1.4.
This activation profile makes sure these dependencies are included when Java 11 is used:
[INFO] +- javax.annotation:javax.annotation-api:jar:1.3.1:compile
[INFO] +- javax.xml.ws:jaxws-api:jar:2.3.0:compile
[INFO] | +- javax.xml.bind:jaxb-api:jar:2.3.0:compile
[INFO] | \- javax.xml.soap:javax.xml.soap-api:jar:1.4.0:compile
[INFO] \- javax.activation:activation:jar:1.1.1:compile
More info about activation can be found in the official Maven documentation:
Activations are the key of a profile. The power of a profile comes from its ability to modify the basic POM only under certain circumstances. Those circumstances are specified via an activation element.
Together with another example of activation based on Java version:
<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
https://maven.apache.org/xsd/maven-4.0.0.xsd">
...
<profiles>
<profile>
<id>test</id>
<activation>
<activeByDefault>false</activeByDefault>
<jdk>1.5</jdk>
<os>
<name>Windows XP</name>
<family>Windows</family>
<arch>x86</arch>
<version>5.1.2600</version>
</os>
<property>
<name>sparrow-type</name>
<value>African</value>
</property>
<file>
<exists>${basedir}/file2.properties</exists>
<missing>${basedir}/file1.properties</missing>
</file>
</activation>
...
</profile>
</profiles>
</project>
Dependency tree mojo trims lower level dependencies if the dependency is already present higher in the tree.
We can use verbose flag (-Dverbose) to show the excluded dependencies.
To find a specific artifact : mvn dependency:tree -Dverbose -Dincludes=[groupId]:[artifactId]:[type]:[version]
Please visit Maven Dependency Tree to know more.

Maven is not using dependency version specified in pom.xml

I have a project A, which has B and C dependencies.
The project B also depends on C.
In project A pom, I have:
<dependencyManagement>
<dependency>
<groupId>br.com.mygroup</groupId>
<artifactId>C</artifactId>
<version>2</version>
</dependency>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>br.com.mygroup</groupId>
<artifactId>B</artifactId>
<version>BVERSION</version>
</dependency>
<dependency>
<groupId>br.com.mygroup</groupId>
<artifactId>C</artifactId>
<version>2</version>
</dependency>
<dependencies>
In project B(version BVERSION), I have:
<dependencies>
<dependency>
<groupId>br.com.mygroup</groupId>
<artifactId>C</artifactId>
<version>1</version>
</dependency>
</dependencies>
I have added some methods in C dependency in version 2, but the code doesn't compile when I try to use the new methods. That is, I can't access the new methods. Project A is using version 1(which is inside project B) of C.
If I change the order of the import in project A pom from B, C to C, B, the code compiles, but at execution time a get java.lang.NoSuchMethodError error.
Shouldn't maven dependencyManagement deal with this problem and force project A to use version 2 of C? Does anyone have an idea of what I am getting wrong?
EDIT 1:
mvn dependency:tree returns the following:
[INFO] br.com.mygroup:A:1.0-SNAPSHOT
[INFO] +- br.com.mygroup:B:jar:BVERSION:compile
[INFO] +- br.com.mygroup:C:jar:2:compile
EDIT 2:
mvn dependency:list returns the following:
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< br.com.mygroup:A >---------------------
[INFO] Building A 1.0-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:list (default-cli) # A ---
[INFO]
[INFO] The following files have been resolved:
[INFO] br.com.mygroup:B:jar:BVERSION:compile
[INFO] br.com.mygroup:C:jar:2:compile
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.639 s
[INFO] Finished at: 2019-10-04T09:03:37-03:00
[INFO] ------------------------------------------------------------------------

Java classes missing from jar built with maven

When i try to run my .jar the classes cannot be found?
Its a basic app, contains 2 custom classes and commons-lang
The .jar contains classes for commons-lang but not for my java classes.
rob#work:~/git/ProjectName/target$ java -jar uber-ProjectName-1.0-SNAPSHOT.jar
Exception in thread "main" java.lang.NoClassDefFoundError: com/test/server/Main
Caused by: java.lang.ClassNotFoundException: com.test.server.Main
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
Could not find the main class: com.test.server.Main. Program will exit.
This is 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.server</groupId>
<artifactId>ProjectName</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>thisisatest</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.3</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<mainClass>com.test.server.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<finalName>uber-${artifactId}-${version}</finalName>
</configuration>
</plugin>
</plugins>
</build>
</project>
build output ..
rob#work:~/git/ProjectName$ mvn package
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building thisisatest
[INFO] task-segment: [package]
[INFO] ------------------------------------------------------------------------
[INFO] Ignoring available plugin update: 2.3 as it requires Maven version 3.0
[INFO] Ignoring available plugin update: 2.2 as it requires Maven version 3.0
[INFO] Ignoring available plugin update: 2.1 as it requires Maven version 3.0
[INFO] Ignoring available plugin update: 2.0 as it requires Maven version 3.0
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/rob/git/ProjectName/src/main/resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] No sources to compile
[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/rob/git/ProjectName/src/test/resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] No sources to compile
[INFO] [surefire:test {execution: default-test}]
[INFO] No tests to run.
[INFO] Surefire report directory: /home/rob/git/ProjectName/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] [jar:jar {execution: default-jar}]
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: /home/rob/git/ProjectName/target/ProjectName-1.0-SNAPSHOT.jar
[INFO] [shade:shade {execution: default}]
[INFO] Including commons-lang:commons-lang:jar:2.3 in the shaded jar.
[INFO] Replacing /home/rob/git/ProjectName/target/uber-ProjectName-1.0-SNAPSHOT.jar with /home/rob/git/ProjectName/target/ProjectName-1.0-SNAPSHOT-shaded.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Tue May 06 22:23:33 IST 2014
[INFO] Final Memory: 17M/179M
[INFO] ------------------------------------------------------------------------
[INFO] [compiler:compile {execution: default-compile}]
[INFO] No sources to compile
Maven can't find any code to compile. This looks very suspicious. Perhaps your maven project is not configured like a maven project should be and it can't find the source. See the project structure diagram from maven.
[INFO] [compiler:compile {execution: default-compile}]
[INFO] No sources to compile
Maven isn't finding your sources, you may not have the directory structure correct. Take a read through http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html
I encountered this issue when I had an extra space before the "main" folder. You can check your folder structure and see if it's correct.

Maven: Combining multiple module jars into one war file?

I have a project babybird which has 3 components persistence, business and service
in babybird's pom.xml I have following
<modules>
<module>persistence</module>
<module>business</module>
<module>service</module>
</modules>
when I run mvn clean install, I see
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] babybird ......................................... SUCCESS [2.801s]
[INFO] persistence ....................................... SUCCESS [3.321s]
[INFO] business .......................................... SUCCESS [0.832s]
[INFO] service ........................................... SUCCESS [0.694s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.168s
[INFO] Finished at: Tue Jan 22 12:09:48 PST 2013
[INFO] Final Memory: 18M/50M
[INFO] ------------------------------------------------------------------------
and each one of these modules generate a jar file.
Question: How can I combine them into one babybird.war?
I am new to Maven and do not know what to look for to accomplish this task, please provide the pointers
That's fairly simple. Create another module named web or similar:
<modules>
<module>persistence</module>
<module>business</module>
<module>service</module>
<module>web</module>
</modules>
web module should depend on all others:
<dependencies>
<dependency>
<groupId>...</groupId>
<artifactId>persistence</artifactId>
</dependency>
...
</dependencies>
and have war packaging:
<packaging>war</packaging>
You'll also need web.xml in /src/main/webapp/WEB-INF. That's it.

Categories

Resources