I received some java code and a WAR file for a web application that I need to test.
My overall goal is to be able to test the web application functionality and potentially make modifications to the code if need be.
I seem to be stuck on correctly loading this into eclipse.
I grabbed the WAR file and did a Import where I attempted to import the WAR file into a (Web -> WAR) project. The first issue was Eclipse was complaining there not being enough memory or the heap size. So I changed the java memory options in the eclipse.ini file. This seemed to resolve the complaining about the memory.
I restarted eclipse and attempted to import the Web - War again now it goes through the process of pretending like it is importing the war file but nothing happens after it finishes.
So overall my questions are
1 What is the correct process to load the war and source code into eclipse
2. Why is Eclipse not loading the war file
If you want to test a WAR file, you must deploy it to a Servlet container. Common Servlet containers include: Tomcat, Jetty, JBoss (which actually uses Tomcat), WebSphere, and WebLogic.
JBoss, WebSphere, and WebLogic are JEE environments, but they each have a Servlet container.
WAR file generally contains compiled version of .Java file i.e. .class file and other web related stuff.
You unzip the .war file with WinZip or similar software, if it contains source code attached, then only you can view or modify the code.ELSE you can do the below steps to run the application.
Install a server e.g Apache Tomcat to your PC.
Start the server from CMD.
Open the server home page.
Deploy your WAR file. Now you will be able to see the Application running.
If you want to modify the code then you should have .Java files inside your war file.
Related
I need to create a local environment to deploy an EAR, which is currently in production.
By documentation, it needs:
Java EE 7
Oracle WebLogic 12.1.2
Maven
Installed everything fine and configured, but this is my first time with Java Enterprise and WebLogic. I downloaded WebLogic from the official website (the 12.1.3 version, which is the only one available for a development installation). Executed all scripts to create a local domain, realm and server. It starts fine.
So, I proceeded generating the EAR within the source code, using mvn ear:ear and created the package.
Connected to localhost:7001/console and logged in, went into the Deployments Control page and clicked in install button. Browsed the EAR and deployed without changing any default configuration. It leads me to an error:
java.io.FileNotFoundException: class path resource [env.properties] cannot be opened because it does not exist
I thought it was a file missing inside the EAR package, but I opened it with both Eclipse and WinRAR and the env.properties file is present, in the right path. So I tried deploying the EAR package that is currently in production, but it still gives this error.
At this point, I think it's some WebLogic configurations I missed. Am I right? Where should I eventually check?
I can NOT share any code snippet, I'm sorry.
We still have to understand if it's like this by choice, but the WAR file inside the EAR actually didn't have the properties file. It was sufficient opening it with WinRAR, put the file in the right path and re-deploy it.
So, just to say, WebLogic had no missing configurations. The downloadable development package seems to have everything configured.
I am really new to WebLogic deployments. I have the below situation:
I have a war file which is already deployed on WebLogic 8.1, I want to pick the same war and deploy it on the same server without bringing the original site down. This would definitely give me a exception saying the context path already exists. I have no way of recreating the war file, hence I will somehow have to modify the war file to change the context root. Is this possible?
And if it is possible could you also confirm that both using the same data-source(JNDI) would not cause any issues to the existing site.
Thanks,
Sahana
Yes you can deploy the same war file multiple times and yes you can change the context root. You will want to do something like the following if you cannot rebuild the war file yourself.
Unzip the war file (jar xvf myfile.war)
This isn't entirely necessary but it will help you understand the structure of the war file. Zip tools can modify a file in place. Try 7zip or use the Windows zip utility via right-click Open
Edit the weblogic.xml file with the new root <context-root>/new-root</context-root>
Rezip the war file (jar cvf mywar.war folder_it_is_in)
Here are other examples that may help as well:
How to deploy EAR application twice on WebLogic server?
How to deploy the same web application twice on WebLogic 11g?
How can I use Weblogic (12 C) without the application context in the URL?
I have NetBeans web application, with HTML, JavaScript, CSS files... and I have some Java files which I manage to call in the web application with DirectWebRemoting.
It is using NetBean's Tomcat.
After "Clean and Build", I get a WAR file in dist/
I put this WAR file into XAMPP/tomcat/webapps directory
Run the application with XAMPP Tomcat, but then the Java files would not work using XAMPP's Tomcat.
Question: How do I compile the build, so that when I put into XAMPP it would work? This is so that everytime I run the application I don't need to turn NetBeans on.
Use the Tomcat Manager application to upload the war file, dropping them directly in the /webapps directory doesn't work for me sometimes too.
Here's a link to know more about using Tomcat Manager Application
I have a webserver that I developed in Eclipse with a local TomCat server. When developing, I often had to run scripts from the command line from my Java code. I just looked at the working directory that Java inside eclipse was working from (was in the Eclipse subdirectory somewhere) and put a ton of files and scripts in here.
Now when creating a WAR those paths are wrong. I'm just not sure how to integrate this all into my project correctly. Should I copy everything into the Eclipse project directory and make the Java 'home' path here - how can I set this up so that the WAR would work when deployed on a webserver?
Should I copy everything into the Eclipse project directory and make the Java 'home' path here - how can I set this up so that the WAR would work when deployed on a webserver?
That is a bad idea:
Since you can't change the "current directory" in a Java program, the only way to do that would be to "cd" to the Eclipse project directory and start Tomcat from there. Yuck!!
And that's conceptually wrong:
Suppose you had two WAR files created in two distinct Eclipse projects. An application cannot have two different "current" directories. It makes no sense.
What if you want to deploy to a Tomcat on a system that doesn't have the Eclipse projector available to it ...
The correct way to solve this is to put all of the requisite files into the WAR file, and then access them from your webapp codebase using either webapp relative file paths ... or via the classpath.
Yes, it will entail changing the code of your webapp, but it is the right approach.
I have a Java Web project (Struts + Spring) working perfectly in my localhost. I have to deploy it on my website, but the Tomcat Manager interface given by the webhost says it cannot upload a WAR file due to safety reasons. When contacting the tech support I was told it is not possible to upload a WAR and that I should try deploying my project by uploading the files directly (I have FTP access).
My problem is that no one at the tech support gave specific instructions on where I should put my project files (I don't know if it should be on de same folder the WAR would be sent to) neither how to start/stop it (Will the Tomcat Manager recognize it once I upload the files?).
You can always try to upload a war file to webapps folder of tomcat.
if tomcat is running with autoDeploy set to true it will auto deploy your application.
i think that the same will happen if you upload the exploded war to the webapps, the context will be the name of the directory you put your files in.
Just place your apllication's root folder to the Tomcat's directory webapps and configure tomcat to auto deploy. Restart the server and your application will be deployed.
You transfer the files to the same place as the war file would go - but just as an expanded war.
Whether or not tomcat will recognise that the files have changed depends on the configuration of the tomcat server. I'd just give it a go - transfer the files and see what happens. If it doesn't pick up the changes then you'll need to find out from tech support how to restart tomcat.