提问者:小点点

如何从WAR文件中用自己的模块重写JBoss模块?


我正在使用JBoss 7.1.1,并尝试使用Apache Commons Lang 3.3部署WAR文件。JAR位于WAR文件中的WEB-INF/lib文件夹中。然而,当我运行我的web应用程序时,我得到了以下错误/异常,我认为这是因为JBoss正在使用它自己的较旧的commons-lang库。如何在不修改JBoss安装的情况下覆盖JBoss commons-lang模块?

java.lang.NoClassDefFoundError: org/apache/commons/lang/RandomStringUtils
    org.mainco.subco.dido.service.TrainingSessionServiceImpl.createTrainingLink(TrainingSessionServiceImpl.java:387)
    org.mainco.subco.dido.service.TrainingSessionServiceImpl.addUserLinks(TrainingSessionServiceImpl.java:352)
    org.mainco.subco.dido.service.TrainingSessionServiceImpl.createOrUpdateTrainingSessionFromOrder(TrainingSessionServiceImpl.java:205)
    org.mainco.subco.dido.service.TrainingSessionServiceImpl.createTrainingSessions(TrainingSessionServiceImpl.java:162)
    org.mainco.subco.dido.service.TrainingSessionServiceImpl.createOrUpdateTrainingSessions(TrainingSessionServiceImpl.java:124)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
    org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    $Proxy132.createOrUpdateTrainingSessions(Unknown Source)
    org.mainco.subco.dido.quartz.ProcessPDWorker.work(ProcessPDWorker.java:23)
    org.mainco.subco.dido.controller.IndexController.refreshPD(IndexController.java:40)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
    org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
        org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
    org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

root cause
java.lang.ClassNotFoundException: org.apache.commons.lang.RandomStringUtils from [Module "deployment.didoclient.war:main" from Service Module Loader]
    org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
    org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
    org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
    org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
    org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
    org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
    org.mainco.subco.dido.service.TrainingSessionServiceImpl.createTrainingLink(TrainingSessionServiceImpl.java:387)
    org.mainco.subco.dido.service.TrainingSessionServiceImpl.addUserLinks(TrainingSessionServiceImpl.java:352)
    org.mainco.subco.dido.service.TrainingSessionServiceImpl.createOrUpdateTrainingSessionFromOrder(TrainingSessionServiceImpl.java:205)
    org.mainco.subco.dido.service.TrainingSessionServiceImpl.createTrainingSessions(TrainingSessionServiceImpl.java:162)
    org.mainco.subco.dido.service.TrainingSessionServiceImpl.createOrUpdateTrainingSessions(TrainingSessionServiceImpl.java:124)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
    org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    $Proxy132.createOrUpdateTrainingSessions(Unknown Source)
    org.mainco.subco.dido.quartz.ProcessPDWorker.work(ProcessPDWorker.java:23)
    org.mainco.subco.dido.controller.IndexController.refreshPD(IndexController.java:40)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
    org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
        org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
    org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

谢谢,戴夫


共1个答案

匿名用户

在我看来,你的代码(或者至少是< code > org . mainco . subco . Dido . service . trainingsessionserviceimpl 中的代码)似乎仍然使用旧版本的commons-lang。如果您查看commons-lang 3的Javadoc,您会看到代码位于< code > org . Apache . commons . lang 3 下,而不是< code > org . Apache . commons . lang 3 下。