cxf + wss4j + maven NoSuchMethod错误

巴拉吉·克里希南

尝试使用Maven使用cxf + wss4j。创建了服务和客户端,没有任何编译问题。该服务在tomcat中运行良好。
问题:运行客户端代码时,出现“ java.lang.NoSuchMethodError:org.apache.xml.security.utils.I18n.init(Ljava / util / ResourceBundle;)V”。此类在xmlsec jar中,随cxf发行版一起提供。

服务项目的pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>userNameTokenService</groupId>
    <artifactId>userNameTokenService</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <dependencies>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <version>3.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http</artifactId>
            <version>3.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-ws-security</artifactId>
            <version>3.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.ws.security</groupId>
            <artifactId>wss4j</artifactId>
            <version>1.6.15</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>3.2.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>3.2.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>3.2.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>3.2.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-expression</artifactId>
            <version>3.2.6.RELEASE</version>
        </dependency>
    </dependencies>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <configuration>
                        <webXml>WebContent\WEB-INF\web.xml</webXml>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>


客户项目的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>userNameTokenClient</groupId>
  <artifactId>userNameTokenClient</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <dependencies>
      <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <version>3.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http</artifactId>
            <version>3.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-ws-security</artifactId>
            <version>3.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.ws.security</groupId>
            <artifactId>wss4j</artifactId>
            <version>1.6.15</version>
        </dependency>
      <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>3.2.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>3.2.6.RELEASE</version>
        </dependency>
  </dependencies>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <resources>
      <resource>
        <directory>src</directory>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.0</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

编辑:使用wss4j尝试用户名令牌,客户端代码:

public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-context.xml");
        HelloWorld helloworld= (HelloWorld) context.getBean("helloClient");
        HelloRequest hreq = new HelloRequest();
        hreq.setRequestMsg("This is client");
        HelloResponse hres = helloworld.sayHello(hreq);
        System.out.println(hres.getResponseMsg());
    }

客户端wss4j配置:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    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">

    <bean id="logInBound" class="org.apache.cxf.interceptor.LoggingInInterceptor" />
    <bean id="logOutBound" class="org.apache.cxf.interceptor.LoggingOutInterceptor" />
    <jaxws:client id="helloClient" serviceClass="com.ddmwsst.helloworld.HelloWorld"
        address="http://localhost:8080/userNameTokenService/services/HelloWorld">
        <jaxws:inInterceptors>
            <ref bean="logInBound" />
        </jaxws:inInterceptors>
        <jaxws:outInterceptors>
            <ref bean="logOutBound" />
            <ref bean="outbound-security" />
        </jaxws:outInterceptors>
    </jaxws:client>

    <!-- WSS4JOutInterceptor for incorporating a UsernameToken in a SOAP -->
    <bean class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor"
        id="outbound-security">
        <constructor-arg>
            <map>
                <entry key="action" value="UsernameToken" />
                <entry key="user" value="dummy" />
                <!--entry key="passwordType" value="PasswordText"/ -->
                <entry key="passwordCallbackClass" value="client.ClientPasswordCallback" />
            </map>
        </constructor-arg>
    </bean>
</beans>

服务wss4j配置:

<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" />

    <bean id="logInBound" class="org.apache.cxf.interceptor.LoggingInInterceptor" />
    <bean id="logOutBound" class="org.apache.cxf.interceptor.LoggingOutInterceptor" />
    <!-- WSS4JInInterceptor for processing a UsernameToken from the SOAP -->
    <bean id="inbound-security" class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
        <constructor-arg>
            <map>
                <entry key="action" value="UsernameToken" />
                <!--entry key="passwordType" value="PasswordText"/ -->
                <entry key="passwordCallbackClass" value="server.ServerPasswordCallback" />
            </map>
        </constructor-arg>
    </bean>

    <jaxws:endpoint id="helloWorld" implementor="server.HelloWorldImpl"
        address="/HelloWorld">
        <jaxws:inInterceptors>
            <ref bean="logInBound" />
            <ref bean="inbound-security" />
        </jaxws:inInterceptors>
        <jaxws:outInterceptors>
            <ref bean="logOutBound" />
        </jaxws:outInterceptors>
    </jaxws:endpoint>
</beans>
科姆·奥格

CXF 3.0.0不适用于WSS4J 1.6.15。您需要改用WSS4J 2.0.0。

科尔姆

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

使用CXF和WSS4J创建信封签名

来自分类Dev

CXF 3.X和WSS4J 2.X中的CallbackHandler

来自分类Dev

SoapFault MustUnderstand标头,CXF WSS4J没有提供加密属性文件

来自分类Dev

JAX-WS CXF WSS4J在运行时添加证书以进行消息签名

来自分类Dev

CXF SOAP JAX-WS WSS4JInInterceptor更改名称空间并导致解组错误

来自分类Dev

WSS4j 1.5:如何跳过密码验证?

来自分类Dev

WSS4J中密钥库的可配置位置

来自分类Dev

如何使用wss4j库验证soap签名

来自分类Dev

如何使用wss4j库验证soap签名

来自分类Dev

CXF中的标头错误

来自分类Dev

带有Spring WS的WSS4J(用户/密码身份验证+ .cert)

来自分类Dev

如何使用 WSS4J 在 KeyInfo 元素中生成 X509Data 和 KeyValue

来自分类Dev

使用Apache CXF和CXF Maven插件在Eclipse Workspace中自动生成WSDL Java Stub

来自分类Dev

缺少cxf.xml?在Maven中失败,在Eclipse中工作

来自分类Dev

Maven和CXF:具有Web服务的abstractMethodError(getConduit)

来自分类Dev

Maven cxf-codegen-plugin并在wsdl中导入

来自分类Dev

Maven cxf-codegen-plugin不生成源

来自分类Dev

Maven中的CXF Web服务客户端生成失败

来自分类Dev

CXF代码生成Maven插件不工作了OpenJDK 11

来自分类Dev

缺少cxf.xml?在Maven中失败,在Eclipse中工作

来自分类Dev

Maven和CXF:带Web服务的abstractMethodError(getConduit)

来自分类Dev

Crawler4j-NoSuchMethod getOutgoingUrls()

来自分类Dev

403禁止将wss4jOutInterceptor与骆驼和cxf一起使用

来自分类Dev

NoSuchMethod错误Java但方法存在

来自分类Dev

发生错误时重复CXF请求

来自分类Dev

Apache CXF中的Web服务错误

来自分类Dev

与 CXF 客户端的链接错误

来自分类Dev

如何使用WSS4J拦截器以Web服务方法获取经过身份验证的用户

来自分类Dev

Apache CXF 和 Log4j2

Related 相关文章

  1. 1

    使用CXF和WSS4J创建信封签名

  2. 2

    CXF 3.X和WSS4J 2.X中的CallbackHandler

  3. 3

    SoapFault MustUnderstand标头,CXF WSS4J没有提供加密属性文件

  4. 4

    JAX-WS CXF WSS4J在运行时添加证书以进行消息签名

  5. 5

    CXF SOAP JAX-WS WSS4JInInterceptor更改名称空间并导致解组错误

  6. 6

    WSS4j 1.5:如何跳过密码验证?

  7. 7

    WSS4J中密钥库的可配置位置

  8. 8

    如何使用wss4j库验证soap签名

  9. 9

    如何使用wss4j库验证soap签名

  10. 10

    CXF中的标头错误

  11. 11

    带有Spring WS的WSS4J(用户/密码身份验证+ .cert)

  12. 12

    如何使用 WSS4J 在 KeyInfo 元素中生成 X509Data 和 KeyValue

  13. 13

    使用Apache CXF和CXF Maven插件在Eclipse Workspace中自动生成WSDL Java Stub

  14. 14

    缺少cxf.xml?在Maven中失败,在Eclipse中工作

  15. 15

    Maven和CXF:具有Web服务的abstractMethodError(getConduit)

  16. 16

    Maven cxf-codegen-plugin并在wsdl中导入

  17. 17

    Maven cxf-codegen-plugin不生成源

  18. 18

    Maven中的CXF Web服务客户端生成失败

  19. 19

    CXF代码生成Maven插件不工作了OpenJDK 11

  20. 20

    缺少cxf.xml?在Maven中失败,在Eclipse中工作

  21. 21

    Maven和CXF:带Web服务的abstractMethodError(getConduit)

  22. 22

    Crawler4j-NoSuchMethod getOutgoingUrls()

  23. 23

    403禁止将wss4jOutInterceptor与骆驼和cxf一起使用

  24. 24

    NoSuchMethod错误Java但方法存在

  25. 25

    发生错误时重复CXF请求

  26. 26

    Apache CXF中的Web服务错误

  27. 27

    与 CXF 客户端的链接错误

  28. 28

    如何使用WSS4J拦截器以Web服务方法获取经过身份验证的用户

  29. 29

    Apache CXF 和 Log4j2

热门标签

归档