I am working on weblogic 12c and i deploy .ear file which inside contains .jars and project stuff.
After ANT Build all java classes goes as jar inside 'project/bin' folder. This bin folder will be part of .ear file.
I then deploy .ear on weblogic. But apart from doing this, it is also
forcing me to copy 'project/bin' folder stuff into 'Weblogic/domain/lib' folder and restart the weblogic server. If i dont do this, i am getting ClassNotFoundException for all java classes.
Why should i copy 'project/bin' folder into 'Weblogic/domain/lib' ?
Is this a ideal way of doing deployment ?
If not, How to avoid doing this every time ?
Please help.
Related
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 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 am trying to configure JRebel
Dev environment description:
Eclipse Juno IDE
JBoss 6.0.1 - Running externally from eclipse (same machine, not remotely)
Debugging: Remote, all hotswapping functionalities off
Ant script that: compiles, deploys and lifts target WAR to the JBoss
I have not used JRebel before, the configuration guide seemed pretty easy, but i am having troubles with my particular case.
All source (incl. jsps and images) is being compiled in project's bin folder.
Ant script creates WAR which holds separately JSPs, style, property files and compiled application classes are put inside dedicated jar in /web-inf/lib/ together with libraries. The script lifts the generated WAR to the JBoss and runs the server.
Where should i put my rebel.xml (i suppose in my project's bin folder?!) and what should i write into it in order to get jrebel-hotswapped the code changes inside the jar inside the war that is deployed in JBoss server.
I provided JBoss run script with necessary jrebel VM arguments.
Many thanks in advance!
rebel.xml should end up in WEB-INF/classes of your application. If you have dependencies in WEB-INF/lib folder, then every archive should have its own dedicated rebel.xml configuration file.
See the doc
If you deploy using Eclipse WTP, then it is fine to put it into source folder. But if you are using Ant to build the WAR, then you have to make sure that your Ant script will detect rebel.xml and copy it to the correct location.
The paths in the rebel.xml should point to the folder where the compiled classes are, i.e. the location where your IDE compiles these classes to.
So I was given a WAR 'file', but upon downloading it I noticed that it is actually a folder, not a WAR file. Trying to open this folder in Netbeans is not working, because it is expecting a war file, not a folder.
I attempted "War-ing" the folder, which worked. Netbeans can now open the file, however none of the files can be edited.
This was tested using apache's ode.war in NetBeans 8.0:
Unzip the war file
In the unzipped folder, you will see WEB-INF/, META-INF/, etc., create a sub-folder named web in the unzipped folder.
Put everything else into web (now they will be web/WEB-INF/, web/js/, ...)
Go to netbeans, new project -> java web -> web application with existing sources
Pretty much just press next all the way through. voilĂ , it's done.
If you don't have eclipse handy, just place the war file into the webapps folder of Tomcat, go to the bin folder of Tomcat and run startup. Tomcat will automatically extract the war file for you. Now go to the webapps folder and you'll find another folder there, with the same name as your war.
I couldn't find an option to import a war directly into Netbeans (strange. Perhaps someone could create this feature and submit it as a patch to Netbeans). The folder which gets extracted into the Tomcat folder can be used as the Netbeans project. It's advisable to copy it to some other folder first. Import by File > New Project > Web application with existing sources.
Eclipse has an option to export a war and include the sources with it too, so there's a chance that the source files are in the war too.
How does WebLogic 11g load libraries in an EAR file? I have this problem with a web application, that when deployed as a WAR (with libraries it depends on in WEB-INF/lib), it works just fine. However, when it's inside an EAR file, WebLogic does not find those libraries unless I put them in APP-INF/lib. Does that mean that if I'm deploying as an EAR I'd have to pull out all JAR files from the WEB-INF/lib directory and place them in APP-INF/lib ? or is there a configuration that can be done in WebLogic to avoid this?
Thanks!
If you have JAR files that you need to share between multiple WAR files or between WAR files and EAR files then you will need to package them in the EAR.
If WAR#1 has a JAR in its WEB-INF/lib and is packaged in an EAR with WAR#2, then WAR#2 will not be able to see the JAR files in WAR#1/WEB-INF/lib.
Solving your problem will take some understanding of how Java EE classloading works in a container. You should look at this link to get an understanding, but the basic problem is that when you package your application as an EAR, you've introduced another classloader (the application classloader) into the class loading hierarchy. You can configure WebLogic to load from your webapp by using the prefer-web-inf-classes element.