SEVERE - App startup failed because of SingleAppCoreServletListener & SingleAppWebServletListener error

Hi!

I am trying to deploy my cuba (6.6.2) application to a tomcat (8.0.26) server but it wont start.

I build the project with gradle (3.4) and copy the app.war file to my tomcat\webapps folder. Then I start the local tomcat server. When I try to connect to the local server I get the welcome page, but when I try to connect to the app (localhost:11723/app) I get the 404 error screen saying:

 HTTP Status: 404 - /app
 type: Status report
 message: /app
 description: The requested resource is not available.
 Apache Tomcat/8.0.26

The logs are:

catalina.out:

 [...]
 **22-Jan-2018 16:56:25.372 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file**
 **22-Jan-2018 16:56:25.376 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Context [/app] startup failed due to previous errors**
 16:56:25,379 |-INFO in ch.qos.logback.classic.servlet.LogbackServletContextListener@dcd90d - About to stop ch.qos.logback.classic.LoggerContext [default]
 22-Jan-2018 16:56:25.388 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of configuration descriptor /projects/SuperSkill/Workspace/release/daily/apache-tomcat-8.0.26/conf/Catalina/localhost/app.xml has finished in 6,846 ms
 22-Jan-2018 16:56:25.389 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /projects/SuperSkill/Workspace/release/daily/apache-tomcat-8.0.26/webapps/manager
 22-Jan-2018 16:56:25.418 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /projects/SuperSkill/Workspace/release/daily/apache-tomcat-8.0.26/webapps/manager has finished in 29 ms
 22-Jan-2018 16:56:25.418 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /projects/SuperSkill/Workspace/release/daily/apache-tomcat-8.0.26/webapps/ROOT
 22-Jan-2018 16:56:25.428 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /projects/SuperSkill/Workspace/release/daily/apache-tomcat-8.0.26/webapps/ROOT has finished in 10 ms
 22-Jan-2018 16:56:25.429 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /projects/SuperSkill/Workspace/release/daily/apache-tomcat-8.0.26/webapps/docs
 22-Jan-2018 16:56:25.438 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /projects/SuperSkill/Workspace/release/daily/apache-tomcat-8.0.26/webapps/docs has finished in 10 ms
 22-Jan-2018 16:56:25.438 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /projects/SuperSkill/Workspace/release/daily/apache-tomcat-8.0.26/webapps/host-manager
 22-Jan-2018 16:56:25.450 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /projects/SuperSkill/Workspace/release/daily/apache-tomcat-8.0.26/webapps/host-manager has finished in 12 ms
 22-Jan-2018 16:56:25.450 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /projects/SuperSkill/Workspace/release/daily/apache-tomcat-8.0.26/webapps/examples
 22-Jan-2018 16:56:25.558 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /projects/SuperSkill/Workspace/release/daily/apache-tomcat-8.0.26/webapps/examples has finished in 108 ms
 22-Jan-2018 16:56:25.564 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-apr-11723"]
 22-Jan-2018 16:56:25.570 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-apr-11724"]
 22-Jan-2018 16:56:25.571 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 7060 ms

localhost.2018-01-22.log:

 22-Jan-2018 16:56:25.195 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log Initializing AtmosphereFramework
 22-Jan-2018 16:56:25.308 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log No Spring WebApplicationInitializer types detected on classpath
 **22-Jan-2018 16:56:25.368 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class com.haulmont.cuba.core.sys.singleapp.SingleAppCoreServletListener**
  java.lang.NullPointerException
 	at sun.net.util.URLUtil.urlNoFragString(URLUtil.java:50)
 	at sun.misc.URLClassPath.getLoader(URLClassPath.java:512)
 	at sun.misc.URLClassPath.getNextLoader(URLClassPath.java:484)
 	at sun.misc.URLClassPath.getResource(URLClassPath.java:238)
 	at java.net.URLClassLoader$1.run(URLClassLoader.java:365)
 	at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
 	at java.security.AccessController.doPrivileged(Native Method)
 	at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
 	at com.haulmont.cuba.core.sys.CubaSingleAppClassLoader.loadClass(CubaSingleAppClassLoader.java:43)
 	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
 	at java.lang.ClassLoader.defineClass1(Native Method)
 	at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
 	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
 	at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
 	at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
 	at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
 	at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
 	at java.security.AccessController.doPrivileged(Native Method)
 	at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
 	at com.haulmont.cuba.core.sys.CubaSingleAppClassLoader.loadClass(CubaSingleAppClassLoader.java:43)
 	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
 	at java.lang.ClassLoader.defineClass1(Native Method)
 	at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
 	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
 	at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
 	at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
 	at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
 	at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
 	at java.security.AccessController.doPrivileged(Native Method)
 	at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
 	at com.haulmont.cuba.core.sys.CubaSingleAppClassLoader.loadClass(CubaSingleAppClassLoader.java:43)
 	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
 	at java.lang.ClassLoader.defineClass1(Native Method)
 	at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
 	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
 	at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
 	at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
 	at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
 	at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
 	at java.security.AccessController.doPrivileged(Native Method)
 	at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
 	at com.haulmont.cuba.core.sys.CubaSingleAppClassLoader.loadClass(CubaSingleAppClassLoader.java:43)
 	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
 	at com.haulmont.cuba.core.sys.singleapp.SingleAppCoreServletListener.contextInitialized(SingleAppCoreServletListener.java:81)
 	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4729)
 	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167)
 	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
 	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
 	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
 	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
 	at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:586)
 	at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1750)
 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
 	at java.lang.Thread.run(Thread.java:748)

 **22-Jan-2018 16:56:25.372 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class com.haulmont.cuba.web.sys.singleapp.SingleAppWebServletListener**
  java.lang.NullPointerException
 	at sun.net.util.URLUtil.urlNoFragString(URLUtil.java:50)
 	at sun.misc.URLClassPath.getLoader(URLClassPath.java:512)
 	at sun.misc.URLClassPath.getNextLoader(URLClassPath.java:484)
[...]

 **22-Jan-2018 16:56:25.381 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.listenerStop Exception sending context destroyed event to listener instance of class com.haulmont.cuba.web.sys.singleapp.SingleAppWebServletListener**
  java.lang.NullPointerException
 	at com.haulmont.cuba.web.sys.singleapp.SingleAppWebServletListener.contextDestroyed(SingleAppWebServletListener.java:94)
 	at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4776)
 	at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5390)
 	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
 	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
 	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
[...]

 22-Jan-2018 16:56:25.554 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized()
 22-Jan-2018 16:56:25.554 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized()

The strange thing is, when I open the project in Cuba Studio and start the application from there, it builds and starts just fine. Cuba Studio uses tomcat 8.5.xx (don’t remember the exact version) so I tried to deploy to tomcat 8.5.24, but I got the same error. The project worked on tomcat 8.0.26 last week, and the only thing that changed is that we added some JUnit 5 tests.

I am using Java 1.8.0_152
and the project uses a Gradle 3.4 wrapper

I already tried to revert to a previous app version through git, but I also got errors (sometimes the same, sometimes others). I am not sure whether there is a problem with tomcat or cuba.

I also tried to copy the tomcat folder that cuba studio starts from build/tomcat. It actually worked to launch this tomcat instance and the app! But then I tried to copy the app.war to tomcat/webapps and the server stoped working again with the error message at the top of the post. So I rather think that it’s a problem with our app than with the tomcat, but I am not sure.

I would really like to know why the SingleAppCoreServletListener and the SingleAppWebServletListener don’t work. Maybe somebody knows a solution for this error.

I am really clueless plz send help, this error terrifies me for too long :’(

Greez
Rene

PS.: sorry for the long logs… I tried to shorten them a little bit. Here are the full version:

logs.zip (3.5 KB)

1 Like

Hi,

Could you try to reproduce the problem in the sample project?

Hi!

The error always occurs, when I try to deploy the .war file from my project to my tomcat instance.

What sample project do you mean?

Hi,

Could you try to create a new project using CUBA Studio, create WAR and deploy it to the Tomcat?
Will the error occur?
Please zip that project and attach it to the topic.

Hi!

I created a new Project with Cuba Studio and build the .war. Then i tried to deploy it to the tomcat and the same error occurred:

29-Jan-2018 15:40:27.082 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log Initializing AtmosphereFramework
29-Jan-2018 15:40:27.280 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log No Spring WebApplicationInitializer types detected on classpath
29-Jan-2018 15:40:29.201 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class com.haulmont.cuba.core.sys.singleapp.SingleAppCoreServletListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in class path resource [cuba-spring.xml]: Cannot resolve reference to bean ‘cubaDataSource’ while setting bean property ‘dataSource’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘cubaDataSource’ defined in class path resource [cuba-spring.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [jdbc/CubaDS] is not bound in this Context. Unable to find [jdbc].

Here is the attached project:
https://1drv.ms/u/s!AoWHXfp9cYCyiPZ5S0ej2imq70k2kA

I had to configure a proxy in gradle.settings, so don’t wonder :slight_smile:

Hey,

i also deployed my cuba application to a tomcat Server and also faced mulitple problems. Took me multiple hours, so i will share my experience with you. The issues i had, or the things i did wrong:

  • First i used tomcat7, but some strange errors occurde switched to tomcat8

  • my tomcat is running under debian 9, i neede to install libservlet3.1-java (apt-get install libservlet3.1-java)

  • i forgot to enter the correct app home directory in the gradle build task
    image

  • then at last i needed to copy the context.xml from “CUBA_workspace\modules\core\web\META-INF\context.xml” to “/var/lib/tomcat8/conf/Catalina/localhost” and renamed it to app-core.xml

hopefully this will help you.

@CUBATeam: is it common or normal to copy the context.xml by hand to the localhost directory of the tomcat. nowhere in the documentary is there any information about this topic. :frowning:

Best Regards
Daniel

CUBA Platform ist awesome

Hi,
A database connection is not configured. Try to generate context.xml file when configuring WAR building in the Studio. Set checkbox IncludeTomcat’s context.xml and click Generate button and setup database connection params.

Hi,

You can specify the custom context.xml file for WAR building. Try to generate context.xml file when configuring WAR building in the Studio. Set checkbox IncludeTomcat’s context.xml and click Generate button and setup database connection params.

You can find more information about deployment on Linux in the https://doc.cuba-platform.com/manual-6.7/tomcat_war_deployment_linux.html

thanks for the feedback. i completely overlooked this checkbox

Hi guys!

Thanks for all the help so far :slight_smile:

I generated and added the context.xml. Now when i try to open localhost:11723/app I get this:

Unexpected Error:
Cuba-UnexpectedError

I don’t have the rights to install libservlet3.1-java on my system, is there an other way to get this library?

do should get any error message in the logs? Catalina or localhost log i think. please have a look.

maybe the team from CUBA can tell us if the libservlet3.1-java package is really neccessary or if there is an other option or solution for it.
maybe you can ask your sys admin to install the package ? or is it that big of a deal for you ?

Daniel

Hi there!

I found a solution to my problem :smiley:

In the .war file there are 2 files:
app.war\WEB-INF\core.dependencies
app.war\WEB-INF\web.dependencies

they had entries like this:

app-global-0.8.0-SNAPSHOT.jar
cuba-core-6.6.2.jar
cuba-global-6.6.2.jar
app-core-0.8.0_alpha-SNAPSHOT.jar
app-core-0.8.0-SNAPSHOT.jar

the problem was the line:

app-core-0.8.0_alpha-SNAPSHOT.jar

This was a dependency from on old alpha build and should not be referenced anymore.

So what I did to fix this is:
In the repo delete all the build folders
modules\core\build
modules\gui\build
modules\web\build

And in Cuba Studio click on Build > Clean

After this the .dependencies files don’t had the reference to the alpha .jar anymore and everything worked :slight_smile:

What I learned today: Clean up your #$%cking project directory
xD thx bye

3 Likes