0

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

在主 servletRegisterServlet中是这样的语句:

dispManager = (DispatcherManager)DispatcherManagerFactory.getDispatcherManager();

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

我在 class 上得到一个 ClassNotFoundException DispatcherManagerImpl。我怎么可能没有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:classrun.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 行找不到一个类?

4

0 回答 0