- This topic has 12 replies, 2 voices, and was last updated 18 years, 10 months ago by
Riyad Kalla.
-
AuthorPosts
-
nbhatiaMemberI have and ear project that has a dependency on a simple project with POJO classes. Under the EAR tab in of the project properties, I have selected the option to “Jar dependent Java projects”. However, MyEclipse does not seem to be jarring the dependent project and adding it to the ear. In the exploded archive, there is no folder for the dependent project, in the packaged archive, there is a jar for the dependeent project but it is empty. What could I be doing wrong?
September 18, 2006 at 9:26 am #258660
Riyad KallaMemberPlease explain the full dependency list to me, for example, EAR->WAR->Java or something like that, usually there is a setting somewhere in the middle that is causing the deployment to fail. This setup is actually supported, but the settings for it are squrirely.
September 18, 2006 at 10:06 am #258674
nbhatiaMemberI have the EAR project directly dependent on the Java project (EAR -> Java). To give you specifics, I have 4 projects:
measure-app: EAR
measure-common: Java
measure-core: EJB
measure-web: WARHere’s how I set the dependencies:
1) In the properties for measure-app, I go to “Project References” and check the boxes for measure-common, measure-core and measure-web.
2) Then I go to the MyEclipse > EAR tab and click the radio button “Jar dependent Java projects”
With these two steps I expect measure-common.jar, measure-core.jar and measure-web.war to be packaged at the ear level. However only the last two are being packaged in the ear, the first is not. Let me know if I am missing a step somewhere.
Thanks.
NareshSeptember 18, 2006 at 10:42 am #258694
Riyad KallaMemberNaresh,
I just created a setup I believe is similar to yours, can you download it from here and import it then try and deploy it and see if it’s correct? Also are you checking the contents of the EAR file, or just getting ClassNotFoundExceptions and assuming it’s not working? I ask because when I check here locally, I’m seeing the JAR for the Java project being deployed with all lowercase letters for the JAR name, which might be causing it to fail loading. (I’m filing that as a bug)September 18, 2006 at 2:26 pm #258712
nbhatiaMemberI tried out your project and it deployes correctly (except for the lower case jar name as you indicated). I did not realize that the Java project will show up as a jar in the exploded archive and not a folder. So I went back to my project and looked at the exploded archive. Indeed there is a jar file created over there, but it has only one class where as my java project has 6 classes. I don’t have any clue why that is happening. I even copied my src folder for that project to your project and deployed it. In your project all 6 classes exist in the jar, but in mine only 1. What could I check next? One thing I am suspeciaous about is the module-ids in .mymetadata file in the ear project (e.g. id=”myeclipse.1158435055390″). I had initially created this project in a different workspace and then copied it over to the current worspace. Does this somehow mess up the build? I hope not.
September 19, 2006 at 5:04 pm #258767
nbhatiaMemberRiyad,
I am now able to duplicate your setup in my project – the generated jar for the Java project has all the classes. However there is one glitch. In your projects, there were no compile time dependencies between them – all the classes were independent. In my case, the EJB project needs the Java project to compile. Also the WAR project needs both – the EJB project and the Java project to compile. If you add these compile time dependencies in your projects, then the EJB and war projects will stop compiling and so there is no way the EAR can be generated. I know how to manually genrate jars for the Java and EJB projects and put them on the classpath of dependent projects (File -> Export), but don’t know of any automated way of doing this. In other words, whenever I change code in Java and EJB projects, not only should they be compiled but also jarred immediately. Do you have any advice on this?
BTW, the other alternative I thought of is to include source level dependencies between the projects. While this solves the compile issue, it adds the classes from the Java project into the jar of the EJB project and inside the war of the web project. Obviously I don’t want this, because those classes should only exist in the jar of the Java project. So this solution was a no-go.
Thanks.
NareshSeptember 20, 2006 at 1:13 am #258820
Riyad KallaMemberNaresh,
Here is the setup you should have:+ EAR + EJB Project + Java Project (Exported by EJB Project, marked as dependency of EAR Project) + Web Project
MyEclipse actually honors the classloader hierarchy of a deployed EAR in that the EJB (and java) project will be exposed to the Web project’s classpath, for example, setup what I show above and go into your web project and create a new class with a property of your EJB, you’ll notice that it will import that EJB without you adding all the references on the build path.
September 20, 2006 at 12:09 pm #258866
nbhatiaMemberRiyad,
Thanks for the response. I tried to set up the projects the way you suggested, but ran into a slight problem. The Java project defines the data transter objects that are shared by the EJB project and the WAR project. Hence the WAR project does not compile if it is not made dependent on the Java project. So this is what I had to do to make everything compile:
+ EAR + EJB Project + Java Project (Exported by EJB Project, marked as dependency of EAR Project) + Web Project + Java Project
This, of course, has the side effect of including the actual classes from the Java project in WEB-INF/classes, instead of relying on the exported Java project Jar.
The other issue that I am running into is this. When I deploy the project, the EJB verification fails:
12:54:28,705 WARN [EJBDeployer] Verify failed; continuing java.lang.NoClassDefFoundError: org/springframework/ejb/support/AbstractStatelessSessionBean at java.lang.ClassLoader.defineClass1(Native Method)
spring-1.2.7.jar has been included as a dependency of the EJB jar and has been exported. So it exists at the ear level – I can see that. Also, I have included it in the classpath in the manifest.mf of the EJB project. In spite of all the the EJB verification fails. What should I do next.
(BTW, this whole project works when I build and package it the way I want it with Maven – I am trying to set up MyEclipse to package everything the same way).
September 20, 2006 at 1:06 pm #258875
Riyad KallaMemberThis, of course, has the side effect of including the actual classes from the Java project in WEB-INF/classes, instead of relying on the exported Java project Jar.
If you go to your web project properties, go to MyEclipse > Web > Deployment, you can adjust how it handles dependent Java classes, just tell it to do nothing with them. (default is to package them up)
spring-1.2.7.jar has been included as a dependency of the EJB jar and has been exported. So it exists at the ear level – I can see that. Also, I have included it in the classpath in the manifest.mf of the EJB project. In spite of all the the EJB verification fails. What should I do next.
What is different when you package it with maven? Is it generating different Manifests for you?
September 20, 2006 at 4:56 pm #258901
nbhatiaMemberOk, I was able to solve both these problems:
1) Changed MyEclipse > Web > Deployment to do nothing with dependent java project – so none of that stuff gets into the Jar.
2) Manifest was not the problem here (I was actually copying the maven generated manifest, so this could not be different). Turns out that this problem occurs only in the exploded ear. As soon as I package the ear the problem goes away.
Ok, so ready for the next cople of problems?
1) My EAR project has two sub-directories called target and src – these are maven related. For some reason these are getting packaged into the ear. Is there anyway to prevent this? For right now I am manually removing them from the ear.
2) When I deploy the application and send it an http request, I get the following error:
java.lang.NoClassDefFoundError: com/sapient/measure/ServiceLocator at com.sapient.measure.web.bean.TreeTableBean.getTreeService(TreeTableBean.java:35)
In other words the Web app is trying to access the ServiceLocator class. This class happens to be in the EJB project jar, which should be accessible to the Web application, but for some reason it is not.
Let me know if you have any ideas on these.
Thanks.
NareshSeptember 20, 2006 at 6:47 pm #258908
Riyad KallaMember2) Manifest was not the problem here (I was actually copying the maven generated manifest, so this could not be different). Turns out that this problem occurs only in the exploded ear. As soon as I package the ear the problem goes away.
Ahh, some app servers don’t like exploded deployments, that could be the issue.
1) My EAR project has two sub-directories called target and src – these are maven related. For some reason these are getting packaged into the ear. Is there anyway to prevent this? For right now I am manually removing them from the ear.
Not yet, filtering deployments is high on our priority list, along with filtering validation.
In other words the Web app is trying to access the ServiceLocator class. This class happens to be in the EJB project jar, which should be accessible to the Web application, but for some reason it is not.
What does the manifest look like in the web project?
Also if you open the EJB JAR, do you see the class in there that the app server is complaining about missing?
Additionally, what app server are you deploying this to?
Lastly if none of this helps, can you exrpot the EAR and all the other projects to an archive and share it with us for testing purposes? If not, can you create a small sample setup similar to yours that exhibits the same problem? You have our deployment guy’s interest piqued, he wants to know if it’s breaking and why.
September 20, 2006 at 8:04 pm #258910
nbhatiaMember1) I solved the filter issue with deployment by separating out the Maven and MyEclipse projects for the ear. Now the extra maven directories are not being packaged in the ear.
2) The web project did not have any manifest. So I put the following manifest in, but that did not help.
Manifest-Version: 1.0 Class-Path:
I also tried adding the classpath of the EJB project – that did not help either.
3) When I open the EJB jar, I do see the class that the Web application is looking for, namely ServiceLocator.class.
4) I am deploying this to JBoss 4.0.4.
5) I can try to reduce the application down to a small one and send it to you. How should I send it?
Thanks for all your help with this. I think we are very close now!
Naresh
September 20, 2006 at 8:59 pm #258912
Riyad KallaMemberI can feel success just around the corner, Naresh if you can pair the project down to a small subset, just use FIle > Export to export all associated projects to a zip, then email them to support@genuitec.com ATTN Riyad with a link to this thread so I know why I’m getting the files and I’ll have a look at it.
-
AuthorPosts