2

I converted my project just like it was precised in accepted answer for this question

After deployment of .war package (built using Maven) I couldn't launch the app, I looked up the logs and I isolated following part:

Jan 07, 2015 12:12:05 PM org.apache.catalina.core.ContainerBase addChildInternal
SEVERE: ContainerBase.addChild: start: 
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1247)
    at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1898)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    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:745)
Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;
    at org.apache.tomcat.websocket.server.WsServerContainer.<init>(WsServerContainer.java:147)
    at org.apache.tomcat.websocket.server.WsSci.init(WsSci.java:131)
    at org.apache.tomcat.websocket.server.WsSci.onStartup(WsSci.java:47)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5479)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 10 more

Jan 07, 2015 12:12:05 PM org.apache.catalina.startup.HostConfig deployDirectory
SEVERE: Error deploying web application directory /var/lib/tomcat7/webapps/ROOT
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1247)
    at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1898)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    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:745)

Where the following error seems to be essential:

Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;

I deducted that I should add a targeted envirement using my Eclipse IDE (because I heard that it is not advised to add jars and edit files manually).

My Amazon AWS instance is Tomcat 7 Java 7 64bit, so I created a Tomcat 7 server with Java 1.7 on my local machine, but unfortunately it is not selectable.

All environments are not sellectable

It says that I should uninstall some of the facets but as you can see on the following screenshoot, there is nothing seems to be suitable to be uninstalled in order to make it be compatible with Tomcat 7.

Facets

Community
  • 1
  • 1
Marek
  • 1,413
  • 2
  • 20
  • 36
  • Do you use maven or gradle? Then make sure you are building a war and not a jar. Also the API that is request is a Servlet 2.5 API, make sure you don't have an old servlet-api jar in your class path... – M. Deinum Jan 07 '15 at 15:45
  • Thanks for quick feedback. I use Maven and I build a war package. – Marek Jan 07 '15 at 15:46

1 Answers1

0

I finally got it working. The solution was the following.

At first we need to profile our project on desired server.

right click on the project -> profile as -> profile on server

Now select server of your choice, if it is not available you will have to install it (which is pretty simple, you download tar.gz archive, unpack it and select this directory in the wizard).

Now just like I tryied in my question, select this server as Target Runtime, this time it should appear.

right click on the project -> Properties -> Targeted Runtimes -> select your server -> apply

this time server appears

After those steps I built again my war package, deployed it on AWS using ElasticBeanstalk and application run successfully.

Marek
  • 1,413
  • 2
  • 20
  • 36