I got a problem with generating a war file from a dynamic web project by the command line. Similar to this thread. But unfortunately I dont have maven or gradle...
If I create a war file from commandline from the main directory of my Webproject, I cant connect on any website by tomcat. If I go deeper into folder "webcontent", I am able to connect to the html welcome-page but I am not able to connect to the servlets, which are located in the src folder.
Thank you for your help!
Okay, I solved the problem with a different solution:
According to this thread, I created /WEB-INF/classes under /WebContent.
Then I was able to create the War-File really easy with
cd /to/your/Webcontent/directory
jar -cvf /destination/folder/of/war-file *
And deployed this war file in tomcat. Everything working now. Hope this will also help other people with similar problem.
Related
To my knowledge, to deploy my web application to tomcat, I need to move the war file under webapps in tomcat home. And in eclipse, in order to do that I right click on the server and select "Add and Remove", then add the projects to deploy them when ran.
Without eclipse, I have to make the war file myself by using jar -cf projectname.war * but I don't at which directory should I use this command. Also, should I compile all the sources in the src folder first?
To sum up my question, what is the step to run my web app on tomcat without using eclipse? I want to know what eclipse have done for me under the hood.
Thanks in advance!
I have a project which run in tomcat.
I have this error from tomcat.
java.lang.ClassNotFoundException: net.glxn.qrgen.javaase.QRCode.
I know that this error occur because I did not import my JAR file when I was building the WAR file but then I do not have the source code anymore which mean I cannot build a WAR file again.
Just wanna to know is there a way for me to put my JAR file into tomcat so the related function will call the JAR?
Thanks.
You should be able to copy the jar straight into $CATALINA_HOME/lib and it should work.
I created a normal Dynamic Web Project in Eclipse. I added a folder to the project, which shows up after refreshing the project. The folder is containing an XML-file with configurations for the applications.
When I deploy the application on the tomcat in eclipse, the relative pathes do not match anymore. I need to copy the folder in the catalina home directory and then it works.
Question
How can I add the folder to my project, that when I start tomcat (V7) in eclipse the folder is deployed as well and the relative pathes work too?
When the development comes to an end, I will export a WAR-File and deploy it on my server. It would be great, if then the configurations will be included as well.
If you have any questions or you need some further information, do not hesitate to ask nor to comment!
In the project's properties I have found where I can add the folder when I export the WAR-file. But it doesn't deploy in eclipse's tomcat yet. This part is still remaining.
I copied the configs-folder into the WebContent-folder and accorded the paths.
Now i have two configurations, one for my local execution and one for the execution on Tomcat after the deployment.
Important Advise
I needed to accord the filepaths starting from CATALINA's home directory.
I really apologize if this is a silly question.
I have a tomcat server running on a unix machine. I want to use the HTTPClient library. Does it come pre-bundled with tomcat or do you need to install it?
If people say to just add it to your class path. Should I download the source or the binary from here:
http://hc.apache.org/downloads.cgi
Once downloaded is there a way to auto install it using a .tar.gz as I think I have done this in the past. If not is it just a case of putting the folder on the drive and adding it to the classpath?
TIA
Each web application is supposed to package its own dependencies inside the deployable WAR file. It is an ill-advised practice to extend Tomcat's global library with any library an application might need.
On the WAR building front, the common practice you should stick to is not to manage dependencies on your own; it quickly turns into a nightmare. Configure your project with Maven , which will both manage the dependencies and build the WAR for you.
Just look for httpclient....jar file in the Tomcat directory. If there is none there, then put it inside the lib directory :)
You should download the appropriate jar file. It contains portable library code. Once placed in the classpath, Tomcat will find it. Tomcat directory has a lib subdirectory. This is global classpath part for all web applications.
I have made some changes to an existing Java web application. When I deploy this file to Apache, via WAR file, it regenerates the website as it appeared before my changes.
I delete the existing website directory before deployment, and I've moved out all existing WAR files. I have committed my changes to source control and recreated the WAR file, but still no effect. I even added a small text file to the solution and that was included in the WAR file and deployed to the server, but still my changes were not active.
I am using Spring as my IDE to create the WAR file, and Apache Tomcat to host the website.
Why aren't my changes being packed in the WAR file?
EDIT: I am very new to Java, but have plenty of experience in .NET. Please excuse stupid questions from me.
EDIT 2: As far as I can see, the changes are actually included in the WAR file and are deployed to the server (the class files contain certain strings that they never did before). But the code just isn't executing as it should with those changes (despite Tomcat and the machine itself being restarted).
Maybe try to add Maven to your project and then try to use mvn package to make a war file. Some time ago I had a similar problem. I tried to build a war file without Maven and changes on Tomcat weren't seen. Then Maven helped me out.
Edit:
Convert Existing Eclipse Project to Maven Project
http://www.mkyong.com/maven/how-to-convert-java-web-project-to-maven-project/
Maybe this could help you.