Resources located inside META-INF/resources directories in jars in WEB-INF/lib are not found - tomcat9

I have an application running fine in Tomcat 7 and Tomcat 8. I want to run this application also in Tomcat 9.0.19.
Tomcat 9.0.19 starts correctly with the application deployed. However, when I ask for the start page of the application in the browser, I get a http 404 error for the resource asked for.
Is there additional configuration necessary to get my application running on tomcat 9?

The problem was caused by a difference in behavior between tomcat 8 and tomcat 9 concerning JAR scanning.
The keyword tomcat.util.scan.StandardJarScanFilter.jarsToSkip in catalina.properties contained jar's with resources in the META-INF/resources directory. In these jars the resources are not discovered any more by tomcat 9. The problem was solved by removing the jars containing a META-INF/resources directory from the list of jarsToSkip in catalina.properties.

Related

Servlet works in Eclipse, but not from my tomcat server

Im teaching myself servlets, found some very good tutorials and have great success in Eclipse Neon EE. (very basic servlet that just serves a simple static web page)
I installed Tomcat standalone before installing Eclipse Neon EE, and tested it and I get the regulat apache tomcat page. The tutorials I found also guided me on how to set up the tomcat server in Eclipse. They also showed me how to create a project and servlet. Even though I use 3.1, I still have Eclipse create the web.xml file.
When I run my servlet, Eclipse starts up Tomcat and does everything, and opens a browser tab within Eclipse and it takes me to http://127.0.01:9999/first/Hello and it serves up my web page. No problem. So now I export my project as WAR file, tell Eclipse to put the .war file right in my tomcat8's ROOT dir. Then i stop the tomcat8 server in eclipse and shut down eclipse. Then I use startup.bat and tomcat comes up, but then I cannot surf to http://127.0.01:9999/first/Hello from this same PC, it just gives 404 with "The origin server did not find a current representation for the target resource or is not willing to disclose that one exists."
Im not quite sure what steps I am missing?
You have to put your war file (first.war) into the "webapps" subdirectory, not into the root Folder of your tomcat server. Have a look at : How to deploy a war file in Tomcat 7
Copy the .war file (first.war) to %CATALINA_HOME%\webapps ( E.g.: C:\tomcat\webapps )
Run %CATALINA_HOME%\bin\startup.bat
Your .war file will be extracted automatically to a folder that has the same name (without extension) (E.g.: hello)
...

Deploy IVY resolved war file to eclipse tomcat?

I am trying to understand whether it is possible to have an eclipse tomcat runtime configuration that will publish the IVY resolved war files when tomcat is started?
I have created a tomcat server instance in eclipse and pointed it at a catalina configuration which includes a server.xml that specifies the contexts. For example.
<Context docBase="Module1" path="/Module1"/>
Module1 is a resolved war file and I have added the corresponding ivy.xml file to the eclipse tomcat classpath. I can see the war file has been resolved, but I assume I must have to do something extra to get the war files auto deployed on server startup?

How to deploy a web application on Jetty

I create a war file , then i executed in eclipse, like described here.
I don't know configure the context path, how can I run the war file?
There are two ways you can run your webapp using Jetty Server
Configure jetty server using Jetty_WTP_Plugin and run webapp within eclipse
Download stand alone jetty server from Jetty Distributions from Eclipse
If you use second option, you need to create war file keep war file interface /webapps folder.
I haven't used jetty but I know that its quite similar to tomcat. Just place your war file (say foo.war) in webapps directory; Start jetty by the following command in
java -jar start.jar
and hit http://localhost:8080/foo in your browser
By the way the tutorial you're using is quite an old one and may not work for jetty 8 or 9

Import and run WAR on eclipse

I have a subproject in a Virtual Machine with Ubuntu which I compile with Maven and then run with mvn jetty:run.
Maven also packages it as a war.
All of this works fine and does what is expected.
I am trying to import this WAR from another eclipse in Windows so I have done it by Import -> WAR, thus creating a Web application.
I now want to run it from Eclipse so I have created a new Jetty Server and run my application as Run on Server but I am getting Could not find the main class.
What is the proper way of doing this?
Besides, I have tried deploying the application by putting it in the webapps Tomcat directory . I can see it in the Tomcat GUI and launches the index.html but when I tried to access some of the services it throws No service was found
When deploying, in the Tomcat console I can see runtime NoClassDefFoundErrors.
Is there anything that mvn jetty:run does that the tomcat regular deployment does not? How is it possible that this didn't happen in my Virtual Machine? Shouldn't those classes be all in the WAR?
EDIT:
Here is another hint. When I run the project imported from the WAR in the Ubuntu VM, either with Jetty from eclipse or adding it to the webapps folder it works fine.
It is only hen running it on Windows Host Environment when it fails.
The specific NoClassdefFoundErrors thrown on cmd is the following:
Caused by: java.lang.NoClassDefFoundError: org/ow2/frascati/explorer/
api/FraSCAtiExplorer
That is one of the modules fo the main project.
If you try to deploy your war in tomcat's webapps folder, and if you miss a class, then you probably miss a jar in your lib folder. It is probably a jar that is supposed to be provided by the web server.
We need to know which class is missing.
Finally all errors have been solved by doing the following:
First I recompiled the WAR which did work this time under Jetty in Windows cmd. I apologize as this must be due to some error I still don't know, probably sharing the wrong WAR with Windows HOST OS from the beginning.
On the other hand, the Eclipse was solved by moving the Jetty folder out of the "Program Files" directory. It seems the old Jetty 6 adapter Eclipse comes with does not recognize spaces in its route to the server.

Undeployment fails for GWT application in tomcat 7

I am using the cargo-maven2-plugin:1.2.0 to do redeployments of my GWT 2.4.0 based web application to Apache Tomcat 7.0.25 1.6.0_30-b12 Sun Microsystems Inc. Windows Server 2008 R2 6.1 amd64).
The initial deployment works fine. I immediately try to undeploy the application using the tomcat manager when I receive the following error message:
org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: FAIL - Unable to delete [C:\apache-tomcat7\webapps\mywebapp]. The continued presence of this file may cause problems.
From tomcat the war file and most of the unzipped web application files have been successfully removed. But it fails to delete two libraries from mywebapp\WEB-INF\lib:
gwt-user-2.4.0
servlet-api-2.3
When I now wait half a minute and trigger the undeploy again, it works.
Did anybody experience the same or a similar behavior?
I already tried to debug using PSI Probe for Tomcat but that didn't really give me any insights. What could I try next?
Both files shouldn't be deployed in the first palce. First gwt-user-2.4.0 is the complete gwt jar file. For deployment only the server specific version needs to be deployed: gwt-servlet-2.4.0.jar. The servlet-api-2.3 is already available in the tomcat lib directory. So you should set both files to provided and if you not yet have the gwt-servlet jar file, add that file to you dependencies.