Using maven-assembly-plugin I could bundle my java web application into a single standalone.jar
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>my.package.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>standalone</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</plugin>
using the command
$ mvn clean compile assembly:single
The application is a REST back-end based on grizzly and jersey. I can start it using
$ java -jar standalone.jar
and it seems to work. The console output tells me that the HTTP server has started and is now listening on port 8765.
Unfortunately when I send a request to any of the REST endpoints I receive a response with error code 500 Internal Server Error. As I can conclude from the output, none of the request handling methods are called.
The application works correctly if it is started from within the IDE IntelliJ (by pressing the run button).
A similar questions was asked Java JAR behaving differently to program run out of IDE but in my case the flag -Dfile.encoding=UTF-8 which is also set by the IDE does not solve the problem
EDIT
As suggested in the comments, I have tried to inspect the log output. I was following the approach described in Grizzly Standalone Logging
When I run the application from the IDE with the finest logging level I receive a lot of additional messages including an an exception
Dez 03, 2016 11:36:07 PM org.glassfish.jersey.internal.util.ReflectionHelper$2 run
FINER: Unable to load class org.osgi.framework.BundleReference using the current class loader.
java.lang.ClassNotFoundException: org.osgi.framework.BundleReference
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)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.glassfish.jersey.internal.util.ReflectionHelper$2.run(ReflectionHelper.java:262)
at org.glassfish.jersey.internal.util.ReflectionHelper$2.run(ReflectionHelper.java:247)
at java.security.AccessController.doPrivileged(Native Method)
at org.glassfish.jersey.internal.util.ReflectionHelper.<clinit>(ReflectionHelper.java:1471)
at org.glassfish.jersey.server.ResourceConfig$State.<init>(ResourceConfig.java:112)
at org.glassfish.jersey.server.ResourceConfig.<init>(ResourceConfig.java:353)
at my.package.Main.main(Main.java:42)
I do not get any additional logging messages when I execute the standalone.jar with -Djava.util.logging.config.file=...