1

更新ClassNotFoundException仅当我在启动应用程序后立即尝试使用 Web 服务时才会发生这种情况。如果我等待(对于一些未知的事件/持续时间),应用程序将工作。我想知道我需要等待什么。


问题:我的应用程序失败,因为类加载器找不到确实存在的类。

更多信息

找不到的类是com.sun.xml.stream.ZephyrParserFactory

在我的耳朵里,我有sjsxr.jar. 这个 jar 包含类com.sun.xml.stream.ZephyrParserFactory

EAR 还包含MyApp.jar,其中包含应用程序的 EJB 入口点。MyApp.jar清单引用了所有需要的 jar,包括sjsxr.jar

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.1
Created-By: 1.5.0_18 (Sun Microsystems Inc.)
Built-By: GMM Development Team
Class-Path: aopalliance-1.0.jar commons-codec-1.4.jar commons-collecti
 ons-3.1.jar commons-lang-2.1.jar commons-logging-1.1.1.jar ehcache-co
 re-2.1.0.jar ehcache-spring-annotations-1.1.2.jar joda-time-1.6.1.jar
  log4j-1.2.16.jar org.springframework.context.support-3.0.4.RELEASE.j
 ar sjsxr.jar slf4j-api-1.6.1.jar slf4j-log4j12-1.6.1.jar spring-aop
 -3.0.4.RELEASE.jar spring-asm-3.0.4.RELEASE.jar spring-beans-3.0.4.RE
 LEASE.jar spring-context-3.0.4.RELEASE.jar spring-core-3.0.4.RELEASE.
 jar spring-expression-3.0.4.RELEASE.jar spring-jdbc-3.0.4.RELEASE.jar
  spring-tx-3.0.4.RELEASE.jar swiftVal.jar velocity-1.5.jar vm-startup
 .jar xbean.jar

wsimport该应用程序包含由 WebSphere 的工具生成的 Web 服务客户端代码。当应用程序尝试调用此代码时,将引发以下异常:

EJB threw an unexpected (non-declared) exception during invocation of method 
  "messageIn" on bean "BeanId(MyApp#ejb.jar#NodeEJB, null)". 
Exception data: javax.xml.stream.FactoryConfigurationError: Provider
  com.sun.xml.stream.ZephyrParserFactory not found
    at javax.xml.stream.XMLInputFactory.newInstance(Unknown Source)
    at org.apache.axiom.om.util.StAXUtils$7.run(StAXUtils.java:327)
    at java.security.AccessController.doPrivileged(AccessController.java:202)
    at org.apache.axiom.om.util.StAXUtils.getXMLInputFactory_perClassLoader(StAXUtils.java:323)
    at org.apache.axiom.om.util.StAXUtils.getXMLInputFactory(StAXUtils.java:78)
    at org.apache.axiom.om.util.StAXUtils.createXMLStreamReader(StAXUtils.java:133)
    at org.apache.axis2.util.XMLUtils.toOM(XMLUtils.java:596)
    at org.apache.axis2.util.XMLUtils.toOM(XMLUtils.java:581)
    at org.apache.axis2.deployment.DescriptionBuilder.buildOM(DescriptionBuilder.java:97)
    at org.apache.axis2.deployment.AxisConfigBuilder.populateConfig(AxisConfigBuilder.java:90)
    at org.apache.axis2.deployment.DeploymentEngine.populateAxisConfiguration(DeploymentEngine.java:641)
    at com.ibm.ws.websvcs.deployment.WASAxis2ConfigurationBuilder.loadAxisCfg(WASAxis2ConfigurationBuilder.java:492)
    at com.ibm.ws.websvcs.deployment.WASAxis2ConfigurationBuilder.loadAxisClientConfiguration(WASAxis2ConfigurationBuilder.java:191)
    at com.ibm.ws.websvcs.client.WSClientConfigurationFactory.getConfigContext(WSClientConfigurationFactory.java:271)
    at com.ibm.ws.websvcs.client.WSClientConfigurationFactory.getClientConfigurationContext(WSClientConfigurationFactory.java:236)
    at org.apache.axis2.jaxws.description.impl.DescriptionFactoryImpl.createServiceDescription(DescriptionFactoryImpl.java:92)
    at org.apache.axis2.jaxws.description.impl.DescriptionFactoryImpl.createServiceDescription(DescriptionFactoryImpl.java:79)
    at org.apache.axis2.jaxws.description.DescriptionFactory.createServiceDescription(DescriptionFactory.java:76)
    at org.apache.axis2.jaxws.spi.ServiceDelegate.<init>(ServiceDelegate.java:212)
    at org.apache.axis2.jaxws.spi.Provider.createServiceDelegate(Provider.java:59)
    at javax.xml.ws.Service.<init>(Service.java:67)
    at my.generated.Web_Service.<init>(Web_Service.java:44)
...
Caused by: java.lang.ClassNotFoundException: com.sun.xml.stream.ZephyrParserFactory
    at java.lang.Class.forNameImpl(Native Method)
    at java.lang.Class.forName(Class.java:136)
    at javax.xml.stream.FactoryFinder.newInstance(Unknown Source)
    at javax.xml.stream.FactoryFinder.find(Unknown Source)
    at javax.xml.stream.FactoryFinder.find(Unknown Source)
    ... 101 more

我已经确认了六次,类、jar 和清单在部署前后都是正确的。

我也尝试重命名sjsxr.jar以避免任何潜在的日食,但问题并没有消失。

我正在使用 WebSphere 7.0.0.11 ND

任何人都可以帮忙吗?

4

1 回答 1

2

很久没用java了,只是简单接触了下WebSphere,也许会有所帮助?如果您在使用清单查找 jar 文件时遇到问题,请尝试将其打包WEB-INF/lib到 jar 中的文件夹中。假设我正确阅读了链接页面上的信息,则无需在清单中引用它就可以隐式找到它。

您可能还想查看这个 WebSphere 链接,大约在页面中间的“在 EAR 文件中引用类”标题下。

于 2010-11-30T02:38:12.960 回答