NoClassDefFoundError:无法在应用程序服务器上实例化类,在本地工作正常(NoClassDefFoundError: Can't instantiate class on application server, works fine locally)

我在WebLogic上运行了一个包含ejb的耳朵。 所有都运行良好,直到ejb尝试实例化ServiceFactory的对象 - 我们自己的类之一。

在我的单元测试中,我可以在本地创建该类的对象。 服务器上发生错误。

我猜这可能是构建/打包问题或WebLogic 10.3.6怪癖,但由于依赖存在于耳中(在APP-INF / lib中),因此不知道从何处开始。 我也尝试将包含类的依赖项移动到耳朵的根部。 对于ejb和ear,MANIFEST.MF文件中的“Class-Path:”为空白,但产品运行正常,直到现在没有它们。 我正和Maven一起建设。

javax.ejb.EJBException: what do i do: seems an odd quirk of the EJB spec. The exception is:java.lang.NoClassDefFoundError: Could not initialize class com.company.ts.management.icm.service.ServiceFactory at com.oracle.pitchfork.intercept.MethodInvocationInvocationContext.proceed(MethodInvocationInvocationContext.java:110) at com.company.it.techservices.aae.service.CommonService.bizLog(CommonService.java:37) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310) at com.oracle.pitchfork.intercept.JeeInterceptorInterceptor.invoke(JeeInterceptorInterceptor.java:68) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131) at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at com.oracle.pitchfork.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:34) at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54) at com.oracle.pitchfork.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:42) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131) at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at com.sun.proxy.$Proxy476.calculateRoles(Unknown Source) at com.company.it.techservices.aae.autheng.AuthorizationEngineBean_t79b4w_AuthorizationEngineBeanRemoteImpl.__WL_invoke(Unknown Source) at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:40) at com.company.it.techservices.aae.autheng.AuthorizationEngineBean_t79b4w_AuthorizationEngineBeanRemoteImpl.calculateRoles(Unknown Source) at com.company.it.techservices.aae.autheng.AuthorizationEngineBean_t79b4w_AuthorizationEngineBeanRemoteImpl_WLSkel.invoke(Unknown Source) at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:667) at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230) at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:522) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146) at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:518) at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256) at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)

I have an ear running on WebLogic that contains an ejb. All runs well until the ejb tries to instantiate an object of ServiceFactory - one of our own classes.

In my unit tests, I could create an object of the class locally. It's on the server that the error occurs.

I'm guessing this is either a build/packaging issue or a WebLogic 10.3.6 quirk but don't know where to proceed from here given that the dependency exists in the ear (in APP-INF/lib). I've also tried moving the dependency that contains the class to the root of the ear. "Class-Path: " is blank in the MANIFEST.MF file for the ejb and the ear, but the product has run fine until now without them. I'm building with Maven.

javax.ejb.EJBException: what do i do: seems an odd quirk of the EJB spec. The exception is:java.lang.NoClassDefFoundError: Could not initialize class com.company.ts.management.icm.service.ServiceFactory at com.oracle.pitchfork.intercept.MethodInvocationInvocationContext.proceed(MethodInvocationInvocationContext.java:110) at com.company.it.techservices.aae.service.CommonService.bizLog(CommonService.java:37) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310) at com.oracle.pitchfork.intercept.JeeInterceptorInterceptor.invoke(JeeInterceptorInterceptor.java:68) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131) at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at com.oracle.pitchfork.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:34) at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54) at com.oracle.pitchfork.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:42) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131) at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119) at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at com.sun.proxy.$Proxy476.calculateRoles(Unknown Source) at com.company.it.techservices.aae.autheng.AuthorizationEngineBean_t79b4w_AuthorizationEngineBeanRemoteImpl.__WL_invoke(Unknown Source) at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:40) at com.company.it.techservices.aae.autheng.AuthorizationEngineBean_t79b4w_AuthorizationEngineBeanRemoteImpl.calculateRoles(Unknown Source) at com.company.it.techservices.aae.autheng.AuthorizationEngineBean_t79b4w_AuthorizationEngineBeanRemoteImpl_WLSkel.invoke(Unknown Source) at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:667) at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230) at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:522) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146) at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:518) at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256) at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)

最满意答案

通常, NoClassDefFoundError意味着可能找到了类但无法初始化。 因此,该类的代码中的某些内容在实例化时会抛出错误(这可能意味着完全缺少不同的类)。

检查您班级的代码。 具体来说,查找静态块或使用ClassLoader未找到的类的成员。

In general NoClassDefFoundError means the class was probably found but could not initialize. So something in the code for that class throws an error when it is instantiated (it could mean a different class entirely is missing).

Check the code for your class. Specifically look for static blocks or members which use a class that's not found by the ClassLoader.

更多推荐