Tomcat error using war file

58 views
Skip to first unread message

Neil Thackeray

unread,
Aug 1, 2018, 5:39:34 PM8/1/18
to xnat_discussion
I'm having some problems getting tomcat to use my war file. I followed the directions in the documentation, but at first I installed java jdk 1.8. I had these problems and then installed 1.7, but that didn't seem to fix the problem. I'm not a java person so I'm not sure where to go from here.

Aug  1 16:31:51 xnat-dev server: INFO: Deploying web application archive /var/lib/tomcat/webapps/ROOT.war
Aug  1 16:31:52 xnat-dev server: Aug 01, 2018 4:31:52 PM org.apache.catalina.core.ContainerBase addChildInternal
Aug  1 16:31:52 xnat-dev server: SEVERE: ContainerBase.addChild: start:
Aug  1 16:31:52 xnat-dev server: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
Aug  1 16:31:52 xnat-dev server: at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)
Aug  1 16:31:52 xnat-dev server: at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
Aug  1 16:31:52 xnat-dev server: at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
Aug  1 16:31:52 xnat-dev server: at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
Aug  1 16:31:52 xnat-dev server: at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1092)
Aug  1 16:31:52 xnat-dev server: at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1984)
Aug  1 16:31:52 xnat-dev server: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
Aug  1 16:31:52 xnat-dev server: at java.util.concurrent.FutureTask.run(FutureTask.java:266)
Aug  1 16:31:52 xnat-dev server: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
Aug  1 16:31:52 xnat-dev server: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
Aug  1 16:31:52 xnat-dev server: at java.lang.Thread.run(Thread.java:748)
Aug  1 16:31:52 xnat-dev server: Caused by: org.apache.catalina.LifecycleException: Failed to start component [WebappLoader[]]
Aug  1 16:31:52 xnat-dev server: at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)
Aug  1 16:31:52 xnat-dev server: at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5499)
Aug  1 16:31:52 xnat-dev server: at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
Aug  1 16:31:52 xnat-dev server: ... 10 more
Aug  1 16:31:52 xnat-dev server: Caused by: java.lang.NullPointerException
Aug  1 16:31:52 xnat-dev server: at java.util.Arrays.sort(Arrays.java:1246)
Aug  1 16:31:52 xnat-dev server: at org.apache.catalina.loader.VirtualWebappLoader.startInternal(VirtualWebappLoader.java:146)
Aug  1 16:31:52 xnat-dev server: at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
Aug  1 16:31:52 xnat-dev server: ... 12 more
Aug  1 16:31:52 xnat-dev server: Aug 01, 2018 4:31:52 PM org.apache.catalina.startup.HostConfig deployWAR
Aug  1 16:31:52 xnat-dev server: SEVERE: Error deploying web application archive /var/lib/tomcat/webapps/ROOT.war
Aug  1 16:31:52 xnat-dev server: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
Aug  1 16:31:52 xnat-dev server: at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:903)
Aug  1 16:31:52 xnat-dev server: at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
Aug  1 16:31:52 xnat-dev server: at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
Aug  1 16:31:52 xnat-dev server: at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1092)
Aug  1 16:31:52 xnat-dev server: at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1984)
Aug  1 16:31:52 xnat-dev server: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
Aug  1 16:31:52 xnat-dev server: at java.util.concurrent.FutureTask.run(FutureTask.java:266)
Aug  1 16:31:52 xnat-dev server: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
Aug  1 16:31:52 xnat-dev server: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
Aug  1 16:31:52 xnat-dev server: at java.lang.Thread.run(Thread.java:748)
Aug  1 16:31:52 xnat-dev server: Aug 01, 2018 4:31:52 PM org.apache.catalina.startup.HostConfig deployWAR
Aug  1 16:31:52 xnat-dev server: INFO: Deployment of web application archive /var/lib/tomcat/webapps/ROOT.war has finished in 193 ms
Aug  1 16:31:52 xnat-dev server: Aug 01, 2018 4:31:52 PM org.apache.coyote.AbstractProtocol start
Aug  1 16:31:52 xnat-dev server: INFO: Starting ProtocolHandler ["http-apr-8080"]
Aug  1 16:31:52 xnat-dev server: Aug 01, 2018 4:31:52 PM org.apache.coyote.AbstractProtocol start
Aug  1 16:31:52 xnat-dev server: INFO: Starting ProtocolHandler ["ajp-apr-8009"]
Aug  1 16:31:52 xnat-dev server: Aug 01, 2018 4:31:52 PM org.apache.catalina.startup.Catalina start
Aug  1 16:31:52 xnat-dev server: INFO: Server startup in 301 ms

Herrick, Rick

unread,
Aug 1, 2018, 5:48:52 PM8/1/18
to xnat_di...@googlegroups.com

I think you haven’t defined xnat.home in your Tomcat configuration. XNAT has a custom context definition that configures that VirtualWebappLoader class:

 

<Loader className="org.apache.catalina.loader.VirtualWebappLoader" searchVirtualFirst="true" virtualClasspath="${xnat.home}/plugins/*.jar"/>

 

I think the null is coming because it’s trying to expand that ${xnat.home} reference but it doesn’t have anything to expand it with.

 

You can check whether Tomcat is getting xnat.home set by looking at the process:

 

$ ps ax | fgrep tomcat

30064 ?        Sl     1:34 /usr/lib/jvm/java-8-openjdk-amd64/bin/java -Djava.util.logging.config.file=/var/lib/tomcat7/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.awt.headless=true -Xms512m -Xmx1g -XX:+UseConcMarkSweepGC -XX:-OmitStackTraceInFastThrow -XX:+CMSIncrementalMode -XX:+CMSClassUnloadingEnabled -Dxnat.home=/data/xnat/home -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000 -agentpath:/opt/yourkit/bin/linux-x86-64/libyjpagent.so -Djava.endorsed.dirs=/usr/share/tomcat7/endorsed -classpath /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar -Dcatalina.base=/var/lib/tomcat7 -Dcatalina.home=/usr/share/tomcat7 -Djava.io.tmpdir=/tmp/tomcat7-tomcat7-tmp org.apache.catalina.startup.Bootstrap start

 

For Debian/Ubuntu servers, you can set this in /etc/default/tomcat7, while on Fedora/RHEL/CentOS servers you can set it in /etc/sysconfig/tomcat7 (or sometimes it’s just tomcat). On my current development server, I have this in /etc/default/tomcat7:

 

# Set CATALINA_OPTS for Tomcat-specific operations, mainly service start and run.

CATALINA_OPTS="-Xms512m -Xmx1g -XX:+UseConcMarkSweepGC -XX:-OmitStackTraceInFastThrow"

CATALINA_OPTS="${CATALINA_OPTS} -XX:+CMSIncrementalMode -XX:+CMSClassUnloadingEnabled"

CATALINA_OPTS="${CATALINA_OPTS} -Dxnat.home=/data/xnat/home"

CATALINA_OPTS="${CATALINA_OPTS} -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000"

CATALINA_OPTS="${CATALINA_OPTS} -agentpath:/opt/yourkit/bin/linux-x86-64/libyjpagent.so"

 

-- 

Rick Herrick

Sr. Programmer/Analyst

Neuroinformatics Research Group

Washington University School of Medicine

Phone: +1 (314) 273-1645

--
You received this message because you are subscribed to the Google Groups "xnat_discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xnat_discussi...@googlegroups.com.
To post to this group, send email to xnat_di...@googlegroups.com.
Visit this group at https://groups.google.com/group/xnat_discussion.
For more options, visit https://groups.google.com/d/optout.

 


The materials in this message are private and may contain Protected Healthcare Information or other information of a sensitive nature. If you are not the intended recipient, be advised that any unauthorized use, disclosure, copying or the taking of any action in reliance on the contents of this information is strictly prohibited. If you have received this email in error, please immediately notify the sender via telephone or return mail.

Neil Thackeray

unread,
Aug 2, 2018, 6:23:39 PM8/2/18
to xnat_discussion
I don't think setting xnat.home is the problem. I checked it and it is set to the right place. I must have something else wrong.

12035 ?        Ssl    0:02 /usr/bin/java -Dxnat.home=/data/xnat/home -Xdebug -classpath /usr/share/tomcat/bin/bootstrap.jar:/usr/share/tomcat/bin/tomcat-juli.jar:/usr/share/java/commons-daemon.jar -Dcatalina.base=/usr/share/tomcat -Dcatalina.home=/usr/share/tomcat -Djava.endorsed.dirs= -Djava.io.tmpdir=/var/cache/tomcat/temp -Djava.util.logging.config.file=/usr/share/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager org.apache.catalina.startup.Bootstrap start

Moore, Charlie

unread,
Aug 2, 2018, 6:30:51 PM8/2/18
to xnat_di...@googlegroups.com

What version of tomcat do you have installed? I recall people having issues with the version of tomcat7 that CentOS7 wants to give you by default.

 

Thanks,

Charlie

--

You received this message because you are subscribed to the Google Groups "xnat_discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xnat_discussi...@googlegroups.com.
To post to this group, send email to xnat_di...@googlegroups.com.
Visit this group at https://groups.google.com/group/xnat_discussion.
For more options, visit https://groups.google.com/d/optout.

Neil Thackeray

unread,
Aug 3, 2018, 11:20:49 AM8/3/18
to xnat_discussion
This is a list of what I have installed.
 
tomcat.noarch                           7.0.76-6.el7                   @base    
tomcat-el-2.2-api.noarch                7.0.76-6.el7                   @base    
tomcat-jsp-2.2-api.noarch               7.0.76-6.el7                   @base    
tomcat-lib.noarch                       7.0.76-6.el7                   @base    
tomcat-native.x86_64                    1.2.17-1.el7                   @epel    
tomcat-servlet-3.0-api.noarch           7.0.76-6.el7                   @base

Moore, Charlie

unread,
Aug 3, 2018, 11:36:27 AM8/3/18
to xnat_di...@googlegroups.com

Yep, tomcat 7.0.76 was the version installed where an issue like this happened previously: https://groups.google.com/forum/#!searchin/xnat_discussion/saltstack%7Csort:date/xnat_discussion/nw7g5tjhDTo/m1mBIZ2VAgAJ . For some reason, the last message in this thread was deleted from the google group. I’m not really sure why that is, but I still have a copy of it in my email. I’d like to check with Rick to see why it was deleted though before I post it; that shouldn’t take long.

 

Thanks,

Charlie

--

You received this message because you are subscribed to the Google Groups "xnat_discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xnat_discussi...@googlegroups.com.
To post to this group, send email to xnat_di...@googlegroups.com.
Visit this group at https://groups.google.com/group/xnat_discussion.
For more options, visit https://groups.google.com/d/optout.

Moore, Charlie

unread,
Aug 3, 2018, 12:02:36 PM8/3/18
to xnat_di...@googlegroups.com

Herrick, Rick

unread,
Aug 3, 2018, 1:19:30 PM8/3/18
to xnat_di...@googlegroups.com

Neil,

 

Charlie and I were just going over this and came up with an idea that might work around the issue. The problem is that Tomcat gets a list of jar files from the folder specified in the VirtualWebappLoader configuration, but it doesn’t find any and so gets a null back. It then tries to sort the list without checking whether or not it’s null, which leads to the failure. To fix this, try the following:

 

$ cd /data/xnat/home/plugins

$ echo Hello > hello.txt

$ jar cf hello.jar hello.txt

$ rm hello.txt

 

Now try starting Tomcat. I think it should work just by virtue of giving it something to sort rather than a null.

 

-- 

Rick Herrick

Sr. Programmer/Analyst

Neuroinformatics Research Group

Washington University School of Medicine

Phone: +1 (314) 273-1645

 

Neil Thackeray

unread,
Aug 3, 2018, 3:11:14 PM8/3/18
to xnat_discussion
That didn't work, but thanks for the suggestion.

Marcel Koek

unread,
Aug 6, 2018, 3:37:25 AM8/6/18
to xnat_discussion
Rick emailed me about the deleted post Charlie mentioned earlier. I was the author of that post and I don't see any reason why this post should not be public and am a bit confused to why that post was deleted ;).
I re-posted the answer which you can find here: https://groups.google.com/d/msg/xnat_discussion/nw7g5tjhDTo/uUcdTuCrAQAJ

The gist is that there is a bug in tomcat 7.0.76 causing the NullPointerException which leads to the LifecycleException with the current xnat context config.

Cheers,
Marcel
Reply all
Reply to author
Forward
0 new messages