I'm using JBoss Developer Studio 7 (alpha) and have an EAR project with two WARs and one JAR. The JAR is a JPA project. The JAR contains all JPA Entities and also persistance.xml (inside META-INF folder). So I'd like to use the persitence unit defined in the JAR from both WARs. Since the idea is that each WAR has to use the shared persistance.xml from the JAR (JPA project) y removed the persitence.xml in each WAR MATA-INF folder, but then when I want to build the WAR I get "No persistence.xml file found in project (WAR name)".
How I resolve this? If I set some dummy configuration in the WAR persistance.xml the IDE let me buid withot errors, but I don't like this, I have two persitence units that never will be used.
Related
I am using Maven 3.3.9 and created a Maven Web Project in Spring tool suite and using Eclipse.
Recently I went through a Tutorial for configuring JPA with maven project.
Tutorial showing JPA configuration
I successfully configured Database connection using EclipseLink2.5
PROBLEM I AM FACING IS
After I click ok followed by configuring JPA 2.1 using project Facet properties. Persistence.xml is created automatically under META-INF of src/main/java instead of src/main/resource location.
Is this correct ??
I had already researched a lot on this, in every blog it is mentioned that META-INF should be placed under src/main/java and not under src/main/resource.
Then why is it every time I create a Maven project and configure JPA from Project Facet, Its ends up automatically creation under src/main/java.
please refer my screenshot.
So should I remove this folder META-INF/Persistence.xml from src/main/java and paste it manually under src/main/resource.
I always move META-INF to src/main/resources. Everything is going to be happier with things configured that way.
Where do I put META-INF in Eclipse?.
I have my enterprise project which contains 2 WARs. There are some common resources in those WARs, in project structure we have base project which is web project. and base project contains common resources for 2 WARs. for those 2 WARs in project structure we have 2 separate web project.
When I do build through maven then I use a overlay option of maven to build a 2 WARs to be merged with a base project WAR. So that common resources from base project war is merged in both WARs from EAR.
I have created a eclipse project by following command,
eclipse:eclipse -Dwtpversion=2.0 eclipse:configure-workspace
Now I want to configure these project in eclipse(Kepler) so I can run those from eclipse by configuring application server on eclipse.
But above commnad add base war file directly in deployment assembly of WARs from EAR, instead of merging it as happening in overlay option of maven build.
I tried to fix this by manual configuration of deployment assembly but there is no option for adding folders from different project.
I have google a lot for solution for this but no luck.
Thanks in advance.
After lot f google one thought came to my mind, how this is been handled in myeclipse?
I have downloaded myeclipse and imported my project in myeclipse, then added maven nature to all project.
Then I have checked deployment assembly of WAR project, there base project added in deployment assembly without any value in deploy path, then i had opened .setting folder from WAR project I have checked the org.eclipse.wst.common.component file where i have found one entry which were doing overlay maven build in deployment assembly, that line is as follows,
<dependent-module deploy-path="/" handle="module:/overlay/prj/base-project?includes=**/**&excludes=META-INF/MANIFEST.MF">
<dependency-type>consumes</dependency-type>
</dependent-module>
here is a solution for overlay issue of maven build, which we need to configure in deployment assembly in component file of .setting folder of project.
I am using JBOSS 7
In my custom jar I am implementing an Interface. The interface is in a jar packaged with ECM.ear file. Unless I put my custom jar inside the web-inf/lib folder (of the war file located in ear file) I am getting ClassNotFoundException w.r.to the interface.
I created a module for my custom jar but I don't how to set up a dependency with ear file. I copied the jar containing the interface say mdm.jar and placed it in the module and also added an entry in the resource root of module.xml. After restarting I am getting ClassNotFoundException for the classes referred by mdm.jar, which arein ear file.
How to achieve this dependency?
Thanks,
Raghu
JBOSS 7 needs you to place the packaged jar files in the lib folders of your web-inf/lib or the ear/lib cos of the Class Loading Precedence that JBOSS server follows.
Alternatively you could load it as a module, but you need to specify any addition of this kind outside of JBOSS default supplied modules using your MANIFEST file or jboss-deployment-structure.xml
This link should provide you more insight on what would suit you best.
Hope it helps.
**EntityManagerFactory factory=Persistence.getEnityManagerFactory(???);**
In specification they are explained in the context of EJBs.But i am not understanding the actual possible locations of persistence.xml in a web archive.
The persistence.xml must always be in the META-INF directory on the classpath. Normally it will be inside a jar that is on the classpath, such as a jar in /WEB-INF/lib/ in your war file.
How can I include external jar file in my ejb3 jar file? There is one external jar project with all helper classes and manifest.mf file. Now I have this jar in my classpath in eclipse. But when eclipse build the ejb-jar I want it to include this external jar file so in Application server when my ejb loads and run it can use classes in external jar. Right now I am adding a reference in Manifest.mf for ejb-jar, still when eclipse build the ejb-jar it is not packaging this external jar and during runtime I am getting ClassNotFoundException.
Can somebody please give me an example how to achieve this? I am using Eclipse 3.6 and EJB3
You have to create ear or war deployment and include your ejb.jar and a third-party.jar into it. Then deploy it to jboss
I found a solution.
Method 2 Worked for me. the tutorial uses Rational, but I assume Eclipse will be similar.
http://www.ibm.com/developerworks/rational/library/07/1211_schrag/index.html
check it out.