spring-projects / spring-boot

Spring Boot helps you to create Spring-powered, production-grade applications and services with absolute minimum fuss.
https://spring.io/projects/spring-boot
Apache License 2.0
75.23k stars 40.7k forks source link

unable to start Spring Boot Executable Jar Application with JavaServiceWrapper #1037

Closed dominik42 closed 10 years ago

dominik42 commented 10 years ago

We use the Java Service Wrapper from TanukiSoftware for production environments of our java applications. Now I want to start a Spring Boot App as executable jar file the same way, but I've got the following exception:

java.lang.reflect.InvocationTargetException
INFO   | jvm 4    | 2014/06/05 14:36:58 |   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
INFO   | jvm 4    | 2014/06/05 14:36:58 |   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
INFO   | jvm 4    | 2014/06/05 14:36:58 |   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
INFO   | jvm 4    | 2014/06/05 14:36:58 |   at java.lang.reflect.Method.invoke(Method.java:601)
INFO   | jvm 4    | 2014/06/05 14:36:58 |   at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
INFO   | jvm 4    | 2014/06/05 14:36:58 |   at java.lang.Thread.run(Thread.java:722)
INFO   | jvm 4    | 2014/06/05 14:36:58 | Caused by: java.lang.IllegalStateException: java.lang.IllegalStateException: Unable to determine code source archive
INFO   | jvm 4    | 2014/06/05 14:36:58 |   at org.springframework.boot.loader.ExecutableArchiveLauncher.<init>(ExecutableArchiveLauncher.java:41)
INFO   | jvm 4    | 2014/06/05 14:36:58 |   at org.springframework.boot.loader.JarLauncher.<init>(JarLauncher.java:30)
INFO   | jvm 4    | 2014/06/05 14:36:58 |   at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:45)
INFO   | jvm 4    | 2014/06/05 14:36:58 |   ... 6 more
INFO   | jvm 4    | 2014/06/05 14:36:58 | Caused by: java.lang.IllegalStateException: Unable to determine code source archive
INFO   | jvm 4    | 2014/06/05 14:36:58 |   at org.springframework.boot.loader.Launcher.createArchive(Launcher.java:147)
INFO   | jvm 4    | 2014/06/05 14:36:58 |   at org.springframework.boot.loader.ExecutableArchiveLauncher.<init>(ExecutableArchiveLauncher.java:38)
INFO   | jvm 4    | 2014/06/05 14:36:58 |   ... 8 more

Any suggestions ?

dsyer commented 10 years ago

Works for me. What did you do exactly? E.g. can you paste in the changes you made to the stock wrapper.conf?

dominik42 commented 10 years ago

The origin error message is gone ... there was a problem during the maven packaging phase and the resulting executable jar file itself was wrong and the same error was shown for starting the jar the normal way (java -jar ...) without the wrapper. After fixing the packaging phase and including an assembly descriptor in order to assemble a bin-tar including the spring boot jar, the wrapper and all that configuration stuff, everything works except one exception during the startup phase of the spring boot application. But nevertheless, the app is up'n'running.

java.net.MalformedURLException: no !/ in spec
    at java.net.URL.<init>(URL.java:619)
    at java.net.URL.<init>(URL.java:482)
    at java.net.URL.<init>(URL.java:431)
    at org.springframework.boot.loader.jar.JarURLConnection.<init>(JarURLConnection.java:73)
    at org.springframework.boot.loader.jar.Handler.openConnection(Handler.java:75)
    at java.net.URL.openConnection(URL.java:971)
    at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:250)
    at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:221)
    at org.springframework.boot.context.embedded.tomcat.SkipPatternJarScanner.scan(CustomSkipPatternJarScanner.java:51)
    at org.apache.catalina.startup.TldConfig.execute(TldConfig.java:266)
    at org.apache.catalina.startup.TldConfig.lifecycleEvent(TldConfig.java:562)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5355)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NullPointerException: no !/ in spec
    at sun.net.www.protocol.jar.Handler.parseAbsoluteSpec(Handler.java:170)
    at sun.net.www.protocol.jar.Handler.parseURL(Handler.java:150)
    at java.net.URL.<init>(URL.java:614)
dsyer commented 10 years ago

That might be an issue with the Boot class loader, or it might be a problem with your wrapper config. Can you paste in your wrapper.conf (or the deltas from the standard one)? A sample project would help a lot. Probably it's fixed in 1.1.3 anyway.

dominik42 commented 10 years ago

Hi,

here is my working wrapper conf (for wrapper 3.2.3)

wrapper.debug=true


Wrapper Properties

****

Java Application

wrapper.java.command=java

wrapper.java.classpath.1=../lib/wrapper.jar

wrapper.java.library.path.1=../lib

wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperJarApp

wrapper.app.parameter.1=../lib/mdeWebServices-MarcAurel-1.0-SNAPSHOT.jar wrapper.app.parameter.2=--logging.config=../config/log4j.properties

Java Additional Parameters

wrapper.java.additional.1=-Dproject.short=ma wrapper.java.additional.2=-Djava.awt.headless=true wrapper.java.additional.3=-Dcom.sun.management.jmxremote.port=10992 wrapper.java.additional.4=-Dcom.sun.management.jmxremote.authenticate=false wrapper.java.additional.5=-Dcom.sun.management.jmxremote.ssl=false wrapper.java.additional.6=-XX:MaxPermSize=64m wrapper.java.additional.7=-Xss512k

wrapper.java.additional.8=-Xdebug

wrapper.java.additional.9=-Xnoagent

wrapper.java.additional.10=-Djava.compiler=NONE

wrapper.java.additional.11=-Xrunjdwp:transport=dt_socket,address=8989,server=y,suspend=n

Initial Java Heap Size (in MB)

wrapper.java.initmemory=128

Maximum Java Heap Size (in MB)

wrapper.java.maxmemory=512

wrapper.ping.timeout=0 wrapper.disable_shutdown_hook=TRUE

wrapper.max_failed_invocations=15

wrapper.restart.delay=5 wrapper.restart.reload_configuration=TRUE

wrapper.umask=0002 wrapper.java.umask=0002

****

Wrapper Logging Properties

****

Format of output for the console. (See docs for formats)

wrapper.console.format=PM

Log Level for console output. (See docs for log levels)

wrapper.console.loglevel=INFO

Log file to use for wrapper output logging.

wrapper.logfile=../log/wrapper-mdeWebServices.log

Format of output for the log file. (See docs for formats)

wrapper.logfile.format=LPTM

Log Level for log file output. (See docs for log levels)

wrapper.logfile.loglevel=INFO

Maximum size that the log file will be allowed to grow to before

the log is rolled. Size is specified in bytes. The default value

of 0, disables log rolling. May abbreviate with the 'k' (kb) or

'm' (mb) suffix. For example: 10m = 10 megabytes.

wrapper.logfile.maxsize=2m

Maximum number of rolled log files which will be allowed before old

files are deleted. The default value of 0 implies no limit.

wrapper.logfile.maxfiles=10

Log Level for sys/event log output. (See docs for log levels)

wrapper.syslog.loglevel=NONE

****

Wrapper Windows Properties

****

Title to use when running as a console

wrapper.console.title=SICSone MDEWebServices MarcAurel

Gruß:Dominik

Am 12.08.2014 um 13:08 schrieb Patrice:

I know this one is closed, but I have the same issue. Difference is that my Spring Boot App works as an executable jar no problem. But with the tanuki wrapper it stops witn the 'Unable to determine code source archive' . What did you do to make that go away? Can you provide a wrapper conf that worked for you? Thanks!

— Reply to this email directly or view it on GitHub.

dominik42 commented 10 years ago

BTW, why your email isn't listed at GitHub ???

Am 12.08.2014 um 13:08 schrieb Patrice:

I know this one is closed, but I have the same issue. Difference is that my Spring Boot App works as an executable jar no problem. But with the tanuki wrapper it stops witn the 'Unable to determine code source archive' . What did you do to make that go away? Can you provide a wrapper conf that worked for you? Thanks!

— Reply to this email directly or view it on GitHub.

ibanezje commented 10 years ago

Hi thanks for the reply. My fault I, deleted my comment thinking it was no use to comment a closed case. Anyway thanks for the wrapper.conf. I see no real difference with my setup. So maybe my problem is in the executable jar. I've setup a simple spring boot app, like gs-spring-boot. (http://spring.io/guides/gs/spring-boot/) Stanalone it runs fine by itself. With the tanuki wrapper I get java.lang.IllegalStateException: Unable to determine code source archive. And that is a Spring exception. may have something to do with Spring not being able to determine a certain (jar)path?

dsyer commented 10 years ago

If you can share your wrapper configuration there's a chance someone might be able to see the error.

ibanezje commented 10 years ago

Ok, here it is. Maybe I should mention I'm on Windows 7, java 8, and wrapper 3.5.24 (all 64 bit)

#********************************************************************
#* Wrapper Java Properties
#********************************************************************
wrapper.java.command=java
wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperJarApp
wrapper.java.classpath.1=../lib/wrapper.jar
wrapper.java.library.path.1=../lib
wrapper.java.additional.auto_bits=TRUE
wrapper.java.additional.1=-Dproject.short=ma
wrapper.java.additional.2=-Djava.awt.headless=true
wrapper.java.additional.3=-XX:MaxPermSize=64m
wrapper.java.additional.4=-Xss512k
wrapper.java.initmemory=128
wrapper.java.maxmemory=512
wrapper.ping.timeout=0
wrapper.max_failed_invocations=15
wrapper.restart.delay=5
wrapper.restart.reload_configuration=TRUE
wrapper.app.parameter.1=../lib/gs-spring-boot-0.1.0.jar

#********************************************************************
#* Wrapper Logging Properties
#********************************************************************
wrapper.debug=TRUE
wrapper.console.format=PM
wrapper.console.loglevel=INFO
wrapper.logfile=../logs/wrapper.log
wrapper.logfile.format=LPTM
wrapper.logfile.loglevel=INFO
wrapper.logfile.maxsize=2m
wrapper.logfile.maxfiles=10
wrapper.syslog.loglevel=NONE

#********************************************************************
#* Wrapper General Properties
#********************************************************************
wrapper.ignore_sequence_gaps=TRUE
wrapper.pidfile.strict=TRUE
wrapper.console.title=My simple springboot
dvtoever commented 10 years ago

I have the same problem. The TanukiSoftware is not used in my case, but the maven-jar-plugin.

java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: Unable to determine code source archive
        at org.springframework.boot.loader.Launcher.createArchive(Launcher.java:147)
        at org.springframework.boot.loader.PropertiesLauncher.getProperty(PropertiesLauncher.java:427)
        at org.springframework.boot.loader.PropertiesLauncher.getProperty(PropertiesLauncher.java:389)
        at org.springframework.boot.loader.PropertiesLauncher.getArgs(PropertiesLauncher.java:330)
        at org.springframework.boot.loader.PropertiesLaunch

It seems related to the project being a maven project (B) that is dependant on another maven project (A). When I run mvn clean install on project A and then run mvn clean install on project B, the problem usually goes away.

philwebb commented 10 years ago

@dvtoever Could you please open a new issue if you're still having problems. Please provide some more details and ideally a sample project that replicates the issue.