Myeclipse deployment issue for web module dependent java jars - java

I am using WAS 8, in the deployment folder, I just need to get the dependent java jar projects under the x.war-> web-inf-> lib, .
This can be done easily in RAD using j2ee module dependencies-> web library tab. How to do this in Myeclipse?
I disabled the deployment assembly mapping and tried many options in Myeclipse but seems like all have same result..
Eclipse indigo some how deploys the dependent java jar projects under the x.war-> web-inf-> lib.
Please help.

Dependent projects are deployed in the manner specified in the project properties (or the workspace preferences). Select the project, right click then go to Properties->MyEclipse->Web and select the Deployment tab. You can specify here how dependent projects are deployed and how exported jars from dependent projects are deployed, among other things.

Related

Eclipse maven-enabled web app references workspace projects, but those are not deployed when running Tomcat server

I have a web application (Eclipse's Dynamic Web App) which uses Maven (m2e-wtp) for the build and dependencies management. This web app's POM references a few other projects in my workspace, which happen to be eclipse plugins built with maven as well (built using Tycho), and also other third party libraries which come from Maven's repository.
Everything works fine when I run maven from the CLI. All dependencies are included in the WEB-INF/lib directory just as expected.
The problem is when I attempt to run the project using Eclipse. I run the app in a configured Tomcat server inside Eclipse, but the referenced projects in my workspace are not added to the deployed war.
I tried adding them to the Deployment Assembly (under project preferences), and that works perfectly, but those settings get wiped out by m2e every time the maven configurations are updated. I read in a few places that we should not manually add entries there since all dependencies should be managed by m2e...
The question is: How to make Eclipse add the workspace project dependencies to the WEB-INF/lib of my web app when I run it from Eclipse?
I'm using Eclipse J2EE 4.3.1 (Kepler SR1).
I also tried right-clicking the project and selecting Export -> WAR file, but the exported WAR file doesn't include the referenced workspace projects either. I'm assuming the issue is affecting both cases.
This is extremely annoying ans is slowing me down quite a bit.. at this time I have to re-add the projects to the Deployment Assembly page several times a day to keep it going...
UPDATE: The workspace projects I added as dependencies in the POM appear in the list of Referenced Projects, under the project's properties. But when I expand the Maven Dependencies in the Project Explorer, the workspace project dependencies are missing from the list! Only the ones in the Maven repository show up. They local ones seem to be silently ignored...
I had similar problem because I created the project outside eclipse, and them imported it. What worked for me was to add the right project facet: Project context menu -> properties -> Project Facets -> Dynamic Web Module (choose right version). I was using Eclipse ADT (version 4.2.0), but, to avoid having multiple installations, I use the same eclipse for Android and other kind of apps.

Netbeans does not package class library jar to ear file when deploying Enterprise Application

I build a java enteprise application in netbeans 7.1 which consists of two EJB modules. One of the EJB modules has a reference to another class library project, lets call it MyUtilities. When i deploy the application, its ear file does not contain MyUtilities.jar file. When i add to the other EJB module libraries MyUtilites project, although its not necessary, the ear file is built correctly and under its lib folder, MyUtilities.jar exists.
Anyone with the same issue?
Thanks
Did you check the setting of the checkbox "Package required JARs in EJB jar" in the Build | Packaing dialog?
This is a new option which I found after upgrading a NetBeans 6.5.1 EJBModule project which had also no longer the references JARs bundled in the EJB jar.

How to properly set a JavaEE project classpath in Eclipse?

I'm developing a JavaEE system with several applications on a Weblogic AS (10.3.5) using Eclipse indigo with OEPE plugin. I turned my computer off, turned it back on, started the eclipse, and all of a sudden I get class-path errors all over the place (didn't change a thing).
Now let me get this straight:
1. Say I have an application with one EAR project that contains an EJB project and an EJBClient project (both in the deployment assembly).
2. I have written a new regular Java project, and I want to use it in both the EJB and EJBClient projects (it needs to be visible to them).
3. As far as I know, I can simply add this Java project to the EAR project's deployment assembly, and it will be visible to the EJB and EJBClient projects.
4. This has been working for me so far, but now I get class-path errors and I have to add this Java project to the build path of each project.
How should I set the class-path when using JavaEE technology in Eclipse?
After some tweaking I managed to solve the errors:
First I removed the library named 'EAR libraries' from the build path of each of my regular Java projects (I have no clue why Eclipse added them, they shouldn't be there).
Then, for each EAR project, I deleted and re-added every project or jar that was not part of the EAR (regular Java projects, other EJBClient projects, etc).
This solved the issue of not finding classes which aren't included in the EAR, but then I had a 'circular dependency' error.
I narrowed that error down to the projects that caused it - It was a regular Java project that was using an EJBClient project of some application in its build path, and the EJBClient project was also using the Java project in its build path.
Sounds trivial, then why havn't I seen it in the first place? Well, I looked into the EAR project of the application, and it didn't have the java project in the deployment assembly, and the EJBClient didn't have Java project as a 'required project'. So where was it?
The java project was in the 'EAR libraries' library of the EJBClient project, which, according to Eclipse, is automatically generated according to the 'MANIFEST.MF' file (which was empty, btw).
So I simply deleted and re-added the 'EAR libraries' library from the build path of the EJBClient project, and it solved the problem, and everything now works.
In conclusion, it seems like the OEPE plugin for Eclipse have some bugs that needs to be fixed.

Eclipse exporting JAR in WAR

I have two projects in eclipse, a library project producing a Jar file and a web project dependant on that Jar. How do I get the web project to export the first projects jar in its war automatically. I know this must have been answered before, but I really cant find it.
Thanks,
The mechanism to determine what goes in the war is not the build path as for "normal" applications, but the "Deployment assembly".
Right-click on the root node of the dynamic web project, and select Properties, and select Deployment assembly. Here you can add projects (which are jarred up and added to WEB-INF/lib) and individual jars in the project.
EDIT 2015-08-20: A few years later, Maven has become the standard way to build Java-based software primarily due to the script based approach to dependency management. This includes how to build WAR-files, and the three major IDE's (IntelliJ, Netbeans and Eclipse) fully support this allowing you to switch between IDE's while developing. In Eclipse the problem asked here will not apply, as this is fully controlled by the Maven plugin.

Eclipse WAR with 2 projects?

I am trying to export a WAR file from Eclipse. I have a "Dynamic Web Project". But I need classes created for two other projects, one a plain Java project, the other another web project. So in the Build Config I told it to add the other projects and on the "Order and Export" page I clicked the boxes to export the second and third projects. In runs fine within Eclipse, apparently finds the files from the other projects with no problem. But when I export, only the files from the first project are included in the WAR file.
How do I get Eclipse to include the other projects' files in the WAR? Apparently just adding them to the Build Config and marking for export isn't enough. Is there a problem because one of the other projects is also a web project? Does Eclipse balk at that?
I presume I could make this work by copying the files I need from the other projects to the first. But then any time they are updated, I would have to know that this had happened and copy the new versions. That would be a pain, and I thought that's what Eclipse projects were for, so I could share files between applications.
Edit
Let me clarify that I don't want to deploy 2 WARs. I have a web app written for one project that includes some classes that I want to re-use on another project. What I was trying to do was just pick up those couple of classes in the "real" WAR. I definately don't want to deploy 2 WARs because this might go on the same server as the original project, and I don't want to overwrite the existing WAR of the original project.
Thanks for any help!
You need to add your other project as a Java EE module to your web project. Right click on your web project -> properties -> Java EE module Dependencies. Add the 'other' project to it. Eclipse will include this project in the export.
Packing together different projects for deployment is achieved through an EAR file (enterprise archive). An EAR may combine multiple web projects (WAR), Enterprise JavaBeans projects (JAR), standard JARs, etc. and packs it into a single application.
Create a new EAR project in Eclipse, open its properties and check all dependencies on the Java EE Module Dependencies page. After that export the project as an EAR and deploy it.

Categories