java.lang.NoSuchFieldError:反思

Arthurfnsc

我正在使用CXF创建一个项目,并以一定的安全性使用MTOM(我不知道该信息是否相关)。

当我尝试初始化服务器时,我收到了该错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'example': Invocation of init method failed; nested exception is java.lang.NoSuchFieldError: REFLECTION

这是我的cxf-servlet.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee" 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">

<jaxws:endpoint 
    id="example" 
    address="/example"
    implementor="br.com.arthur.services.ExampleService">

    <!-- Uncomment only if using WS-SecurityPolicy -->
    <jaxws:properties>
        <entry key="mtom-enabled" value="true" />
        <entry key="ws-security.callback-handler" value-ref="myPasswordCallback" />
    </jaxws:properties>

    <!-- Uncomment only if using standard WSS4J interceptors -->
    <!--jaxws:inInterceptors> <bean class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor"> 
        <constructor-arg> <map> <entry key="action" value="UsernameToken"/> <entry 
        key="passwordType" value="PasswordText"/> <entry key="passwordCallbackRef" 
        value-ref="myPasswordCallback"/> </map> </constructor-arg> </bean> </jaxws:inInterceptors -->
</jaxws:endpoint>

<bean id="myPasswordCallback" class="br.com.arthur.services.ServerPasswordCallback" />
</beans>

这是我的web.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">

<display-name>Sample web service provider</display-name>
<listener>
    <listener-class>
          org.springframework.web.context.ContextLoaderListener
    </listener-class>
</listener>
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        classpath:META-INF/cxf/cxf.xml
    </param-value>
</context-param>
<servlet>
    <servlet-name>WebServicePort</servlet-name>
    <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>WebServicePort</servlet-name>
    <url-pattern>/services/*</url-pattern>
</servlet-mapping>
<session-config>
    <session-timeout>60</session-timeout>
</session-config>

<security-constraint>
    <web-resource-collection>
        <web-resource-name>restricted web services</web-resource-name>
        <url-pattern>/*</url-pattern>
        <http-method>GET</http-method>
        <http-method>POST</http-method>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>
</web-app>

这是我的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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.arthur</groupId>
<artifactId>security-mtom</artifactId>
<packaging>war</packaging>
<version>1.0.0</version>

<properties>
    <cxf.version>3.0.1</cxf.version>
    <jdk.version>1.7</jdk.version>
    <maven-compiler.version>3.1</maven-compiler.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <spring.version>4.1.0.RELEASE</spring.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-core</artifactId>
        <version>2.7.12</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
        <version>${cxf.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-ws-security</artifactId>
        <version>${cxf.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http</artifactId>
        <version>${cxf.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-common-utilities</artifactId>
        <version>2.5.11</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${spring.version}</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven-compiler.version}</version>
            <configuration>
                <source>${jdk.version}</source>
                <target>${jdk.version}</target>
                <encoding></encoding>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>${cxf.version}</version>
            <executions>
                <execution>
                    <id>generate-sources</id>
                    <phase>generate-sources</phase>
                    <configuration>
                        <sourceRoot>${project.basedir}/src/main/java</sourceRoot>
                        <wsdlOptions>
                            <wsdlOption>
                                <wsdl>${project.basedir}/src/main/resources/wsdl/example.wsdl</wsdl>
                                <wsdlLocation>classpath:wsdl/example.wsdl</wsdlLocation>
                            </wsdlOption>
                        </wsdlOptions>
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
</project>

我尝试执行这两个教程http://web-gmazza.rhcloud.com/blog/entry/cxf-usernametoken-profilehttp://thenonsensetechlogs.wordpress.com/2011/05/09/mtom-using-apache- cxf和maven /

路易·奎勒

您在cxf-rt-frontend-jaxws和cxf-common-utilities库之间存在冲突。两者都提供com.sun.xml.bind作为它们的依存关系,这是导致问题的原因。因此,您应该从cxf-common-utilities中排除com.sun.xml.bind:jaxb-impl或删除对cxf-common-utilities的依赖。

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

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

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

抖动错误:java.lang.NoSuchFieldError的PREFER_HIGHEST_OR_REMOTE_VERSION_NO_FORCE_STAGING

java.lang.NoSuchFieldError的:ACCEPT_CASE_INSENSITIVE_VALUES

“java.lang.NoSuchFieldError的:超级”异常 - 错误的编译器?

带有弹性搜索的Spring Boot导致java.lang.NoSuchFieldError:IGNORE_DEPRECATIONS

HTTPClient示例-线程“主”中的异常java.lang.NoSuchFieldError:INSTANCE

线程“主”中的异常java.lang.NoSuchFieldError:TRACE

春季:java.lang.NoSuchFieldError:IMPORT_BEAN_NAME_GENERATOR

Spring 3.1 entityManagerFactory java.lang.NoSuchFieldError:NULL错误

NoSuchFieldError Java

java.lang.NoSuchFieldError:INSTANCE

响应式Spring Boot-java.lang.NoSuchFieldError:DEFAULT_SHUTDOWN_QUIET_PERIOD

java.lang.NoSuchFieldError:默认

线程“主”中的异常java.lang.NoSuchFieldError:JAVA_VENDOR

Eclipse无法启动:java.lang.NoSuchFieldError:url

java.lang.NoSuchFieldError:来自Linux终端的带有twilio的DEF_CONTENT_CHARSET

更改类后java.lang.NoSuchFieldError

JSON解析器-java.lang.NoSuchFieldError:defaultReader

Proguard应用程式当机(造成原因:java.lang.NoSuchFieldError:否“ Lcom / facebook / jni / HybridData)

如何解决此错误:java.lang.NoSuchFieldError:UTF_32BE?

AWS EMR客户端错误:java.lang.NoSuchFieldError:SIGNING_REGION

适用于ssm的aws Java sdk提供了java.lang.NoSuchFieldError:SIGNING_REGION

JPA:QUERY DSL错误:java.lang.NoSuchFieldError:LIKE_IC

NullnessChecker错误:java.lang.NoSuchFieldError:释放

ScalaFx MouseEvent:java.lang.NoSuchFieldError:返回

使用ScalaTest时出现java.lang.NoSuchFieldError

正在创建CA ...意外错误java.lang.NoSuchFieldError:BasicConstraints

java.lang.NoSuchFieldError:IBM_JAVA

java.lang.NoSuchFieldError:Apache HttpComonents和Wildfly中的实例

HttpClientBuilder-java.lang.NoSuchFieldError:INSTANCE