I have this pom.xml
<?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>org.springframework</groupId>
<artifactId>gs-maven</artifactId>
<packaging>jar</packaging>
<version>0.1.0</version>
<build>
<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.ManifestResourceTransformer">
<mainClass>hello.HelloWorld</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.1.4.Final</version>
<exclusions>
<exclusion>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>ch.simas.qlrm</groupId>
<artifactId>qlrm</artifactId>
<version>1.5.1</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
The dependency:tree is
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building gs-maven 0.1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # gs-maven ---
[INFO] org.springframework:gs-maven:jar:0.1.0
[INFO] +- org.hibernate:hibernate-core:jar:4.1.4.Final:compile
[INFO] | +- antlr:antlr:jar:2.7.7:compile
[INFO] | +- org.jboss.logging:jboss-logging:jar:3.1.0.GA:compile
[INFO] | +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar:1.0.0.Final:compile
[INFO] | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile
[INFO] | +- org.javassist:javassist:jar:3.15.0-GA:compile
[INFO] | \- org.hibernate.common:hibernate-commons-annotations:jar:4.0.1.Final:compile
[INFO] \- ch.simas.qlrm:qlrm:jar:1.5.1:compile
[INFO] +- org.eclipse.persistence:eclipselink:jar:2.5.1:compile
[INFO] | +- org.eclipse.persistence:javax.persistence:jar:2.1.0:compile
[INFO] | \- org.eclipse.persistence:commonj.sdo:jar:2.1.1:compile
[INFO] \- com.h2database:h2:jar:1.3.170:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.142 s
[INFO] Finished at: 2015-01-23T15:43:19+05:30
[INFO] Final Memory: 8M/81M
[INFO] ------------------------------------------------------------------------
Even though I have excluded javax.persistence I'm getting the following warnings while build
[WARNING] javax.persistence-2.1.0.jar, hibernate-jpa-2.0-api-1.0.1.Final.jar define 92 overlappping classes:
[WARNING] - javax.persistence.SecondaryTable
[WARNING] - javax.persistence.TableGenerator
[WARNING] - javax.persistence.NamedNativeQueries
[WARNING] - javax.persistence.TransactionRequiredException
[WARNING] - javax.persistence.SecondaryTables
[WARNING] - javax.persistence.JoinTable
[WARNING] - javax.persistence.Id
[WARNING] - javax.persistence.Embedded
[WARNING] - javax.persistence.EntityResult
[WARNING] - javax.persistence.EntityManager
[WARNING] - 82 more...
[WARNING] javax.persistence-2.1.0.jar, eclipselink-2.5.1.jar define 24 overlappping classes:
[WARNING] - javax.persistence.NamedStoredProcedureQuery
[WARNING] - javax.persistence.ConstructorResult
[WARNING] - javax.persistence.ParameterMode
[WARNING] - javax.persistence.Index
[WARNING] - javax.persistence.AttributeConverter
[WARNING] - javax.persistence.NamedStoredProcedureQueries
[WARNING] - javax.persistence.Subgraph
[WARNING] - javax.persistence.ConstraintMode
[WARNING] - javax.persistence.Converts
[WARNING] - javax.persistence.criteria.CriteriaUpdate
[WARNING] - 14 more...
[WARNING] javax.persistence-2.1.0.jar, eclipselink-2.5.1.jar, hibernate-jpa-2.0-api-1.0.1.Final.jar define 80 overlappping classes:
[WARNING] - javax.persistence.criteria.SetJoin
[WARNING] - javax.persistence.criteria.Predicate
[WARNING] - javax.persistence.CacheRetrieveMode
[WARNING] - javax.persistence.TupleElement
[WARNING] - javax.persistence.metamodel.PluralAttribute
[WARNING] - javax.persistence.AccessType
[WARNING] - javax.persistence.Access
[WARNING] - javax.persistence.metamodel.ManagedType
[WARNING] - javax.persistence.metamodel.ListAttribute
[WARNING] - javax.persistence.criteria.CriteriaBuilder$Trimspec
[WARNING] - 70 more...
[WARNING] maven-shade-plugin has detected that some .class files
[WARNING] are present in two or more JARs. When this happens, only
[WARNING] one single version of the class is copied in the uberjar.
[WARNING] Usually this is not harmful and you can skeep these
[WARNING] warnings, otherwise try to manually exclude artifacts
[WARNING] based on mvn dependency:tree -Ddetail=true and the above
[WARNING] output
[WARNING] See http://docs.codehaus.org/display/MAVENUSER/Shade+Plugin
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing /Users/sivakr/Documents/java/maven_1/target/gs-maven-0.1.0.jar with /Users/sivakr/Documents/java/maven_1/target/gs-maven-0.1.0-shaded.jar
[INFO] Dependency-reduced POM written at: /Users/sivakr/Documents/java/maven_1/dependency-reduced-pom.xml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.214 s
[INFO] Finished at: 2015-01-23T15:43:11+05:30
[INFO] Final Memory: 7M/81M
[INFO] ------------------------------------------------------------------------
How to exclude the duplicate jar's ? And eliminate warnings
UPDATED dependency:tree
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building gs-maven 0.1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # gs-maven ---
[INFO] org.springframework:gs-maven:jar:0.1.0
[INFO] +- org.hibernate:hibernate-core:jar:4.1.4.Final:compile
[INFO] | +- antlr:antlr:jar:2.7.7:compile
[INFO] | +- org.jboss.logging:jboss-logging:jar:3.1.0.GA:compile
[INFO] | +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar:1.0.0.Final:compile
[INFO] | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile
[INFO] | +- org.javassist:javassist:jar:3.15.0-GA:compile
[INFO] | \- org.hibernate.common:hibernate-commons-annotations:jar:4.0.1.Final:compile
[INFO] \- ch.simas.qlrm:qlrm:jar:1.5.1:compile
[INFO] +- org.eclipse.persistence:eclipselink:jar:2.5.1:compile
[INFO] | \- org.eclipse.persistence:commonj.sdo:jar:2.1.1:compile
[INFO] \- com.h2database:h2:jar:1.3.170:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.138 s
[INFO] Finished at: 2015-01-23T18:11:06+05:30
[INFO] Final Memory: 8M/81M
[INFO] ------------------------------------------------------------------------
The POM change to exclude a dependency more than one level away is the same as excluding a dependency exactly one level away.
According to the documentation
if the dependency graph is as follows
Project-A
-> Project-B
-> Project-D
-> Project-E <!-- Exclude this dependency -->
-> Project-F
-> Project C
to exclude project E in project A POM
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>sample.ProjectA</groupId>
<artifactId>Project-A</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
...
<dependencies>
<dependency>
<groupId>sample.ProjectB</groupId>
<artifactId>Project-B</artifactId>
<version>1.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>sample.ProjectE</groupId> <!-- Exclude Project-E from Project-B -->
<artifactId>Project-E</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
Maven depdendcy plugin output format is:
[groupId]:[artifactId]:[type]:[version]
for the dependency:
org.eclipse.persistence:javax.persistence:jar:2.1.0:compile
The group is org.eclipse.persistence and the artifactId is javax.persistence
Your exclusion rule is wrong, the group and artifact are reversed. It should be:
<exclusions>
<exclusion>
<artifactId>javax.persistence</artifactId>
<groupId>org.eclipse.persistence</groupId>
</exclusion>
</exclusions>
EDIT: Add maven-shade-plugin configuration
To exclude the dependency from maven-shade-plugin try to add the exclusions to the plugin configuration:
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<excludes>
<exclude>org.eclipse.persistence:javax.persistence</exclude>
</excludes>
</artifactSet>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>hello.HelloWorld</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
Related
I have been trying to pack the properties file inside my jar using Maven but no luck so far.
Project Structure:
src/main/java
All java source files
src/test/java
All test java source files
src/main/resource
All properties files. For example, application.properties
...
pom.xml
POM.XML File Contents:
<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>Database</groupId>
<artifactId>Executor</artifactId>
<version>0.1</version>
<packaging>jar</packaging>
<name>DatabaseExecutor</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.framework.version>5.2.0.RELEASE</spring.framework.version>
<spring.framework.group.id>org.springframework</spring.framework.group.id>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<fully.qualified.main.class>com.applications.App</fully.qualified.main.class>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.14.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.14.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${spring.framework.group.id}</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.framework.version}</version>
</dependency>
<dependency>
<groupId>${spring.framework.group.id}</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.framework.version}</version>
</dependency>
<dependency>
<groupId>${spring.framework.group.id}</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.framework.version}</version>
</dependency>
<dependency>
<groupId>${spring.framework.group.id}</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.framework.version}</version>
</dependency>
<dependency>
<groupId>${spring.framework.group.id}</groupId>
<artifactId>spring-expression</artifactId>
<version>${spring.framework.version}</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>12.2.0.1</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.2</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/libs</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<version>3.2.0</version>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>libs/</classpathPrefix>
<mainClass>${fully.qualified.main.class}</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
I have created a build.bat file to build the code having the below content.
#ECHO OFF
call mvn -e pre-clean
call mvn -e clean
call mvn -e compile
call mvn -e package -DskipTests
Command Prompt Logs:
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< Database:Executor >--------------------------
[INFO] Building DatabaseExecutor 0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.146 s
[INFO] Finished at: 2021-02-02T19:10:26+05:30
[INFO] ------------------------------------------------------------------------
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< Database:Executor >--------------------------
[INFO] Building DatabaseExecutor 0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # Executor ---
[INFO] Deleting C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.465 s
[INFO] Finished at: 2021-02-02T19:10:28+05:30
[INFO] ------------------------------------------------------------------------
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< Database:Executor >--------------------------
[INFO] Building DatabaseExecutor 0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # Executor ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # Executor ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.165 s
[INFO] Finished at: 2021-02-02T19:10:33+05:30
[INFO] ------------------------------------------------------------------------
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< Database:Executor >--------------------------
[INFO] Building DatabaseExecutor 0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # Executor ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # Executor ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # Executor ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # Executor ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # Executor ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-dependency-plugin:3.1.2:copy-dependencies (copy-dependencies) # Executor ---
[INFO] Copying log4j-api-2.14.0.jar to C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\target\libs\log4j-api-2.14.0.jar
[INFO] Copying log4j-core-2.14.0.jar to C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\target\libs\log4j-core-2.14.0.jar
[INFO] Copying junit-3.8.1.jar to C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\target\libs\junit-3.8.1.jar
[INFO] Copying spring-core-5.2.0.RELEASE.jar to C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\target\libs\spring-core-5.2.0.RELEASE.jar
[INFO] Copying spring-jcl-5.2.0.RELEASE.jar to C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\target\libs\spring-jcl-5.2.0.RELEASE.jar
[INFO] Copying spring-context-5.2.0.RELEASE.jar to C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\target\libs\spring-context-5.2.0.RELEASE.jar
[INFO] Copying spring-aop-5.2.0.RELEASE.jar to C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\target\libs\spring-aop-5.2.0.RELEASE.jar
[INFO] Copying spring-beans-5.2.0.RELEASE.jar to C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\target\libs\spring-beans-5.2.0.RELEASE.jar
[INFO] Copying spring-expression-5.2.0.RELEASE.jar to C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\target\libs\spring-expression-5.2.0.RELEASE.jar
[INFO] Copying ojdbc14-12.2.0.1.jar to C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\target\libs\ojdbc14-12.2.0.1.jar
[INFO]
[INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) # Executor ---
[INFO] Building jar: C:\Users\VarunJain\Documents\Personal\DevEnv\_Setups\PracticeWorkspace\DatabaseExecutor\target\Executor-0.1.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.292 s
[INFO] Finished at: 2021-02-02T19:10:39+05:30
[INFO] ------------------------------------------------------------------------
Though the executable jar file is getting created successfully but the properties file is missing in the jar file. I'm not sure what is the mistake here. Can somebody please point out the mistake or tell me if I missed something.
Thanks In Advance,
Varun Jain
I resolved it myself by creating the new project and copying the contents from this project to the newly created project.
I'm trying to use jsonschema2pojo to convert the FHIR schema to a java object. If I use this example schema then the generated java classes are create just fine, but when I use this Json Schema then nothing is created and I don't see any errors to understand why its not created. Can anybody help me understand where the failure is?
My pom file
<?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>DMSAdpater</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.jsonschema2pojo</groupId>
<artifactId>jsonschema2pojo-maven-plugin</artifactId>
<version>1.0.2</version>
<configuration>
<sourceDirectory>${basedir}/src/main/resources/schema</sourceDirectory>
<targetPackage>com.example.types</targetPackage>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.5.4</version>
</dependency>
</dependencies>
The Output of my mvn compile
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.example:DMSAdpater:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. # line 13, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] -----------------------< org.example:DMSAdpater >-----------------------
[INFO] Building DMSAdpater 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # DMSAdpater ---
[INFO] Deleting H:\Workspaces\HDI\Project\DMS_Adapter\target
[INFO]
[INFO] --- jsonschema2pojo-maven-plugin:1.0.2:generate (default) # DMSAdpater ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # DMSAdpater ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 11 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # DMSAdpater ---
[INFO] Nothing to compile - all classes are up to date
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 25.745 s
[INFO] Finished at: 2020-07-13T12:01:07-04:00
[INFO] ------------------------------------------------------------------------
Maven test output in the Eclipse console:
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for Mabi:Mabi:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.seleniumhq.selenium:selenium-java:jar -> duplicate declaration of version 2.45.0 # line 20, column 21
[WARNING] 'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.apache.maven.plugins:maven-surefire-plugin # line 74, column 10
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Mabi 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # Mabi ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory E:\workspace\Mabi\src\com.TestCase
[INFO]
[INFO] --- maven-compiler-plugin:3.5:compile (default-compile) # Mabi ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 166 source files to E:\workspace\Mabi\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # Mabi ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory E:\workspace\Mabi\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5:testCompile (default-testCompile) # Mabi ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.19.1:test (default-test) # Mabi ---
[INFO] No tests to run.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.287 s
[INFO] Finished at: 2016-03-23T11:32:40+05:30
[INFO] Final Memory: 21M/283M
[INFO] ------------------------------------------------------------------------
Above image shows the directory of my project but when I run the project via Maven it gives me the above result without running the test. Looking forward for some accurate solutions.
And this is what my POM.XML file looks like:
<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>Mabi</groupId>
<artifactId>Mabi</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>2.40.2</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.45.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src/com.TestCase</directory>
<includes>
<include>**/com.*TestCase.java</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5</version>
<configuration>
<source/>
<target/>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<inherited>true</inherited>
<configuration>
<suiteXmlFile>testng.xml</suiteXmlFile>
</configuration>
</plugin>
</plugins>
</build>
</project>
Maven is all about "convention over configuration" idiom. In order that maven-surefire-plugin will run your testcases it expects to find it under src/test/java, hence, you should follow the maven's standard directory layout and put all your test cases under src/test/java.
I'm trying to run the junit webdriver example from sauce labs, but I get the following error when I run 'mvn test':
java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
Here is the full pom.xml:
<?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>
<artifactId>sauce-project</artifactId>
<groupId>com.sparkcentral</groupId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>sauce_quickstart</name>
<description>A sample Maven project that demonstrates how to integrate Sauce OnDemand with WebDriver tests
that run using JUnit
</description>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.saucelabs</groupId>
<artifactId>sauce_junit</artifactId>
<version>[1.0.0,)</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>LATEST</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>saucelabs-repository</id>
<url>https://repository-saucelabs.forge.cloudbees.com/release</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</project>
The project was created by running:
mvn archetype:generate -DarchetypeRepository=http://repository-saucelabs.forge.cloudbees.com/release -DarchetypeGroupId=com.saucelabs -DarchetypeArtifactId=quickstart-webdriver-junit -DarchetypeVersion=1.0.7 -DsauceUserName=<USERNAME> -DsauceAccessKey=<KEY>
I've tried adding an exclusion for hamcrest and also tried using junit 4.11, but I keep getting java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
Output from mvn dependency:tree:
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.sparkcentral:sauce-project:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. # line 37, column 21
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-surefire-plugin is missing. # line 44, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building sauce_quickstart 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # sauce-project ---
[INFO] com.sparkcentral:sauce-project:jar:1.0-SNAPSHOT
[INFO] +- junit:junit:jar:4.10:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.1:test
[INFO] +- com.saucelabs:sauce_junit:jar:2.1.3:test
[INFO] | +- com.saucelabs:sauce_java_common:jar:2.1.3:test
[INFO] | \- com.saucelabs:saucerest:jar:1.0.9:test
[INFO] | +- com.googlecode.json-simple:json-simple:jar:1.1:test
[INFO] | +- org.apache.httpcomponents:httpclient:jar:4.3.1:test
[INFO] | | +- org.apache.httpcomponents:httpcore:jar:4.3:test
[INFO] | | +- commons-logging:commons-logging:jar:1.1.3:test
[INFO] | | \- commons-codec:commons-codec:jar:1.6:test
[INFO] | \- org.json:json:jar:20090211:test
[INFO] \- org.seleniumhq.selenium:selenium-java:jar:2.42.2:test
[INFO] +- org.seleniumhq.selenium:selenium-chrome-driver:jar:2.42.2:test
[INFO] | \- org.seleniumhq.selenium:selenium-remote-driver:jar:2.42.2:test
[INFO] | +- cglib:cglib-nodep:jar:2.1_3:test
[INFO] | \- com.google.guava:guava:jar:15.0:test
[INFO] +- org.seleniumhq.selenium:selenium-htmlunit-driver:jar:2.42.2:test
[INFO] | \- net.sourceforge.htmlunit:htmlunit:jar:2.14:test
[INFO] | +- xalan:xalan:jar:2.7.1:test
[INFO] | | \- xalan:serializer:jar:2.7.1:test
[INFO] | +- commons-collections:commons-collections:jar:3.2.1:test
[INFO] | +- org.apache.commons:commons-lang3:jar:3.2.1:test
[INFO] | +- org.apache.httpcomponents:httpmime:jar:4.3.2:test
[INFO] | +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.14:test
[INFO] | +- xerces:xercesImpl:jar:2.11.0:test
[INFO] | | \- xml-apis:xml-apis:jar:1.4.01:test
[INFO] | +- net.sourceforge.nekohtml:nekohtml:jar:1.9.20:test
[INFO] | +- net.sourceforge.cssparser:cssparser:jar:0.9.13:test
[INFO] | | \- org.w3c.css:sac:jar:1.3:test
[INFO] | \- org.eclipse.jetty:jetty-websocket:jar:8.1.14.v20131031:test
[INFO] | +- org.eclipse.jetty:jetty-util:jar:8.1.14.v20131031:test
[INFO] | +- org.eclipse.jetty:jetty-io:jar:8.1.14.v20131031:test
[INFO] | \- org.eclipse.jetty:jetty-http:jar:8.1.14.v20131031:test
[INFO] +- org.seleniumhq.selenium:selenium-firefox-driver:jar:2.42.2:test
[INFO] | +- commons-io:commons-io:jar:2.4:test
[INFO] | \- org.apache.commons:commons-exec:jar:1.1:test
[INFO] +- org.seleniumhq.selenium:selenium-ie-driver:jar:2.42.2:test
[INFO] | +- net.java.dev.jna:jna:jar:3.4.0:test
[INFO] | \- net.java.dev.jna:platform:jar:3.4.0:test
[INFO] +- org.seleniumhq.selenium:selenium-safari-driver:jar:2.42.2:test
[INFO] +- org.seleniumhq.selenium:selenium-support:jar:2.42.2:test
[INFO] | \- org.seleniumhq.selenium:selenium-api:jar:2.42.2:test
[INFO] \- org.webbitserver:webbit:jar:0.4.14:test
[INFO] \- io.netty:netty:jar:3.5.2.Final:test
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.328 s
[INFO] Finished at: 2014-07-01T10:46:54-07:00
[INFO] Final Memory: 9M/81M
[INFO] ------------------------------------------------------------------------
Any advice?
How about adding the dependency for hamcrest in your pom?
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
</dependency>
Also see this related SO question.
I've just added:
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
</dependency>
after
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
and it worked in my project.
I need some help with trying to get an executable working. This is a tricky one and I've narrowed it down to the fact that something is different with the way that maven exec runs things and how either the maven shade plugin or the maven assembly plugin is packaging the files.
I'm building a REST service in Java with Netty and JAX-RS and use Jackson to translate from POJOs to JSON.
The server starts up correctly when executing either mvn exec:java or java -jar. But when making a request against the java -jar file, I get the following error:
Could not find MessageBodyWriter for response object of type: [Ljava.lang.Object; of media type: application/json
It seems like something isn't being packaged correctly, but I'm not sure what. Transitive dependencies are missing, maybe?
Here's my POM:
<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>com.test.myserver</groupId>
<artifactId>myserver</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>myserver</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>oss-sonatype</id>
<name>oss-sonatype</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<build>
<plugins>
<!-- For executing in maven itself (mvn exec:java) -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.test.myserver.App</mainClass>
</configuration>
</plugin>
<plugin>
<!-- for packaging (mvn package) -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.test.myserver.App</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<!-- The configuration of maven-assembly-plugin -->
<plugin>
<!-- for packaging (mvn compile assembly:single) -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<!-- The configuration of the plugin -->
<configuration>
<archive>
<manifest>
<mainClass>com.test.myserver.App</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>LATEST</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.googlecode.plist</groupId>
<artifactId>dd-plist</artifactId>
<version>LATEST</version>
</dependency>
<!-- MongoDB -->
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>2.12.0</version>
</dependency>
<dependency>
<groupId>org.mongojack</groupId>
<artifactId>mongojack</artifactId>
<version>2.1.0-SNAPSHOT</version>
</dependency>
<!-- REST Server -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-netty</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson2-provider</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>LATEST</version>
</dependency>
</dependencies>
Maven shade is executed with mvn package.
Maven assembly is executed with mvn compile assembly:single.
Thanks in advance!
EDIT
I checked mvn dependency:tree against the output for mvn shade and for all intents, they look the same.
Output from dependency tree
$ mvn dependency:tree
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building myserver 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # myserver ---
[INFO] com.test.myserver:myserver:jar:1.0-SNAPSHOT
[INFO] +- junit:junit:jar:4.11:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- com.googlecode.plist:dd-plist:jar:1.8:compile
[INFO] +- org.mongodb:mongo-java-driver:jar:2.12.0:compile
[INFO] +- org.mongojack:mongojack:jar:2.1.0-SNAPSHOT:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.2.3:compile
[INFO] | +- de.undercouch:bson4jackson:jar:2.2.0:compile
[INFO] | +- javax.persistence:persistence-api:jar:1.0.2:compile
[INFO] | \- commons-io:commons-io:jar:2.4:compile
[INFO] +- org.jboss.resteasy:resteasy-jaxrs:jar:3.0.8.Final:compile
[INFO] | +- org.jboss.resteasy:jaxrs-api:jar:3.0.8.Final:compile
[INFO] | +- org.jboss.spec.javax.annotation:jboss-annotations-api_1.1_spec:jar:1.0.1.Final:compile
[INFO] | +- javax.activation:activation:jar:1.1:compile
[INFO] | +- org.apache.httpcomponents:httpclient:jar:4.2.1:compile
[INFO] | | +- org.apache.httpcomponents:httpcore:jar:4.2.1:compile
[INFO] | | +- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] | | \- commons-codec:commons-codec:jar:1.6:compile
[INFO] | \- net.jcip:jcip-annotations:jar:1.0:compile
[INFO] +- org.jboss.resteasy:resteasy-netty:jar:3.0.8.Final:compile
[INFO] | \- io.netty:netty:jar:3.6.4.Final:compile
[INFO] +- org.jboss.resteasy:resteasy-jackson2-provider:jar:3.0.8.Final:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-core:jar:2.3.2:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.3.2:compile
[INFO] | \- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.3.2:compile
[INFO] | +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.3.2:compile
[INFO] | \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.3.2:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.7:compile
[INFO] +- org.slf4j:slf4j-simple:jar:1.7.7:compile
[INFO] \- org.reflections:reflections:jar:0.9.9-RC1:compile
[INFO] +- com.google.guava:guava:jar:11.0.2:compile
[INFO] | \- com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO] +- org.javassist:javassist:jar:3.16.1-GA:compile
[INFO] \- dom4j:dom4j:jar:1.6.1:compile
[INFO] \- xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.999 s
[INFO] Finished at: 2014-04-22T17:09:47-08:00
[INFO] Final Memory: 13M/310M
[INFO] ------------------------------------------------------------------------
Output from shade
$ mvn package
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) # myserver ---
[INFO] Building jar: /myserver/target/myserver-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-shade-plugin:2.2:shade (default) # myserver ---
[INFO] Including com.googlecode.plist:dd-plist:jar:1.8 in the shaded jar.
[INFO] Including org.mongodb:mongo-java-driver:jar:2.12.0 in the shaded jar.
[INFO] Including org.mongojack:mongojack:jar:2.1.0-SNAPSHOT in the shaded jar.
[INFO] Including com.fasterxml.jackson.core:jackson-databind:jar:2.2.3 in the shaded jar.
[INFO] Including de.undercouch:bson4jackson:jar:2.2.0 in the shaded jar.
[INFO] Including javax.persistence:persistence-api:jar:1.0.2 in the shaded jar.
[INFO] Including commons-io:commons-io:jar:2.4 in the shaded jar.
[INFO] Including org.jboss.resteasy:resteasy-jaxrs:jar:3.0.8.Final in the shaded jar.
[INFO] Including org.jboss.resteasy:jaxrs-api:jar:3.0.8.Final in the shaded jar.
[INFO] Including org.jboss.spec.javax.annotation:jboss-annotations-api_1.1_spec:jar:1.0.1.Final in the shaded jar.
[INFO] Including javax.activation:activation:jar:1.1 in the shaded jar.
[INFO] Including org.apache.httpcomponents:httpclient:jar:4.2.1 in the shaded jar.
[INFO] Including org.apache.httpcomponents:httpcore:jar:4.2.1 in the shaded jar.
[INFO] Including commons-logging:commons-logging:jar:1.1.1 in the shaded jar.
[INFO] Including commons-codec:commons-codec:jar:1.6 in the shaded jar.
[INFO] Including net.jcip:jcip-annotations:jar:1.0 in the shaded jar.
[INFO] Including org.jboss.resteasy:resteasy-netty:jar:3.0.8.Final in the shaded jar.
[INFO] Including io.netty:netty:jar:3.6.4.Final in the shaded jar.
[INFO] Including org.jboss.resteasy:resteasy-jackson2-provider:jar:3.0.8.Final in the shaded jar.
[INFO] Including com.fasterxml.jackson.core:jackson-core:jar:2.3.2 in the shaded jar.
[INFO] Including com.fasterxml.jackson.core:jackson-annotations:jar:2.3.2 in the shaded jar.
[INFO] Including com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.3.2 in the shaded jar.
[INFO] Including com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.3.2 in the shaded jar.
[INFO] Including com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.3.2 in the shaded jar.
[INFO] Including org.slf4j:slf4j-api:jar:1.7.7 in the shaded jar.
[INFO] Including org.slf4j:slf4j-simple:jar:1.7.7 in the shaded jar.
[INFO] Including org.reflections:reflections:jar:0.9.9-RC1 in the shaded jar.
[INFO] Including com.google.guava:guava:jar:11.0.2 in the shaded jar.
[INFO] Including com.google.code.findbugs:jsr305:jar:1.3.9 in the shaded jar.
[INFO] Including org.javassist:javassist:jar:3.16.1-GA in the shaded jar.
[INFO] Including dom4j:dom4j:jar:1.6.1 in the shaded jar.
[INFO] Including xml-apis:xml-apis:jar:1.0.b2 in the shaded jar.
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing /myserver/target/myserver-1.0-SNAPSHOT.jar with /myserver/target/myserver-1.0-SNAPSHOT-shaded.jar
[INFO] Dependency-reduced POM written at: /myserver/dependency-reduced-pom.xml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.658 s
[INFO] Finished at: 2014-04-22T17:05:50-08:00
[INFO] Final Memory: 39M/310M
[INFO] ------------------------------------------------------------------------
The shade plugin configuration is missing the service transformer which merges the META-INF/services files used by the service discovery mechanism.
Here is an example:
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.example.helloworld.HelloWorldApplication</mainClass>
</transformer>
</transformers>
It's interesting because I asked myself the question yesterday, "why do I need an über jar?" And, as it turns out, I don't and probably shouldn't be using an über jar. Alexey correctly answered the question to solve the immediate problem, but I also wanted to post an alternate solution that I figured out for doing things a little bit differently.
Rather than using the shade plugin to build an über jar, I decided to create a standard jar and export all the dependencies needed to run my application. This means that I now use the Maven Jar Plugin to create my jar and the Maven Dependency Plugin to export the libraries. Here's what the build section of the pom.xml looks like:
<build>
<plugins>
<!-- For copying the libraries to the output directory -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
<!-- Create the executable jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.test.myserver.App</mainClass>
<useUniqueVersions>false</useUniqueVersions>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
Since my output directory is target/, my jar is generated as target/myserver-1.0-SNAPSHOT.jar and all the dependencies are in target/lib/. The maven-jar-plugin also build the classpath and points them correctly to the lib/ directory, so I'm pretty much set. This also makes it easier in the future to replace individual libraries as they are updated, rather than uploading an entirely new jar.
Building the jar and copying the dependencies is simply mvn install from the command line.