How to deploy optional package shared libraries in weblogic - java

I've got a dozen ear files, which load the same set of jars for each component deployed as an enterprise application in weblogic... I want to move these dependencies to a "shared library" (optional package) jar file. I've done the leg work of moving these artifacts to a jar file and added MANIFEST.MF with Extension-Name as specified in
http://docs.oracle.com/cd/E12840_01/wls/docs103/programming/libraries.html
Now I need to deploy this "shared library" optional package to weblogic 11g, before deploying the enterprise application components, which reference them. Currently deployment is done using a bunch of wlst jython scripts in offline mode, which does a full install of the domain on the filesystem. How do I deploy shared libraries in offline mode?

I couldn't figure out how to deploy shared libs in offline mode, only online, so I re-wrote the deployment scripts using wlst tool. I deploy datasources, jms, non-library-dependent apps in offline mode, then bring up the admin node and deploy libraries in online mode using standard deploy function in weblogic. You can google oracle docs on this, they describe the function and arguments that can be passed quite well. The once the libs are deployed, you deploy the apps (ears or whatever) in online mode, using hte same deploy mechanism from wlst minus the library argument, because applications are not libraries.
Some helpful resources:
https://docs.oracle.com/cd/E13222_01/wls/docs90/deployment/understanding.html#1052661
https://docs.oracle.com/cd/E13222_01/wls/docs90/deployment/deploy.html#1020594

Related

Migrating an EAR application from AppEngine to Google Cloud SDK

Since App Engine reached the end of life last August on the 30th, it's not possible anymore to deploy updates to the same application using the appengine (appcfg) command line.
I was using the appengine maven plugin which in turn was using appcfg to deploy my application.
I'm looking on how to migrate my application to Google Cloud SDK now but between the limitations I saw that Google Cloud SDK does not support EAR applications to be deployed.
Surprize surprize my applications does have an EAR structure.
Is there a workaround for this or should I completely change the structure of my application?
You don't have to change your application structure at all. It's only the deployment that it slightly altered.
Before, you used to create war artifacts and package them into a deployable ear.
Now you keep creating the same war artifacts but you must not package them into an ear. Instead, you deploy them all together using the gcloud command:
gcloud app deploy ./path_module1/WEB-INF/appengine-web.xml ./path_module2/WEB-INF/appengine-web.xml
path_moduleX are paths to the exploded artifacts (not path to your source code, of course)
as explained here https://cloud.google.com/appengine/docs/standard/java/configuration-files

Compile and Deploy the Selected Modules in java

In my application I have three java modules. I have to deploy it into the tomcat server dynamically by selecting module 1 and module 2 or module 3. The selected modules will gets packaged and form a war file and gets deployed in server without restarting. How can I achieve this? Is there any Apache products/tools or any available to do this?
The products/tools you should look at is the Tomcat Manager. The default installation of Tomcat comes with the Tomcat Manager. As the names says it can manage (deploy, undeploy, reload, start, stop) applications for Tomcat without reastart. I'm not realy sure what are your needs and how your precondition look like, but i see four ways how you may can do this:
If you already have a WAR, you can simply use the Tomcat-Manager via a Browser. Just call the manager URL (e.g. http://localhost:8080/manager/html). There you have options to upload a WAR and undeploy a application. (Before you can login, you have to edit tomcat-users.xml - just google a bit).
Use Apache Ant. Ant is a XML-based build tool for Java. With Ant you can compile your SourceCode and pack it into a WAR. If you tomcat runs local, you can copy the WAR via ant in the webapps directory of the Tomcat. Tomcat will auto-deploy it (if auto-deploy is active, as it is by default). And if you remove one WAR from webapps, tomcat will auto undeploy.
Tomcat provides a library with ant commands, to deploy the WAR via HTTP over Tomcat-Manager to the server (Tomcat Ant Commands). So if the tomcat is remote, use this command via ant.
You don't like Ant? Use the Tomcat Manager direct via HTTP. (HTTP Commands). Of course than you have to compile and build the WAR on your own.
I hope it is usefull for you.

Deploying Spring MVC project

I've developed a small MVC project using Spring MVC, Hibernate, MySQL, Maven and Tomcat. I can run and test the application (locally) smoothly.
Now I need to publish/deploy this project on an (online) server that have only Tomcat installed on it. How can I publish/deploy the project online? Is there any special build I should do? What files I shall upload and to where?
There are several types of development options available.
For development on localhost EAR (Exploded ARchive) type of project is usually used (because you can easily make hot deploy on servery). But for production WAR (Web ARchive) is used (basically it's the same EAR archive, but compressed using ZIP algorithm).
If you want to deploy your project to remote Tomcat server then make your project as WAR archive and upload it to Tomcat's webapps directory. Then you might need to restart Tomcat. But it's manual way of deploying.
Better option is to use automated build tools (like Maven) which can compile your project, run unit tests, deploy on web server (local or remote) etc.
This one is a great example of how to deploy your project on Tomcat server by using Maven's tomcat-maven-plugin: http://www.mkyong.com/maven/how-to-deploy-maven-based-war-file-to-tomcat/
Good luck ;)
Do a mvn clean install and you will get a .war file in your target directory of web module.
Copy it and paste it in tomcat_home/webapps directory and restart tomcat. Thats it. now, you can access it in whatever configured port (eg: http://localhost:8080/<your webapp war name>). lets say your war name is myapp.war, then tomcat would have extracted it into myapp folder in webapps.
so your url will be http://localhost:8080/myapp
With maven deploy command, usually gets errors for various reasons.
if you work in Unix/Linux system, I recommend using "rsync" method on console. (You can write own shell script to manage easily). It helps not only deploying without a problem but also helps to get time while redeploying (only uploading changed / new files). Because maven deploy / redeploy uploads your project as a bundle in jar/war. However "rysnc" method uploads your project files one by one.
Before using it, you should sure that two conditions.
1- your project is built in target folder (Spring Tool Suite)
2- you have access to tomcat via ssh
example code : (v_ : prefix which is variable(customizable))
rsync -avz v_your_project_in_target root#v_ip:v_tomcat_name/webapps/v_project_name
(Second sharing)

How to start/stop/redeploy maven web app using cargo start inside Eclipse

I have Maven2 war project built, I'm using the cargo start plugin, and it works great for deploying the web app. To run the maven command, I use a .bat file in my workspace, and I have en external run config to run the the bat file. I can't seem to stop the server from the Eclipse console, or re-deploy.
Does anyone have any advice on how quickly start/stop/re-deploy to Tomcat locally while developing.
Did you try JavaEE tools and m2eclipse? As far as I can see it should work well in most common situations. What m2eclipse does for you is to exactly map the maven configuration to an eclipse projects with the necessary facets set. Also, if the Dynamic Web Application facet is set for your project, you will be able to deploy it to a Tomcat server that you set up in the Server view of JavaEE tools. This configuration allows hot redeploy.
More information on JavaEE tools:
http://eclipse.org/home/categories/index.php?category=enterprise
There is a full Eclipse distribution with the EE tools available on their download site:
http://www.eclipse.org/downloads/
m2eclipse is freely available from Sonatype:
http://m2eclipse.sonatype.org/
At work we use the mentioned software as well. Additionally we use the JBoss tools that provide a feature called Project Archives that let you individually build your web application archive (ear/war/...).
To get startet you should perhaps start a fresh workspace and import the existing maven project (via the import existing maven project wizard). If everything went fine you can set up your tomcat in the server view. Maybe switch to the Java EE perspective. Right click on the newly added server and select Add to add the dynamic web project you just imported. If it doesn't show up in the list try to update the project configuration via the project's maven context menu.
Well, you could use cargo:redeploy to Undeploy and deploy again a deployable (that's a shortcut to cargo:deployer-redeploy). But I personally don't use Cargo this way, I use it mostly for integration testing (i.e. during the build) and use Eclipse WTP during development (this works whether you're using the maven eclipse plugin or m2eclipse).

Application server-agnostic build script

I have a J2EE application that needs to be distributed to customers, who will have application servers of their own choice. What is the recommended way of writing a build script that would compile the J2EE application sources (at customer sites) so that they will eventually be able to deploy the application on their servers ?
Moreover, what JARs should one actually use during the compilation process ? Since this is meant to an application server agnostic script, is it recommended to use the JARs (say servlet.jar, jms.jar, ejb.jar etc.) from the application server, rather than having my customers download these JARs from a particular repository ? Is there any such repository that is recommended for such JARs (JARs of J2EE APIs) ?
PS: The EAR file cannot be built locally and shipped to customers, since additional development will be done at each installation to integrate with other systems, perform customizations on the application etc.
Build the application locally, and distribute the WAR/EAR files to the customer.
Edit:
The situation you describe is basically that you need to provide a code base for further development by the customer. In that case I would suggest that you look into creating maven modules of your work which are pushed to a private repository accessible by the customer. You then let them know that they need to depend on module X version Y in their pom.xml, and module X then pulls in all the libraries needed in the correct versions.
Note that if they don't use Maven, they might use Ant Ivy for the dependency resolving.
Some generic J2EE API jars can be found at Sun's site, however you might have to dig a lot to find them.
I would just use any JAR you have handy, bundle it with the source, but away from /WEB-INF/lib
Basically, don't include the container jars (servlet.jar, jms.jar, ejb.jar etc.) in your EAR or WAR file.
If you are just talking about servlet.jar, the web container provides that - you shouldn't include it in your war file.
If you are creating an EAR file, they you must be using an enterprise container and it will have a JMS.jar and EJB.jar.
JMS on Tomcat would be a little trickier - you'd need people to install something like activemq on their servers.

Categories