I am using JBoss AS 7 with Eclipse Indigo, and i have a problem with deploying a WAR.
In fact, i have 2 projects :
First containing the "Logic part": The differents EJB (Session Bean + Entity Bean)
Second containing the "Web part": Related to the web application, which have some JSF, xhtml and backing bean stuff.
So basically, I added to my Second project classpath, the first (build path -> project -> add).
Then i try to make a basic xhtml file (form), interacting with a backing bean, interacting itself with the Session Bean of my first project.
But when i try to deploy my application, i have the following exception :
catching: org.jboss.weld.resources.spi.ResourceLoadingException: Error loading class MY_BACKINGBEAN_CLASS
Caused by: java.lang.NoClassDefFoundError: MY_SESSIONBEAN_CLASS
I don't get why this error happens, because i included in my classpath the project containing all the session bean.
I know there are a lot of thing about deploying war, but i didn't find any good solution.
Thanks.
Related
I'm building a set of REST services and deploying each service to a separate WAR file. Since each of these services uses the exact same persistence configuration, I've placed my persistence.xml in a jar file (the path of the persistence.xml file in the jar is still /META-INF).
When running this using TomEE (1.7), this works just fine. However, when I try the same thing with WebSphere (8.5.5.x) my persistence units do not get loaded. In the WebSphere log, I get an error that looks like:
[4/27/16 8:54:21:653 EDT] 00000080 JPAApplInfo E CWWJP0029E: The server cannot find the MRO_PU_JTA persistence unit in the Customer_WAR.war module and the DS_APP_EAR application.
[4/27/16 8:54:21:654 EDT] 00000080 InjectionBind E CWNEN0035E: The ds.services.helper.AbstractServiceHelper/em reference of type javax.persistence.EntityManager for the component in the Customer_WAR.war module of the DS_APP_EAR application cannot be resolved.
[4/27/16 8:54:21:657 EDT] 00000080 ResourceInjec E CWOWB0102E: A JCDI error has occurred: The ds.services.helper.AbstractServiceHelper/em reference of type javax.persistence.EntityManager for the null component in the Customer_WAR.war module of the DS_APP_EAR application cannot be resolved.
When I copy the persistence.xml file from my jar file to the local WAR's META-INF, this error goes away and everything works fine. Since I have a ton of services to deploy this way, I don't want to have to make copies of persistence.xml for every WAR file.
Is there any way to get WebSphere to find my persistence.xml file? Maybe some setting in WebSphere that I haven't been able to find?
Thanks.
Ok, so it seems that this is a duplicate of the following: Sharing a persistence unit across components in a .ear file
Looking at the answer to that question from Pascal Thivent, it becomes fairly obvious what the problem is: In order to get this to work, the jar file that contains the persistence.xml must be present in the /lib directory of the EAR that is being deployed to WebSphere. Apparently, the way it works is that the EAR resolves the persistence.xml file, and when each WAR file attempts to inject the entity manager, it refers to the EAR to do so. This is in contrast to TomEE (which is deploying without an EAR file). In that case the dependency is resolved by the WAR file classloader, so just having the jar file in the classpath of the WAR is sufficient.
We have a web application using spring framework which works well. We try to use the same spring context in a standalone application built with maven. We managed to get the context by launching the application within eclipse, a main class instantiates the Spring context with the following lines:
ApplicationContext ap = new ClassPathXmlApplicationContext("spring/applicationContext.xml");
But when we build a jar with maven and launch it with a command line we encounter errors. Here is the command line:
java -jar application.jar
The jar contains a META-INF that defines the classpath generated by maven-jar-plugin.
First spring failed on this error
Unable to locate NamespaceHandler when using context:annotation-config
We solved the problem by merging the different spring.handler files from maven spring jars and putting the result in our application.jar. This is a common solution to this problem but this doesn't explain why this failed in standalone mode but worked in a web app and in eclipse. Eclipse and standalone use the same code (java and spring configuration files).
Now we are facing a second problem, some beans instantiations fail. Some of our beans are declared with XML, some other beans are declared with annotations. Beans declared with annotations are not instantiated in standalone mode, traces in constructors show it, so instantiation of XML beans referencing these beans fails. We didn't solve this problem yet.
We don't understand why we observe a different behavior in eclipse or in standalone mode. What can explain the difference ? How does eclipse call java, how does-it set the classpath ?
Thanks for any response,
Mickaƫl
I'm just about migrating from JBoss 6.1 to Glassfish 3.1 (don't ask why). The following occurs:
Invalid ejb jar [mmsUserMgmtAct-0.0.1-SNAPSHOT.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.
As everything was running perfectly with Jboss I can swear there are EJBs within the jars. The only thing which might cause the error is the fact, that I splitted the interfaces (#Remote and #Local) plus the entities (#Entity) into a package xyzService.jar and the stateless bean (#Stateless, #Remote(XyzService.class)) into another archive named xyzServiceImpl.jar.
All packaging was generated by maven, so no issues with this. Maybe I should mention that I simply copied the things into autodeploy folder.
Any glues?
Thx in advance
El Subcomandante
My eclipse setup for web project worked before. But all of the sudden it stops working.
Eclipse version Build id: 20100218-1602
It is a very standard setup. I have a servers project setup in eclipse. I have defined an tomcat server in it. I was able to run my web project this way.
Suddenly for some reason today I saw this exception:
org.springframework.beans.factory.CannotLoadBeanClassException:
Error loading class [some.company.persistence.dao.hbm.ProductDaoImpl]
for bean with name 'productDao' defined in class path resource [SomeDB.xml]:
problem with class file or dependent class; nested exception is
java.lang.NoClassDefFoundError: org/springframework/orm/hibernate3/support
/HibernateDaoSupport
Based on the message above, can anyone suggest what may be broken?
Looks like the hibernate library is missing from the project's classpath. Figure out which one of the spring jars contains HibernateDaoSupport and add it to your project's classpath.
I try to create JPA persistency module and access it from OSGI WAB in glassfish 3.1.
The way to do it in non-OSGI WAR is to copy the persistency jar into WAR.
However when I deploy the OSGI WAB with jpa jar, I get the exception:
[#|2011-02-01T18:29:10.035+0200|SEVERE|glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=17;_ThreadName=Thread-1;|java.lang.RuntimeException: java.util.zip.ZipException: duplicate entry: META-INF/maven/com.test/test-web/pom.properties
at org.glassfish.osgijavaeebase.OSGiBundleArchive$1.run(OSGiBundleArchive.java:366)
Should the JPA jar contain some special entries in a manifest? It must be defined as OSGI bundle? Please consult.
Update:
The issues was resolved:
To avoid ZipException, I removed the "." from Bundle-Classpath in bundle Manifest.
To get more detailed logs with exceptions, I upgraded Glassfish 3.1 build to 41 (I was working with build 35).
JPA with Hibernate inside bundle started to work after I fixed several classpath problems
To use JPA in a WAB, you just have to drop the persistence jar containing entities and persistence.xml in WEB-INF/lib/ of your WAB. Tell us how the Bundle-ClassPath manifest entry in the WAB looks like. I don't watch this forum; I watch glassfish forum. Can you post your question at users#glassfish.java.net if you want faster response?