How to create war file if project doesn't have entry point? - java

There is a project in github:
https://github.com/chexagon/redis-session-manager
I downloaded and created jar file via maven. But I must use war file for deploying it to Tomcat and use it in our own application. Because of this project doesn't have web.xml file or any entry point (at least I couldn't find it) I couldn't create war file properly. Can anyone help me to solve this issue.
Thanks in advance

The software you downloaded is not a web application. It is a component that can be used as part of a web application.
Correction - Actually it is an add-on component / plugin for Tomcat itself ... that allows the session state of web applications to be persisted in Redis.
Turning it into a WAR file won't help.
Even putting it into your application's WAR file won't help.
The JAR file needs to be copied to the tomcat/lib directory. Then you add a a <Manager> element to the conf/server.xml file. The README.md file describes the attributes of <Manager>.

Related

How to find .properties file in maven based java web application?

Recently I have developed Java based web application and used maven for making a build.
As per standard convention, I have added all the .properties file in folder "src/main/resources". After deployment of .war in tomcat, I wanted to edit properties file without making new build. Is it possible to edit the properties ? If Yes, In which folder I can find the properties file ? (I could not find the properties file in the server /tomcat folders)
If this is a web application, inside the war,you should be able to find the contents of src/main/resources in below location:
war -> WEB-INF -> classes folder.
You can edit the properties file there, restart and it should work.
Just got to the folder where your war is located somewhere in your system.
Target > War > Web-Inf > Classes.
Make changes and redeploy.

Update xml file in JAR with weblogic deployment plan

I have a java application(not a EJB, not a MDB, it has a class implements ApplicationLifecycleListener). I build this java application into a jar file then create an EAR file include this jar, deploy the EAR file on a weblogic server, it works perfectly fine.
Now I want to use weblogic deployment plan to update some of the values in a configuration file which located inside the jar file. I generated the deployment plan, but it does not recognize my configuration XML file. I tried manually add it to the deployment plan, and use the deployment plan to redeploy this application. But nothing is updated.
I have read some examples of updating ejbs, but did not find anything about update a JAR's configuration inside an EAR, can anyone please give me example or send leave a link on how to properly use weblogic deployment plan to update a configuration file inside a JAR which is packed within an EAR file. Thanks.
You probably have to place the XML file in a jar file with same name under the same path as the original and use this jar in AppFileOverrides.

Change context-root inside WAR file

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?

create ear file from myeclipse workspace

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.

Glassfish 3.1.2 lib/jar referral from ejb.jar issue

I have been working on migrating our code base onto Glassfish 3.1.2 using Java 7. I have been struck with this issue, where the deployment of EAR fails. I have an EAR, having modules, ejb.jar, couple of war files, along with lib directory having jar files to be shared across other modules within the EAR.
The issue is that ejb.jar refers to some spring bean definitions in lib/abc.jar file and is unable to find the spring file. The structure is like this:
EAR
ejb.jar (some spring files in here refer to lib spring file like, xyz.xml importing spring/abc.context.xml)
couple of war projects.
lib/lot of jar files (one of the jar here contains the spring file being referred from ejb.jar, note the file is inside directory inside the jar, like spring/abc-context.xml)
But the ejb jar cant load the bean definitions from lib/.jar
I have tried using the Manifest.MF inside the ejb.jar to refer to lib/abc.jar, but with no luck....
Not sure if there is some sort of problem with new GF 3.1.2, why its not able to respect the Manifest file. Any help will be much appreciated!
It looks like the JVM doesnt like the manually edited Manifest file and my guess is that windows is adding something like a carriage return etc. I managed to get it working by using the ant to generate the manifest file instead.
Thanks and hope that helps someone.

Categories

Resources