繁体   English   中英

CXF WebService 的 Spring 配置得到 java.lang.NoClassDefFoundError: javax/xml/ws/EndpointReference

[英]Spring configuration for CXF WebService got java.lang.NoClassDefFoundError: javax/xml/ws/EndpointReference

我正在尝试让 CXF 与 spring、weblogic 上的 maven 一起工作。项目编译/构建正常,但是当我尝试部署它时出现此错误:

  <User defined listener org.springframework.web.context.ContextLoaderListener failed:    org.springframework.beans.factory.BeanCreationException: Error creating bean with name   'ibanInfos': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/ws/EndpointReference.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ibanInfos': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/ws/EndpointReference
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at  org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    Truncated. see log file for complete stacktrace
java.lang.NoClassDefFoundError: javax/xml/ws/EndpointReference
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2395)
    at java.lang.Class.getDeclaredMethods(Class.java:1763)
    at java.beans.Introspector$1.run(Introspector.java:1265)
    at java.security.AccessController.doPrivileged(Native Method)

知道如何解决这个问题吗? 事实上,我正在使用 java 优先策略来生成 WSDL。

这是我的弹簧文件:

  <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:jaxws="http://cxf.apache.org/jaxws"
    xsi:schemaLocation="
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
    <import resource="classpath:META-INF/cxf/cxf.xml" />
    <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
    <import resource="classpath:service-definition-beans.xml"/> 
    <jaxws:endpoint id="ibanInfos" implementor="#ibanInfosService" address="http://localhost:7001/IbanInfos" />  
</beans>

确保您的类路径中有jaxws-api-2.3.1.jar

它可以通过上面的链接或从 maven 下载。

<dependency>
    <groupId>javax.xml.ws</groupId>
    <artifactId>jaxws-api</artifactId>
    <version>2.3.1</version>
</dependency>

我终于找到了问题所在:我实际上在 10.0 版本下使用 weblogic,它提供了包含 EndPointInterface 的 Jaxws2.0。 一种解决方法是将 jar 添加到 setDomainEnv.sh 中,它将完美运行。 非常感谢你的回答。

EndpointReference是在 JAX-WS 2.1 中引入的,JAX-WS 2.1 从 Java 1.6.0_04 开始包含在 JRE 中。

因此,如果EndpointReference在您的环境中不可用,您需要升级 JRE/JDK,或将最新版本的 JAX-WS API 作为单独的依赖项包含在内。

好像这个类不在你的类路径中。 您应该将相关项目添加到您的 POM。 网上搜了一下,很多图书馆都有这个类。 以下是包含此类 artifact 的摘录:

<dependency>
  <groupId>javax.xml.ws</groupId>
  <artifactId>jaxws-api</artifactId>
  <version>2.2.3</version>
</dependency>

看起来您正在使用更高版本的 java,但应用程序还不兼容它。

如果您在 Intellij 中构建应用程序,请尝试将 jdk 设置更改为 java11 或 java8,这将解决问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM