I use JBoss 7.0 and WebSphere 8.5 application servers to deploy my .ear file which has .wars and EJB .jars.
How to get my .ear file path using Java eg. jboss7.0/standalone/deployments/sample.ear? If needed, I can use a separate Java servlet class.
If you are in a war file you can call ServetContext.getRealPath("/") which will give you the file system path to the war file. The war should be in the ear. This of course assumes that these are expanded as directories and not .war/.ear files (getRealPath only returns a non-null path in the former case).
Related
I am deploying a war with embedded jetty using SpringBoot. I start it using java -jar .war. The web app run fine, but the war file is not unpacked to any directory. I have tried setting -Djava.io.tmpdir, and even tried customizing JettyEmbeddedServletContainerFactory and setting the tempDir after extracting the WebAppContext out of the Server. My customizer runs and correctly sets the tempDir, but the war is not unpacked at all.
What do I have to do make it unpack the war file ?
I have a Spring Boot app that I tried deploying to a .war to run it from a Tomcat server.
Before this I was deploying to a executable .jar and everything worked perfectly.
In the app I need to read a .json file and also read a directory, their locations are given as relative. When deploying to .jar I would have the file in the same folder as the .jar. I would access it as: ./branchMap.json. The directory would also be in the same folder as the jar and I would access it as: ./patches.
Now when I am deploying to .war I place the app in webapps in Tomcat and I place the json file and the folder also in webapps. When I run the app it is able to read the json file, but it is not able to read the /patches folder.
Why is this happening? I have seen that Tomcat tries to load the /patches folder as a app, in is listed in the tomcat manager. How does this interfere with the app trying to read access that folder? Is there something different in the way that a app deployed to war accesses relative paths?
Read the paches folder location from properties file and in the property file you can mention the full path of the patches folder.
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?
Actually I use MyEclise to develop and deploy a enterprise project(EAR file).
I use Java Build Path to add some other projects and link sources, and added several jar files (as external jar and user library) to my project. (I used J2EE technology and there are some default jar of course )
By myeclise deploying manager I deployed my project on weblogic base_domain and then by weblogic console I deploy it on weblogic.
All is set and there is no problem in all steps.
Now I wanna to create EAR file manually, first I created WAR file which included some jsf files and web-inf directory contains classes, lib directories and some important file like web.xml , facec-config.xml and etc.
In classes folder I have .class files which build correctly from .java files, and on lib directory**I copied all jar file from web-inf/lib directory** which created automatically by myeclipse deploying manager on weblogic base domain folder.
I added this War file into EAR file along APP-INF directory which contains all jar files from APP-INF/lib directory on weblogic base domain folder and META-INF directorywhat contains application.xml file.
When I deploy this ear file on weblogic there is so many error and problems.
Could you tell me what is the correct way to create that EAR file.
Thanks in advance
If you have an enterprise project, just export the EAR file. Right click the enterprise project, select Export, then select MyEclipse JEE->Ear File and follow instructions on the wizard (basically, specify a destination for the EAR file, on the file system). This should give you an EAR file that contains the same as what was deployed on Weblogic.
I have a web application (WAR) that I want to deploy in Tomcat 5. I'm using Maven 3 and the problem is that when I deploy the WAR, Tomcat automatically copies the context.xml file located in META-INF directory. The file is then renamed with the WAR name and the context path of the application will be the WAR name. By default, it is artifactId-version.war.
The problem is that some client code uses the context path to connect to the web application and I don't want to change the code each time a new version of the web application is deployed. Is there a way to set the context path to another fixed value?
I can't use the tomcat plugin for now. Setting the Context path in the context.xml doesn't help. Also, tomcat documentation precises that it's not recommended to set the Context path in the server.xml. Also, I don't want to change the WAR name, it's important for me to always keep track of the artifact version.
Thanks
You should use the ${project.build.finalName} parameter in your war plugin config so that you can ensure that the war never changes names.