Skip to main content

Eclipse Glassfish plugin v1.0.52 EAR deployment problem

11 replies [Last post]
marioz
Offline
Joined: 2010-02-04

Hello all,

I'm having a problem (more a feature than a bug) with deploying EAR to glassfish app server with glassfish eclipse plugin.

My system:
- eclipse java ee 20090920-1017
- glassfish eclipse plugin v1.0.52
- glassfish v3 final

Problem description:
I have test.ear with following structure:
META-INF/
- MANIFEST.MF
lib/
- jpa.jar (contains META-INF/persistence.xml and entity classes inside 'db' package)
ejb1.jar
web1.war

ejb1.jar is using jpa.jar persistence.xml to get entity manager for persistence unit
specified in jpa.jar and use its entity classes.

Scenario1 (works as expected)
When deploying test.ear directly from glassfish admin console, application works as expected (ejb1.jar can access jpa.jar classes and can use persistence unit defined in jpa.jar) - deployed folders are all exploded; jpa.jar is not exploded (there is actually a jpa.jar in deployed lib/ folder).

Scenario 2 (does not work as expected)
When deploying from eclipse all folders are exploded including jpa.jar inside lib folder, like this: lib/jpa.jar/META-INF/...
In this case ejb1.jar does not see persistence.xml which is now located in lib/jpa.jar/META-INF/persistence.xml.

How can I get the glassfish plugin not to explode jar files found in EAR/lib ?
Am I doing something wrong ?

Best regards,

Mario

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ludo
Offline
Joined: 2003-06-10

Could you attach the eclipse workspace with these projects for analysis?

Thanks

fmora
Offline
Joined: 2010-07-19

Sure, here it is.

http://www.file-upload.net/download-2739353/workspaceJavaNet.zip.html

Btw, thanks for a nice tutorial, Andreas.

-- frank

szczyp

This bug seems to have been fixed recently. See the bug #308 (link above).

fmora
Offline
Joined: 2010-07-19

Hi,

sorry for opening this up again, but I'm wondering whether I'm still encountering the same problem:
Oracle GlassFish Server Tools 1.6.0.201006171607
Glassfish 3.0.1
Eclipse Helios Release Build id: 20100617-1415

I'm setting up a project following this tutorial:
http://programming.manessinger.com/tutorials/an-eclipse-glassfish-java-e...

Even for the smplest project without a connected DB, deployment of the project works with a freshly started eclipse, but fails upon redeployment since the lib folder of the ear is removed (stacktrace below).

The initial, working deployment creates the following directory structure (all the directories are exploded, even the ones with the .jar suffix):

eclipseApps/
- modultypesEAR/
+ lib/
* jee_utilities.jar/
* modultypesEJBClient.jar/
+ modultypesEJB_jar/

After changing something within Eclipse and redeploying, the lib dir is gone.

Does anybody have an idea, what I am doing wrong?

Thanks

-- frank

[#|2010-07-19T11:58:44.339+0200|WARNING|glassfish3.0.1|javax.enterprise.system.tools.deployment.org.glassfish.deployment.common|_ThreadID=24;_ThreadName=Thread-1;|Error in annotation processing: java.lang.NoClassDefFoundError: com/mhh/modultypes/service/ModuleTypeBeanRemoteInterface|#]

[#|2010-07-19T11:58:44.339+0200|SEVERE|glassfish3.0.1|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=24;_ThreadName=Thread-1;|Exception while deploying the app
java.lang.IllegalArgumentException: Invalid ejb jar [modultypesEJB.jar]: it contains zero ejb.
Note:
1. A valid ejb jar requires at least one session, entity (1.x/2.x style), or message-driven bean.
2. EJB3+ entity beans (@Entity) are POJOs and please package them as library jar.
3. If the jar file contains valid EJBs which are annotated with EJB component level annotations (@Stateless, @Stateful, @MessageDriven, @Singleton), please check server.log to see whether the annotations were processed properly.
at com.sun.enterprise.deployment.util.EjbBundleValidator.accept(EjbBundleValidator.java:72)
at com.sun.enterprise.deployment.util.ApplicationValidator.accept(ApplicationValidator.java:124)
....

advman
Offline
Joined: 2009-03-09

Hi,

I'm Andreas Manessinger, the author of the tutorial. The tutorial was originally written with the December 17, 2009 GlassFish Tools Bundle for Eclipse. It reproducibly works with that setup. I've also seen these things work with all kinds of home-grown combinations of the same constituents, namely Eclipse 3.5.x and GlassFish v3.0.0.

Shortly after Helios arrived, I have checked the combination of Helios (3.6 JEE, don't know the build number, just taken straight from Eclipse.org at around July 7.

It worked, although there was an ugly bug that made re-publishing after changes fail most or all of the time. You had to remove the application from the server and add it again. Automatically re-publishing brought something like

[i]cannot Deploy testEAR
Deployment Error for module: testEAR: Exception while deploying the app : java.lang.IllegalArgumentException: Invalid ejb jar [testEJB.jar]: it contains zero ejb. %%%EOL%%%Note: %%%EOL%%%1. A valid ejb jar requires at least one session, entity (1.x/2.x style), or message-driven bean. %%%EOL%%%2. EJB3+ entity beans (@Entity) are POJOs and please package them as library jar. %%%EOL%%%3. If the jar file contains valid EJBs which are annotated with EJB component level annotations (@Stateless, @Stateful, @MessageDriven, @Singleton), please check server.log to see whether the annotations were processed properly.%%%EOL%%%[/i]

Since then I have downloaded and tried the current Oracle Enterprise Pack for Eclipse 11g R1 (11.1.1.6). Well, they have made it default to not automatically publish after changes, but unfortunately this is not a solution, it only hides the problem. Using any kind of publishing (automatically, automatically delayed or manually) immediately un-publishes the application :)

Anyway. "Remove/Add" is currently the way to re-publish in Helios. Thus: it's not you who does something wrong. Re-publishing is broken, and the GlassFish plugin folks believe the bug is in Eclipse. Sounds as if it may take a while to get fixed :D

At the moment, if you don't need Helios, I would go back to 3.5 and the GlassFish Tools Bundle for Eclipse.

szczyp

Hi again.
I have just tried deployment in WAR again, but changed the location of the beans.xml file, and it worked. I put it in the WEB-INF directory, just next to web.xml. I thought I tried this before...

I apologize the GF team for this not-a-bug.

So it is possible to make the eclipse plugin work with JPA if the packaging and deployment is all in a single JAR. I guess (not tested!!) it would also work if EAR deployment was used, but JPA was packaged inside WAR or EJB-jar, and the problem only exists for a standalone JPA jar packaged in EAR/lib.

Regards,
szczyp

szczyp

I filed an issue against this: https://glassfishplugins.dev.java.net/issues/show_bug.cgi?id=308.

Regards,
szczyp

marioz
Offline
Joined: 2010-02-04

Your input was very helpful, thank you.

Best regards,

Mario

rsitze
Offline
Joined: 2004-04-07

This looks like it may be the same problem as discussed in http://forums.java.net/jive/thread.jspa?threadID=75680&tstart=0.

That thread identifies the core issue to JPA in an "exploded" jar file.

szczyp

Hi. I was about to ask the same thing - we are experiencing exactly the same situation.
I have JPA.jar and some other jars in the lib directory. What gets created in domains/domain1/eclipseApps is an exploded Ear.ear (my app), inside there are my Web and Ejb modules (exploded), and a lib directory. Inside this lib is an exploded Jpa.jar (as the author of this post says) and also another lib directory, which contains the rest of the jar files (it was in Gallileo, in Eclipse 3.6 M5 I have no idea how I can put additional library jars inside the lib dir, I simple see no option of doing that, but I guess this is a WTP problem or even something else).

To the author: if you package JPA inside the war (I put there evrything: JPA and EJBs) it works fine. Hovewer, I am also using CDI for injection and it fails. Now here's some fun ;d But this also happens when I deploy the War manually, so it is not the plugin. So, if you don't use CDI you can make the plugin work, if you do, you will have yet another problem (or I am doing things wrong).

Regards,
szczyp

szczyp

Hi.
Some more input on the error: when I use the EAR deployment, I did a test and tried to create EntityManagerFactory in a servlet using Persistence.createEntityManagerFactory(), and it worked, so the persistence.xml file could be found. It just didn't work for container managed persistence.
The error described earlier manifests itself not during deployment (at least for my) - a wrapper around EntityManager is created and injected, but when I try to call persist() on it, I get an exception with a message that the persistence unit for this name could not be found. I have only one JPA unit, and it didn't matter if I tried to use the name or not. I guess it happens lazily, when a first method is invoked and the JPA unit is actually created.
I am not bundling any provider with me, I am relying on EclipseLink provided with GlassFish 3.

Regards,
szczyp