How to Deploy Simple Java Projects into EAR?
I am using MyEclipse and I use an Enterprise Application Project (EAP) that automattically deploys my W开发者_如何学Ceb and EJB Projects.
These projects use some other projects that are just POJOs, "simple" java projects. Like a library kind of thing.
The problem is that when I change something in on of the "simple" java projects I have to redeploy my entire EAP in my JBoss in order to see the changes.
What I want is a way to automatically deploy those projects (POJOs) in the EAP, so hot code replacement works with those too.
Any ideas?
With JBoss, you can just drop your JARs in the server/default/deploy
directory - this was at least true with older versions - thanks to JBoss special classloader (hate it or love it).
With WebLogic, you could use "Shared Libraries".
In both cases, the mentioned features are proprietary, i.e. non standard and using them will make your application not portable.
Sorry, I meant automatically. Like this: 1) Running server 2) Modify something on the Java Project (library) 3) Oh-oh, i have to manually redeploy the library (make a jar, copy, and restart server). I want it to make changes automatically, like a hot deploy kind of thing.
Ahhhh, ok, got it now. In that case, "Exploded Archive Deployment" is the way to go and is supported by MyEclipse (and JBoss). Quoting 7.1 J2EE Project Deployment Modes:
MyEclipse can deploy Web, EJB, and Enterprise Application projects to any MyEclipse enabled application server. Two deployment packaging modes are supported by MyEclipse: exploded archive deployment and packaged archive deployment.
- Exploded Archive Deployment - This is a development-centric but non-standard J2EE application packaging and deployment model. Similar to packaged deployment, an application's deployable resources are organized to conform to a J2EE standard directory/file structure. But, rather than create and deploy a single archived file, the entire application resource structure - directories and files - is copied by the application server connector to the server's special deployment location for exploded archives. The MyEclipse Deployment Service, using "Sync-on-Demand" technology, will keep all MyEclipse project deployments synchronized with all source changes in their corresponding MyEclipse project. Note: exploded deployment is not supported by the J2EE standard and is not supported by all application servers.
Can you deploy an exploded EAR and then just copy over the few files you change? That's how I do all my development. If you change a simple JSP or Java class you can just copy those individual files and the server will pick them up.
If you are adding your simple projects as libraries, have you considered using OSGI to dynamically swap the bundles in runtime. You don't need to redeploy all of your applications and you can just change the jars. jBoss has an OSGI implementation called jbossosgi, which is currently in beta tough.
Try to separate POJO and J2EE elements in 2 separate EARs or WAR and EAR and deploy them separately. I have the same problem with Weblogic project and always deployed EJB and all the staff if I changed something malicious. This Idea came to me not long ago. Have no time to try and those project finished. But you can use my idea.
There is a commercial tool for this called JRebel: http://www.zeroturnaround.com/jrebel though I'm not sure if it will work in your specific case. There is a 30 day trial for testing purposes.
As I use MyEclipse I found a way to do it by adding a reference in the EAP to the java modules. When you deploy the project the java modules are deployed in the AS.
The only bad thing is that now I need to manage the application.xml manually.
It's all explained in this link.
There may be ways of doing it that are server specific, to provide shared libraries for Java EE applications, but I don't think the Java EE spec contains any such facility. One way is to add it to the servers classpath, but you should typically avoid this and bundle your application as a standalone unit...i.e. the EAR. Which it seems you are already doing.
It seems like an odd request since you are already doing it the right way, so don't change it.
精彩评论