Hi Alex,
When we execute
$ mvn install
with pom.xml before the patch.
maven produces jar file without dependencies:
target/electric-9.08-a-SNAPSHOT.jar
When we launch it we get an exception because of absent dependecies:
$ java -jar electric-9.08-a-SNAPSHOT.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at com.sun.electric.Launcher.<clinit>(Launcher.java:55)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
jar with depencecies can be procuced by pom.xml before the patch by a command:
$ mvn assembly:assembly
It produces tatget/electric-9.08-a-SNAPSHOT-jar-with-dependencies.jar
This jar contains necessary dependencies including
org.slf4j.slf4j-api - slf4 api
org.slf4j.slf4j-jdk14 - simplie implementation of slf4j-api using JDK classes java.util.logging.*
This command starts Electric succesfully in my environment:
$ java -jar electric-9.08-a-SNAPSHOT-jar-with-dependencies.jar
The suggested patch contains three changes
1) Add dependency with advanced implementationof slf4 api
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>${orgSlf4jVersion}</version>
+ </dependency>
2) Remove main class from jar without dependencies
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.6</version>
- <configuration>
- <archive>
- <manifest>
- <mainClass>com.sun.electric.Launcher</mainClass>
- </manifest>
- </archive>
- </configuration>
- </plugin>
3) mvn install creates jar with dependency also.
mvn nassembly:assembly is no more necessary
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
I agree with the change (3) . An user obtains jar with dependencies automatically
without need to run $ mvn assembly:assembly .
Can you explain why (1) and (2) are necessary ?
Do you need some features form the advanced implementation slf4j-log4j12
which are not available in the simple implementation org.slf4j.slf4j-jdk14 ?
Why do you want to drop manifiest with main calss from jar without dependencies ?
Does pom.xml with only patch (3) works in you environment ?
Best Regards,
-Dima