Jboss在jar中找不到类,但在同一个jar中找到另一个?

时间:2013-07-28 06:53:44

标签: class jar jboss loading

我尝试在jboss 4.2.3 GA服务器上部署应用程序。看起来好像Jboss在jar中找不到类,但在同一个jar中找到了另一个类。我想它只看这个,它根本找不到罐子。但是,为什么不呢?

在主servlet RegisterServlet中有这样的陈述:

dispManager = (DispatcherManager)DispatcherManagerFactory.getDispatcherManager();

DispatcherManagerImpl仅在DispatcherManagerFactory中实例化,而不是其他任何地方。 DispatcherManagerFactoryDispatcherManagerImpl存在于jar文件中,即我的WEB-INF / lib库中。只有那里,而不是在Jboss服务器库中。

我在类DispatcherManagerImpl上得到一个ClassNotFoundException。 怎么可能首先在DispatcherManagerFactory上没有得到ClassNotFoundException?

我搜索了很多关于jboss类加载的内容,但我认为应该找到WEB-INF / lib中的jar文件。

myApp的结构:

myApp.ear
    META-INF 
        application.xml
        jboss-app.xml
    MANIFEST.MF
myApp.war
    META-INF
    WEB-INF
        classes
        lib     
            *.jar   
        licenses
        jboss-web.xml
        web.xml
        ...

application.xml的内容:

<!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application   1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd">
<application id="myApp-059-20091104-1530">
<display-name>myApp-059-20091104-1530</display-name>
<module id="WebModule_1212992751021">
    <web>
        <web-uri>myApp.war</web-uri>
        <context-root>myApp</context-root>
    </web>
</module>
<security-role id="SecurityRole_1210074998462">
    <description>User who can use the administration console</description>
    <role-name>myAppBeheerder</role-name>
</security-role>
</application>

jboss-app.xml的内容:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-app PUBLIC "-//JBoss//DTD J2EE Application .3V2//EN" "http://www.jboss.org/j2ee/dtd/jboss-app_4_2.dtd">
<jboss-app>
  <loader-repository>myApp:loader=myAppRepository</loader-repository>
</jboss-app>

jboss-web.xml的内容:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<resource-ref>  
<res-ref-name>jdbc/duplodb</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<jndi-name>java:/duplodb</jndi-name>
</resource-ref>
 </jboss-web>

web.xml的内容:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
<display-name>myApp</display-name>

<description>This Web settings implements the Import functionality.</description>
<servlet>
    <servlet-name>registerservlet</servlet-name>
    <display-name>registerservlet</display-name>
    <servlet-class>nl.nn.lc.duploimport.RegisterServlet</servlet-class>
    <init-param>
    <param-name>SplitterRegisteredObjectName</param-name>
    <param-value>ibis4duplo-ponsfilesplitter</param-value>
    </init-param>
    <init-param>
        <param-name>WorkerRegisteredObjectName</param-name>
        <param-value>ibis4duplo-ponsmutationworker</param-value>
    </init-param>
    <init-param>
        <param-name>autoStart</param-name>
        <param-value>true</param-value>
    </init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>registerservlet</servlet-name>
    <url-pattern>/RegisterServlet</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<resource-ref id="ResourceRef_1211270252323">
    <res-ref-name>jdbc/duplodb</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Application</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<security-constraint>
    <web-resource-collection>
        <web-resource-name>SecurityDuploImport</web-resource-name>
        <description></description>
        <url-pattern>
        /*</url-pattern>
        <http-method>
        GET</http-method>
        <http-method>
        POST</http-method>
    </web-resource-collection>
    <auth-constraint>
        <description></description>
        <role-name>DuploImportBeheerder</role-name>
    </auth-constraint>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>
<login-config>
    <auth-method>BASIC</auth-method>
    <realm-name>duploimport</realm-name>
</login-config>
<security-role>
    <description>User who can use the Duplo IMport administration console</description>
    <role-name>DuploImportBeheerder</role-name>
</security-role>   
</web-app>

RegisterServlet.init()中,我添加了Stacktrace的打印件:

public void init() throws ServletException {
        super.init();
        try {
            dispManager = (DispatcherManager)DispatcherManagerFactory.getDispatcherManager();   
            registerImportProxy();
            logRegServlet.debug(strSuccessMessage);
        } catch (DispatcherException e) {
            logRegServlet.error(e.getMessage());
            e.printStackTrace(System.out);
        }
    }

完整的StackTrace是

15:33:54,808 INFO  [STDOUT] nl.nn.adapterframework.dispatcher.DispatcherException: java.lang.ClassNotFoundException: nl.nn.adapterframework.dispatcher.Disp
atcherManagerImpl
15:33:54,808 INFO  [STDOUT]     at nl.nn.adapterframework.dispatcher.DispatcherManagerImpl.getInstance(DispatcherManagerImpl.java:65)
15:33:54,809 INFO  [STDOUT]     at nl.nn.adapterframework.dispatcher.DispatcherManagerFactory.getDispatcherManager(DispatcherManagerFactory.java:19)
15:33:54,809 INFO  [STDOUT]     at nl.nn.lc.duploimport.RegisterServlet.init(Unknown Source)
15:33:54,809 INFO  [STDOUT]     at javax.servlet.GenericServlet.init(GenericServlet.java:212)
15:33:54,809 INFO  [STDOUT]     at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1048)
15:33:54,809 INFO  [STDOUT]     at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:950)
15:33:54,809 INFO  [STDOUT]     at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4122)
15:33:54,809 INFO  [STDOUT]     at org.apache.catalina.core.StandardContext.start(StandardContext.java:4421)
15:33:54,809 INFO  [STDOUT]     at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:367)
15:33:54,810 INFO  [STDOUT]     at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:146)
15:33:54,810 INFO  [STDOUT]     at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:460)
15:33:54,810 INFO  [STDOUT]     at org.jboss.web.deployers.WebModule.startModule(WebModule.java:118)
15:33:54,810 INFO  [STDOUT]     at org.jboss.web.deployers.WebModule.start(WebModule.java:96)
15:33:54,810 INFO  [STDOUT]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
15:33:54,811 INFO  [STDOUT]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
15:33:54,813 INFO  [STDOUT]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
15:33:54,815 INFO  [STDOUT]     at java.lang.reflect.Method.invoke(Method.java:597)
15:33:54,817 INFO  [STDOUT]     at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
15:33:54,819 INFO  [STDOUT]     at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
15:33:54,821 INFO  [STDOUT]     at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
15:33:54,823 INFO  [STDOUT]     at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
15:33:54,823 INFO  [STDOUT]     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
15:33:54,823 INFO  [STDOUT]     at org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206)
15:33:54,824 INFO  [STDOUT]     at $Proxy36.start(Unknown Source)
15:33:54,824 INFO  [STDOUT]     at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:42)
15:33:54,824 INFO  [STDOUT]     at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:37)
15:33:54,824 INFO  [STDOUT]     at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java
:62)
15:33:54,824 INFO  [STDOUT]     at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
15:33:54,825 INFO  [STDOUT]     at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
15:33:54,825 INFO  [STDOUT]     at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
15:33:54,825 INFO  [STDOUT]     at org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:286)
15:33:54,825 INFO  [STDOUT]     at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598)
15:33:54,826 INFO  [STDOUT]     at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
15:33:54,826 INFO  [STDOUT]     at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062)
15:33:54,827 INFO  [STDOUT]     at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
15:33:54,827 INFO  [STDOUT]     at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
15:33:54,827 INFO  [STDOUT]     at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
15:33:54,827 INFO  [STDOUT]     at org.jboss.system.ServiceController.doChange(ServiceController.java:688)
15:33:54,827 INFO  [STDOUT]     at org.jboss.system.ServiceController.start(ServiceController.java:460)
15:33:54,838 INFO  [STDOUT]     at org.jboss.system.deployers.ServiceDeployer.start(ServiceDeployer.java:146)
15:33:54,843 INFO  [STDOUT]     at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:104)
15:33:54,843 INFO  [STDOUT]     at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:45)
15:33:54,843 INFO  [STDOUT]     at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
15:33:54,843 INFO  [STDOUT]     at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
15:33:54,854 INFO  [STDOUT]     at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
15:33:54,857 INFO  [STDOUT]     at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
15:33:54,857 INFO  [STDOUT]     at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
15:33:54,857 INFO  [STDOUT]     at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)
15:33:54,857 INFO  [STDOUT]     at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1210)
15:33:54,858 INFO  [STDOUT]     at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
15:33:54,859 INFO  [STDOUT]     at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
15:33:54,859 INFO  [STDOUT]     at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598)
15:33:54,859 INFO  [STDOUT]     at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
15:33:54,859 INFO  [STDOUT]     at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062)
15:33:54,860 INFO  [STDOUT]     at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
15:33:54,860 INFO  [STDOUT]     at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
15:33:54,861 INFO  [STDOUT]     at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
15:33:54,861 INFO  [STDOUT]     at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
15:33:54,874 INFO  [STDOUT]     at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:545)
15:33:54,874 INFO  [STDOUT]     at org.jboss.system.server.profileservice.ProfileServiceBootstrap.loadProfile(ProfileServiceBootstrap.java:304)
15:33:54,874 INFO  [STDOUT]     at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:205)
15:33:54,874 INFO  [STDOUT]     at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:405)
15:33:54,875 INFO  [STDOUT]     at org.jboss.Main.boot(Main.java:209)
15:33:54,875 INFO  [STDOUT]     at org.jboss.Main$1.run(Main.java:547)
15:33:54,875 INFO  [STDOUT]     at java.lang.Thread.run(Thread.java:662)
15:33:54,876 INFO  [STDOUT] Caused by: java.lang.ClassNotFoundException: nl.nn.adapterframework.dispatcher.DispatcherManagerImpl
15:33:54,876 INFO  [STDOUT]     at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
15:33:54,876 INFO  [STDOUT]     at java.security.AccessController.doPrivileged(Native Method)
15:33:54,876 INFO  [STDOUT]     at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
15:33:54,876 INFO  [STDOUT]     at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
15:33:54,877 INFO  [STDOUT]     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
15:33:54,890 INFO  [STDOUT]     at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
15:33:54,890 INFO  [STDOUT]     at nl.nn.adapterframework.dispatcher.DispatcherManagerImpl.getInstance(DispatcherManagerImpl.java:52)
15:33:54,890 INFO  [STDOUT]     ... 64 more

-verbose:class放入run.bat中的java命令之后,似乎两个类都被加载了: [Loaded nl.nn.adapterframework.dispatcher.DispatcherManagerFactory from jar:file:/C:/jboss/jboss-5.0.0.GA/server/myApp/deploy/myApp.ear!/myApp.war] [Loaded nl.nn.adapterframework.dispatcher.DispatcherManager from jar:file:/C:/jboss/jboss-5.0.0.GA/server/myApp/deploy/myApp.ear!/myApp.war] [Loaded nl.nn.adapterframework.dispatcher.DispatcherManagerImpl from jar:file:/C:/jboss/jboss-5.0.0.GA/server/myApp/deploy/myApp.ear!/myApp.war] [Loaded nl.nn.adapterframework.dispatcher.RequestProcessorException from jar:file:/C:/jboss/jboss-5.0.0.GA/server/myApp/deploy/myApp.ear!/myApp.war]

堆栈跟踪表示执行DispatcherManagerImpl时找不到DispatcherManagerImpl.getInstance()。这对我来说似乎很奇怪。如何在同一个班级的第65行找不到班级?

0 个答案:

没有答案