【问题标题】:JAXWS in WebsphereWebsphere 中的 JAXWS
【发布时间】:2012-03-08 20:17:56
【问题描述】:

我在 Netbeans 中编写了一个简单的 Web 服务,如下所示。

@WebService()
public class CRSEncryptString {

/**
 * Web service operation
 */
@WebMethod(operationName = "encryptString")
public String encryptString(@WebParam(name = "plainText")
String plainText) {
    System.out.println("************* ");
    String cipher = plainText;
    System.out.println("***************************");
    return cipher;
}

}

添加的 jar 与 JAX-WS 相关,例如: activation.jar、FastInfoset.jar、http.jar、jaxb jar、jaxws jar、saaj jar 等

它在 Tomcat 和 Weblogic 中运行良好。

但是,在Websphere 6.1 中运行时出现错误。

以下是服务器日志:

[2/17/12 17:22:53:421 IST] 0000003c AdminHelper   A   ADMN1009I: An attempt is made to start the JAXWS-Test1_war application.
[2/17/12 17:22:54:390 IST] 0000003c ApplicationMg A   WSVR0200I: Starting application: JAXWS-Test1_war
[2/17/12 17:22:54:452 IST] 0000003c ApplicationMg A   WSVR0204I: Application: JAXWS-Test1_war  Application build level: Unknown
[2/17/12 17:22:54:624 IST] 0000003c WebGroup      A   SRVE0169I: Loading Web Module: JAXWS-Test1.war.
[2/17/12 17:22:54:936 IST] 0000003c http          I   WSSERVLET12: JAX-WS context listener initializing

[2/17/12 17:22:55:264 IST] 0000003c http          E   WSSERVLET11: failed to parse runtime descriptor: java.lang.LinkageError: You are loading old SAAJ from jar:file:/E:/Program%20Files/Websphere6_1/lib/j2ee.jar!/javax/xml/soap/MessageFactory.class
                             java.lang.LinkageError: You are loading old SAAJ from jar:file:/E:/Program%20Files/Websphere6_1/lib/j2ee.jar!/javax/xml/soap/MessageFactory.class
    at com.sun.xml.ws.api.SOAPVersion.<init>(SOAPVersion.java:184)
    at com.sun.xml.ws.api.SOAPVersion.<clinit>(SOAPVersion.java:83)
    at java.lang.J9VMInternals.initializeImpl(Native Method)
    at java.lang.J9VMInternals.initialize(J9VMInternals.java:177)
    at com.sun.xml.ws.api.BindingID.<clinit>(BindingID.java:318)
    at java.lang.J9VMInternals.initializeImpl(Native Method)
    at java.lang.J9VMInternals.initialize(J9VMInternals.java:177)
    at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.createBinding(DeploymentDescriptorParser.java:302)
    at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parseAdapters(DeploymentDescriptorParser.java:243)
    at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parse(DeploymentDescriptorParser.java:147)
    at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:108)
    at com.ibm.ws.wswebcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:605)
    at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinish(WebApp.java:265)
    at com.ibm.ws.wswebcontainer.webapp.WebApp.initialize(WebApp.java:271)
    at com.ibm.ws.wswebcontainer.webapp.WebGroup.addWebApplication(WebGroup.java:88)
    at com.ibm.ws.wswebcontainer.VirtualHost.addWebApplication(VirtualHost.java:157)
    at com.ibm.ws.wswebcontainer.WebContainer.addWebApp(WebContainer.java:653)
    at com.ibm.ws.wswebcontainer.WebContainer.addWebApplication(WebContainer.java:606)
    at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:333)
    at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:549)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1295)
    at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1129)
    at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:567)
    at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:814)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:948)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl$1.run(ApplicationMgrImpl.java:1478)
    at com.ibm.ws.security.auth.ContextManagerImpl.runAs(ContextManagerImpl.java:3731)
    at com.ibm.ws.security.auth.ContextManagerImpl.runAsSystem(ContextManagerImpl.java:3813)
    at com.ibm.ws.security.core.SecurityContext.runAsSystem(SecurityContext.java:245)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:1483)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:615)
    at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:62)
    at sun.reflect.GeneratedMethodAccessor23.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:615)
    at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:265)
    at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1089)
    at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:971)
    at com.sun.jmx.mbeanserver.DynamicMetaDataImpl.invoke(DynamicMetaDataImpl.java:231)
    at com.sun.jmx.mbeanserver.MetaDataImpl.invoke(MetaDataImpl.java:238)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:833)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:802)
    at com.ibm.ws.management.AdminServiceImpl$1.run(AdminServiceImpl.java:1055)
    at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
    at com.ibm.ws.management.AdminServiceImpl.invoke(AdminServiceImpl.java:948)
    at com.ibm.ws.management.application.AppManagementImpl._startApplication(AppManagementImpl.java:1285)
    at com.ibm.ws.management.application.AppManagementImpl.startApplication(AppManagementImpl.java:1184)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:615)
    at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:62)
    at sun.reflect.GeneratedMethodAccessor23.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:615)
    at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:265)
    at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1089)
    at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:971)
    at com.sun.jmx.mbeanserver.DynamicMetaDataImpl.invoke(DynamicMetaDataImpl.java:231)
    at com.sun.jmx.mbeanserver.MetaDataImpl.invoke(MetaDataImpl.java:238)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:833)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:802)
    at com.ibm.ws.management.AdminServiceImpl$1.run(AdminServiceImpl.java:1055)
    at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
    at com.ibm.ws.management.AdminServiceImpl.invoke(AdminServiceImpl.java:948)
    at com.ibm.ws.management.connector.AdminServiceDelegator.invoke(AdminServiceDelegator.java:139)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:615)
    at com.ibm.ws.management.connector.soap.SOAPConnector.invoke(SOAPConnector.java:338)
    at com.ibm.ws.management.connector.soap.SOAPConnector.service(SOAPConnector.java:206)
    at com.ibm.ws.management.connector.soap.SOAPConnection.handleRequest(SOAPConnection.java:55)
    at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:680)
    at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:484)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1498)
Caused by: java.lang.NoSuchMethodError: javax/xml/soap/MessageFactory.newInstance(Ljava/lang/String;)Ljavax/xml/soap/MessageFactory;
    at com.sun.xml.ws.api.SOAPVersion.<init>(SOAPVersion.java:178)
    ... 78 more

[2/17/12 17:22:55:467 IST] 0000003c WebApp        E   WSSERVLET11: failed to parse runtime descriptor: java.lang.LinkageError: You are loading old SAAJ from jar:file:/E:/Program%20Files/Websphere6_1/lib/j2ee.jar!/javax/xml/soap/MessageFactory.class
 [2/17/12 17:22:55:514 IST] 0000003c ServletWrappe I   SRVE0242I: [JAXWS-Test1_war] [/JAXWS-Test1] [CRSEncryptString]: Initialization successful.
[2/17/12 17:22:55:530 IST] 0000003c VirtualHost   I   SRVE0250I: Web Module <null> has been bound to default_host[*:9080,*:80,*:9443,*:5060,*:5061,*:443].
[2/17/12 17:22:55:561 IST] 0000003c ApplicationMg A   WSVR0221I: Application started: JAXWS-Test1_war
[2/17/12 17:23:05:714 IST] 00000048 ServletWrappe I   SRVE0242I: [JAXWS-Test1_war] [/JAXWS-Test1] [/index.jsp]: Initialization successful.

请进一步建议我。

提前致谢…………

【问题讨论】:

    标签: websphere jax-ws


    【解决方案1】:

    我通过管理控制台更改 Websphere 的类加载器策略解决了这个问题,即从 Parent_first 到 Parent_last 策略....

    【讨论】:

      【解决方案2】:

      一般来说,如果您不使用 WebSphere 自己的实现,我认为您将难以在 WebSphere 下使用 JAX-WS。因此,您不希望部署任何额外的 jar,而是使用 WebSphere 7 中已经存在的那些。

      【讨论】:

        【解决方案3】:

        如果您使用的是 RAD,您应该将 Websphere Application Server 运行时添加到您的项目构建路径中,而不是添加外部 jar。

        【讨论】:

        • 请你建议我在运行时添加的过程......它适合我的问题......
        • 我手头没有 RAD,但它是这样的:右键单击您的项目 -> 构建路径-> 库,然后将 IBM WAS Runtime 添加到您的项目中。
        【解决方案4】:

        更改 Websphere 中的类加载器顺序是有风险的,因为您正在加载 Websphere 可能不支持的自定义实现,并且您可能会遇到诸如 LinkageErrors 和 ClassCastException 等运行时错误,因为不同的实现共存于同一个 Java 进程中。最好的方法是使用 IBM 支持的 Jax-WS 编程模型。 或者,您可以通过禁用 IBM 的

        来使用自定义 Web 服务引擎

        -Dcom.ibm.websphere.webservices.DisableIBMJAXWSEngine=true

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2011-11-23
          • 1970-01-01
          • 1970-01-01
          • 2016-10-03
          • 2011-07-21
          • 2012-05-05
          • 2011-07-06
          相关资源
          最近更新 更多