This question already has an answer here:
Not able to deploy EAR file
(1 answer)
Closed 6 years ago.
I am developing a web module in struts2 framework and ejb module in eclipse with hibernate as ORM framework.
Every time when I modify my ejb module I have to package it into jar and include it in my web module /WEB-INF/lib folder in order to run my whole application.
Though the application worked fine in this way but it was really time consuming. So I tried to map them in a EAR module. But when I try to run EAR module.
It gives below exceptions
2016-12-24 13:23:43,992 ERROR [org.apache.struts2.dispatcher.DefaultDispatcherErrorHandler] (default task-4) Exception occurred during processing request: WFLYEJB0442: Unexpected Error: javax.ejb.EJBException: WFLYEJB0442: Unexpected Error
at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:184)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:277)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:327)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:239)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ejb3.component.invocationmetrics.WaitTimeInterceptor.processInvocation(WaitTimeInterceptor.java:47)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:100)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ejb3.deployment.processors.StartupAwaitInterceptor.processInvocation(StartupAwaitInterceptor.java:22)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
Caused by: java.lang.NoClassDefFoundError: org/hibernate/HibernateException
at com.ebs.persistence.dao.UserDao.<clinit>(UserDao.java:16)
at com.ebs.business.service.UserAuthorisationBusinessService.getUserProfile(UserAuthorisationBusinessService.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.hibernate.HibernateException from [Module "deployment.EBS.ear.EBS-ejb.jar:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
... 179 more
Below is where I suspect to get the exception
private static SessionFactory sessfct = SessionFactoryGenerator.getSessionFactory();
It seems to be some issue with classloader.Somehow it is not able to load hibernatecore.jar. Earlier it use to work fine with same set of jars when EAR was not in the picture. I am new to EAR. Below is the structure of application.xml
<module>
<web>
<web-uri>EBS-web.war</web-uri>
<context-root>EBS-web</context-root>
</web>
</module>
<module>
<ejb>EBS-ejb.jar</ejb>
</module>
I also tried including all the jars in EAR lib folder but no success was achieved
I am developing a web module in struts2 framework and ejb module in
eclipse with hibernate as ORM framework. Every time when I modify my
ejb module I have to package it into jar and include it in my web
module /WEB-INF/lib folder in order to run my whole application.
With an Eclipse plugin as WTP, you should not have this problem.
I also tried including all the jars in EAR lib folder but no success
was achieved
If you place the JARs in the EAR, they should be in the APP-INF/lib folder at the root of the EAR.
Besides, you could use a build tool as Maven or Gradle. It could ease your job of packaging.
Related
I read in other topics, but I can't quite figure this out. I have an EJB module that uses log4j. I want to package that EJB into a JAR file and put in the WEB-INF/lib path of a web project. The web project has a servlet that executes a function from the EJB, and that's it. But seems that the appender doesn't work, for the file is created but not written.
I read that a deployment descriptor for JBoss, so I created one based on one of the previous posts. But i get a "Failed to process phase STRUCTURE of deployment" error.
12:04:44,905 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.deployment.unit."SampleWeb.war".STRUCTURE: org.jboss.msc.service.StartException in service jboss.deployment.unit."SampleWeb.war".STRUCTURE: Failed to process phase STRUCTURE of deployment "SampleWeb.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_21]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_21]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_21]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: Sub deployment SampleEJB.jar in jboss-structure.xml was not found. Available sub deployments:
at org.jboss.as.server.deployment.module.descriptor.DeploymentStructureDescriptorParser.subDeploymentNotFound(DeploymentStructureDescriptorParser.java:233) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.server.deployment.module.descriptor.DeploymentStructureDescriptorParser.deploy(DeploymentStructureDescriptorParser.java:159) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
... 5 more
Here's the jboss-deployment-structure.xml I created. Because the web project only uses the EJB jar file I created I assumed that the deployment tag is not used.
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<sub-deployment name="SampleEJB.jar">
<exclusions>
<module name="org.apache.log4j"/>
<module name="org.slf4j" />
<module name="org.apache.commons.logging"/>
<module name="org.log4j"/>
<module name="org.jboss.logging"/>
</exclusions>
</sub-deployment>
</jboss-deployment-structure>
I'm using JBoss 7.1.1, by the way.
It seems like eclipse issue, may happen when dependant project of an ear not built properly.
In my case I was getting the same error with reason that ear was unable to find one included dependency jar.
Just check that dependent project and check it's target directory where maven creates jar after building the project. It would be empty if maven does not build that project properly.
Build that dependent project separately by "mvn install" and then try deploying ear on your server.
It worked for me.
org.jboss.as.server.deployment.DeploymentUnitProcessingException: Sub deployment SampleEJB.jar in jboss-structure.xml was not found.
It seems SampleEJB.jar is not deployed yet. Create deployment structure file to deploy components in order.
Running the default Skeleton Key example with Jboss AS7 and Resteasy, I have followed the directions exactly here: https://github.com/resteasy/Resteasy/tree/master/jaxrs/examples/oauth2-as7-example but still get an error on deploy:
14:35:10,453 ERROR [org.apache.catalina.core.StandardContext] (MSC
service thread 1-11) Context [/customer-portal] startup failed due to
previous errors: java.lang.NoClassDefFoundError:
org/apache/http/impl/conn/PoolingClientConnectionManager at
org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder.initDefaultEngine(ResteasyClientBuilder.java:428)
[resteasy-client-3.0.6.Final.jar:] at
org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder.build(ResteasyClientBuilder.java:333)
[resteasy-client-3.0.6.Final.jar:] at
org.jboss.resteasy.skeleton.key.as7.OAuthManagedResourceValve.init(OAuthManagedResourceValve.java:115)
[skeleton-key-as7-3.0.6.Final.jar:] at
org.jboss.resteasy.skeleton.key.as7.OAuthManagedResourceValve.lifecycleEvent(OAuthManagedResourceValve.java:66)
[skeleton-key-as7-3.0.6.Final.jar:] at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:115)
[jbossweb-7.0.13.Final.jar:] at
org.apache.catalina.core.StandardContext.start(StandardContext.java:3845)
[jbossweb-7.0.13.Final.jar:] at
org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90)
[jboss-as-web-7.1.1.Final.jar:7.1.1.Final] at
org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at
org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
[rt.jar:1.7.0_25] at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
[rt.jar:1.7.0_25] at java.lang.Thread.run(Thread.java:724)
[rt.jar:1.7.0_25] Caused by: java.lang.ClassNotFoundException:
org.apache.http.impl.conn.PoolingClientConnectionManager from [Module
"org.jboss.resteasy.resteasy-jaxrs:main" from local module loader
#1d1aed21 (roots: /Users/JamesTruty/work/jboss-as-7.1.1.Final
oauth/modules)] at
org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at
org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at
org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at
org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at
org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
... 12 more
I have tried various ways of trying to include the apache httpclient library, but still no luck. Am I missing something?
A NoClassDefFoundError specifies that the particular library was available during compile time, but missing at runtime. You need to make sure that httpclient jar is present in your classpath. If it is present then it might be having a static initialization failure or is being loaded via a different classloader. You can go through this for any further info on how to debug a NoClassDefFoundError
Okay, after more tweaking I got it to successfully deploy the sample app. I needed to update the jar versions and modify the module xml in Jboss to point to org.apache.httpcomponents to use httpclient-4.2.1.jar, httpcore-4.2.1.jar and httpmime-4.2.1.jar.
im trying to migrate my JBOSS 5.1 application to JBOSS 7.0.2. In admin console i select deployments -> add content and my .war and try to enable it.
I already resolved some problems, but cant figure out this one: (in short, in long at the end)
Caused by: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener from [Module "deployment.ZaprogsProject.war:main" from Servic
e Module Loader]
I copied to JBOSS7\standalone\lib\ the following files:
spring-aop-3.0.5.RELEASE.jar
spring-asm-3.0.5.RELEASE.jar
spring-beans-3.0.5.RELEASE.jar
spring-context-3.0.5.RELEASE.jar
spring-context-support-3.0.5.RELEASE.jar
spring-core-3.0.5.RELEASE.jar
spring-expression-3.0.5.RELEASE.jar
spring-jdbc-3.0.5.RELEASE.jar
spring-orm-3.0.5.RELEASE.jar
spring-test-3.0.5.RELEASE.jar
spring-tx-3.0.5.RELEASE.jar
spring-web-3.0.5.RELEASE.jar
spring-webmvc-3.0.5.RELEASE.jar
I have read this: https://docs.jboss.org/author/display/AS7/How+do+I+migrate+my+application+from+AS5+or+AS6+to+AS7 (Debug and resolve ClassNotFoundExceptions and NoClassDefFoundErrors) but cant find a solution for me and still getting the same error. Can anyone help?
22:19:12,091 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC00001: Failed to start service jboss.deployment.unit."ZaprogsProject.war".INSTALL: o
rg.jboss.msc.service.StartException in service jboss.deployment.unit."ZaprogsProject.war".INSTALL: Failed to process phase INSTALL of deployment "ZaprogsProject
.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121) [jboss-as-server-7.0.2.Final.jar:7.0.2.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [:1.7.0]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [:1.7.0]
at java.lang.Thread.run(Thread.java:722) [:1.7.0]
Caused by: java.lang.RuntimeException: Failed to load class org.springframework.web.context.ContextLoaderListener
at org.jboss.as.ee.component.deployers.EEClassConfigurationProcessor$1.compute(EEClassConfigurationProcessor.java:141)
at org.jboss.as.ee.component.deployers.EEClassConfigurationProcessor$1.compute(EEClassConfigurationProcessor.java:122)
at org.jboss.as.ee.component.LazyValue.get(LazyValue.java:40)
at org.jboss.as.ee.component.EEApplicationDescription.getClassConfiguration(EEApplicationDescription.java:183)
at org.jboss.as.ee.component.ComponentDescription.createConfiguration(ComponentDescription.java:153)
at org.jboss.as.ee.component.deployers.EEModuleConfigurationProcessor.deploy(EEModuleConfigurationProcessor.java:70)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115) [jboss-as-server-7.0.2.Final.jar:7.0.2.Final]
... 5 more
Caused by: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener from [Module "deployment.ZaprogsProject.war:main" from Servic
e Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:361)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:333)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:310)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:103)
at java.lang.Class.forName0(Native Method) [:1.7.0]
at java.lang.Class.forName(Class.java:264) [:1.7.0]
at org.jboss.as.ee.component.deployers.EEClassConfigurationProcessor$1.compute(EEClassConfigurationProcessor.java:139)
... 11 more
JBoss AS 7 does class-loading in a diff way.
All classes in the WAR are loaded with the same class loader. This means classes packaged in the WEB-INF/lib are treated the same as classes in WEB-INF/classes.
Hence it works for you.
But as you have said correctly your WEB-INF/lib is bloated.This would not be the correct way.
You would need to make a module :
Goto modules folder, make folder structure with main folder and put your jar and modules.xml with entries in it.
Something like :
<main-class name="org.jboss.msc.Version"/>
<resources>
<resource-root path="jboss-msc-1.0.1.GA.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="org.jboss.logging"/>
<module name="org.jboss.modules"/>
<!-- Optional deps -->
<module name="javax.inject.api" optional="true"/>
<module name="org.jboss.threads" optional="true"/>
<module name="org.jboss.vfs" optional="true"/>
</dependencies>
You would also need to update MANIFEST as well.
Details are here :
https://docs.jboss.org/author/display/MODULES/Module+descriptors
I would not put those JARs in that directory. Try them in your WAR file's WEB-INF/lib. The class loader will find them there.
You need to understand that all Java EE app servers use a hierarchy of class loaders: bootstrap, server, application. JBoss wasn't finding that class when it needed to.
There is a major change Jboss 7 when compared to previous versions.If you want to access any libraries outside your war file, it should be installed as module.
Check https://docs.jboss.org/author/display/MODULES/Introduction
In this case you should install Spring as module and specify the name of the module as dependency in your application's manifest file(check Manifest module information)
In case the issue started occurring all of a sudden(just like in my case), deleting the application (MyApp) physically from #JBOSS_HOME#\standalone\deployments\ MyApp.war worked for me.
I've a big trouble on tomcat.
Before explaine, let me tell is the first time I see something like this...
I'm building an application using JPA on Hibernate, Spring 3.0 and Jersey REST Framework.
When using glassfish, everything works fine, but deployng the same application on tomcat, I registered the following error code:
GRAVE: Error deploying configuration descriptor java-zero.xml
java.lang.NoClassDefFoundError: com/sun/jersey/spi/container/servlet/ServletContainer
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2527)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1010)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1483)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1095)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4187)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4496)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:563)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:498)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:519)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
... 34 more
Then tomcat restarts the application and again, the same error. In an infinite loop.
Looks like a library conflict, but I really don't have any ideas on how to solve it...
Any suggestion is appreciated!
Ciao, Davide.
java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer suggests that you either don't have the Jersey JAR file or you've put it in the wrong place.
If it's the former, download it here and add it to Tomcat.
If it's the latter, put it and all its dependencies in either your WEB-INF/lib, server/lib for Tomcat 5.x or lib for Tomcat 6.x. (Just one, not all.)
It works with Glassfish because they've bundled it for you. Tomcat has not.
Remove all Jersey JAR from /WEB_INF/lib folder, refresh project and again paste all JARs of Jersey library into /WEB_INF/lib. Refresh project, stop server again, deploy and run.
It looks like either jersey.jar and/or jsr311-api.jar are missing from your webapp. You might check they are in the WEB-INF/lib folder.
I am getting the following error when I am trying to run my J2EE project. The same project was working before and I started getting this exception now. I am sure that all class are there along with their mapping files.
If I remove mapping of jobtitle from my hibernate.cfg.xml in the project, it is running.
java.lang.ExceptionInInitializerError
hrm.dao.HibernateUtil.<clinit>(HibernateUtil.java:28)
hrm.dao.AbstractDAO.<init>(AbstractDAO.java:29)
hrm.dao.JobSpecificationDAO.<init>(JobSpecificationDAO.java:22)
hrm.actions.JobSpecificationAction.execute(JobSpecificationAction.java:53)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
java.lang.ClassNotFoundException: hrm.dao.Jobtitle
java.lang.ClassNotFoundException: hrm.dao.Jobtitle
means you do indicate a mapping in your hibernate.cfg.xml, but a mapping to a class which is not in the classpath of the j2ee project.