TOMCAT 7 not deploying war - tomcat7

I have developed a Dynamic Java Project with Eclipse which involves web services(RESTful). After completion I tried to run my project Tomcat 7 runtime of Eclipse IDE, it works fine. I am able to access all my web services.
But, when I created a WAR file out of my project by right-clicking on project and exporting it to WAR file and placed .war file in Tomcat 7's webapps folder. Started the tomcat by running startup.bat, it throws below exceptions and I am not able t access any web service:
I have placed all the required jar files in lib folder of Tomcat.
Exception fixing docBase for context [/Books] (Books is my war file name)
Failed to create work directory [{CATALINA_HOME}\work\Catalina\localhost\Books]
Failed to create destination directory to copy resources.
Could anyone please let me know what I am missing??
Thanks in advance.
Regards,
Piyush

The failed to create "work directory" error can occur if the work folder does not exist in the tomcat7 folder.
Also this error can be caused by tomcat not having sufficient permissions to read, write and execute in the tomcat7 directory.

The issue is because, tomcat is not finding your web.xml location in the classpath.
Do below steps:
Right click on web project-->Properties-->Deployment Assembly--> Add your classpath to web.xml(src/main/webapp) in my case.

Related

Running Spring application outside of an IDE (preferably OS shell)

https://www.pegaxchange.com/2018/01/24/java-web-project-with-spring-framework/ has instructions for creating a Java Web Project with Spring, without Maven. I am able to get it working in an Eclipse environment. It works as expected by doing “Run As” --> “Run on Server”.
When I kill Eclipse I get the Status 404 error (“The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.”). I have verified that the Tomcat Server is running from the XAMPP Control Panel.
How do I launch the application from an OS shell (Windows & Linux) so that I don't see the 404 error?
Its been a long time I haven't used java web projects without maven but if my memory serves me right, you should first export your project as .war file. Then deploy it to tomcat.
In eclipse right click your project select export and then select WAR file.
Copy your WAR file into webapps directory which is located in tomcat installation directory.
Rename the WAR file as you like if you want to serve you web app with a specific context name something like http://localhost:8080/myapp. If you do want to serve as root without a context name just rename it as "ROOT".
Run tomcat by command line <your-tomcat-installation-dir>\bin\startup.sh or it will be a .bat file for windows so you should end your command with .bat.
Or if you can start and stop by XAMPP panel this should do the same as well.
Also you can see this article for details on how to deploy a war file to tomcat.
I hope this helps. Cheers!

Deploy a embedded Jetty&Jersey war to jetty9,only can see static file?

I cteate a jetty&jersey embedded project with IDEA and Maven,I put it in Github https://github.com/Mengqi777/JettyProject. Run JettyServerStart.java start the server, in the browser address bar enter localhost:8080/dynamic, show OK, enter localhost:8080/static, show static resource file
Now I package it to a war file,and put it in jetty webapps directory. But only can see static file in brower with enter localhost:8080/static.404 Not Found Error when in brower with enter localhost:8080/dynamic
What happend?
What should I do to package this project into a war file or jar file and run it in jetty successfully?
You are doing things in your embedded-jetty usage in JettyServerStart.java that you do not declare/configure in your webapp or war file.
It's a maven project, but not declared as a webapp or war project (in the pom.xml)
Its doesn't have its WEB-INF in the right place (maven directory structure wise), which means your built war file is invalid.
The dependencies are not declared correctly for a webapp or war project (you cannot include jetty-server in a war file)
Your badly located WEB-INF/web.xml does not perform the same configuration steps as your JettyServerStart.java
You don't specify how you created your ${jetty.base} directory to support this war file?
You didn't specify what version of jetty-distribution or jetty-home you downloaded, or are attempting to work with.
The statement "and put it in jetty webapps directory" is unclear, which one? (using jetty-distribution/webapps is invalid and will cause many errors and warnings if you attempt to use it for your own webapps, there's no jetty-home/webapps, and you didn't identify your jetty-base configuration)
The way your project is declared right now, even if manually assembled, skipping maven entirely, you have no servlets, no filters, no listeners, no intializers, only a servlet spec mandated DefaultServlet on url-pattern / giving you static content. That's why accessing http://localhost:8080/static/ works, but nothing else.

java.io.FileNotFoundException: Source 'D:\JBoss\EAP-7.0.0\bin\content\eArsiv.war\WEB-INF\lib\lept4j-1.2.3.jar\win32-x86-64' does not exist

I was developing an application with Spring Boot and using tess4j for OCR process.
It was jar packaging and working well.
I just changed packaging to war and deployed to jBoss EAP7.Now i am getting "Source 'D:\JBoss\EAP-7.0.0\bin\content\eArsiv.war\WEB-INF\lib\lept4j-1.2.3.jar\win32-x86-64' does not exist" error and TessAPI cant be initialized.
Normally there is no folder as content under bin folder but anyway i have created subfolders under bin folder but still no chance.
How can i handle this case?
Many thanks in advance!
Cheers,
Murat

Tomcat context.xml from META-INF folder for context root configuration

I have an application which is being deployed in Tomcat 8. This application needs to be the context root.
To do this, I put a root.xml file in conf\Catalina\localhost folder and it worked.
Now, the problem is that when i debug through IntelliJ idea (Remote host) it is not being deployed as the root application.
Seems like the only way to fix this problem is to add context.xml file in META-INF folder and specify the configuration there.
Now, when I do this, context root configuration from context.xml file is not being picked up.
Any thoughts on this? Ultimately, I just need to debug the application through a remote server.

jboss-as-maven-plugin: which directory does command "jboss-as:deploy" deploy an .ear to?

I am running jboss 7.1, maven 3, and a java ee6 application that generates an .ear
I am doing a mvn clean package jboss:as-deployand Jboss-as-maven-plugin 1.5 does its thing--I can view my app using http://localhost:8080...
just fine, but I want to know where the actual .ear is being put.
It is not in my jboss7.../standalone/deployments folder. So where is it? My app is obviously running in jboss 7.1 just fine, but I can't find the .ear file. I know that there is an .ear in Eclipse's 'target' directory, but that wasn't produced by jboss-as-maven-plugin is it? I hope you can understand my confusion--don't all .ear files need to be in the deployments directory? I also do see my .ear file inside my hidden .m2/repository directory, but does this have any interaction with jboss-as-maven-plugin? Maybe there is some hidden sym-linking between my Eclipse project's 'target' directory and the jboss7.1 standalone/deployment directory?
p.s. I am used to using a hard-deploy option with the other plugin jboss-maven that requires you to say jboss:hard-deploy which just copies the .ear to your deployments folder. Then jboss would pick up the new .ear and redeploy automatically. I get the sense that jboss-as-maven-plugin is the preferred plugin so that's why I am bothering.
The jboss-as-maven-plugin uses the deployment API so it doesn't copy the file to the deployments directory for the scanner to pick it up. It deploys just as if you deployed it from the web console or via CLI. The files should be located somewhere in the $JBOSS_HOME/standalone/data/ directory.
You're welcome to open an issue, for a discussion around it at least. I'm not sure how I feel about adding a goal for it, but here isn't the place to discuss that :)

Resources