AbstractMethodError Jersey javax.ws.rs

时间:2014-09-28 06:47:44

标签: java jersey weblogic jax-ws

我在部署Web应用程序时遇到以下异常。 使用weblogic 12c

<Sep 28, 2014 9:42:54 AM EEST> <Warning> <HTTP> <BEA-101162> <User defined listener com.app.Application failed: java.lang.AbstractMethodError: javax.ws.rs
uilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder;.
java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder;
        at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119)
        at org.glassfish.jersey.client.JerseyWebTarget.<init>(JerseyWebTarget.java:71)
        at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:177)
        at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:68)
        Truncated. see log file for complete stacktrace
>
Eyl 28, 2014 9:42:54 AM com.sun.xml.ws.transport.http.servlet.WSServletContextListener contextInitialized
INFO: WSSERVLET12: JAX-WS context listener initializing
Eyl 28, 2014 9:42:54 AM [com.sun.xml.ws.assembler.MetroConfigLoader]  <init>
SEVERE: MASM0001: Default configuration file [ metro-default.xml ] was not found
<Sep 28, 2014 9:42:54 AM EEST> <Error> <com.sun.metro.assembler> <BEA-000000> <MASM0001: Default configuration file [ metro-default.xml ] was not found>
Eyl 28, 2014 9:42:54 AM com.sun.xml.ws.transport.http.servlet.WSServletContextListener parseAdaptersAndCreateDelegate
SEVERE: WSSERVLET11: failed to parse runtime descriptor: java.lang.IllegalStateException: MASM0001: Default configuration file [ metro-default.xml ] was not found
java.lang.IllegalStateException: MASM0001: Default configuration file [ metro-default.xml ] was not found
        at com.sun.xml.ws.assembler.MetroConfigLoader.init(MetroConfigLoader.java:142)
        at com.sun.xml.ws.assembler.MetroConfigLoader.<init>(MetroConfigLoader.java:119)
        at com.sun.xml.ws.assembler.TubelineAssemblyController.getTubeCreators(TubelineAssemblyController.java:122)
        at com.sun.xml.ws.assembler.MetroTubelineAssembler.createServer(MetroTubelineAssembler.java:173)
        at com.sun.xml.ws.server.WSEndpointImpl.<init>(WSEndpointImpl.java:193)
        at com.sun.xml.ws.server.EndpointFactory.create(EndpointFactory.java:337)
        at com.sun.xml.ws.server.EndpointFactory.create(EndpointFactory.java:332)
        at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:164)
        at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:577)
        at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:560)
        at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parseAdapters(DeploymentDescriptorParser.java:303)
        at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parse(DeploymentDescriptorParser.java:179)
        at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.parseAdaptersAndCreateDelegate(WSServletContextListener.java:131)
        at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:152)
        at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:678)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
        at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
        at weblogic.servlet.internal.EventsManager.executeContextListener(EventsManager.java:243)
        at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:200)
        at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:185)
        at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1838)
        at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:2876)
        at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1661)
        at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:823)
        at weblogic.application.internal.ExtensibleModuleWrapper$StartStateChange.next(ExtensibleModuleWrapper.java:360)
        at weblogic.application.internal.ExtensibleModuleWrapper$StartStateChange.next(ExtensibleModuleWrapper.java:356)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
        at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:138)
        at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:216)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:211)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
        at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:73)
        at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:24)
        at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:729)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
        at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:258)
        at weblogic.application.internal.SingleModuleDeployment.activate(SingleModuleDeployment.java:48)
        at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:165)
        at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:80)

的pom.xml

 <dependencies>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.3.4</version>
        </dependency>
        <dependency>
            <groupId>javax.xml.ws</groupId>
            <artifactId>jaxws-api</artifactId>
            <version>2.2.8</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>jaxws-rt</artifactId>
            <version>2.2.7</version>
        </dependency>
        <dependency>
            <groupId>com.github.fernandospr</groupId>
            <artifactId>javapns-jdk16</artifactId>
            <version>2.2.1</version>
        </dependency>

        <dependency>
            <groupId>commons-discovery</groupId>
            <artifactId>commons-discovery</artifactId>
            <version>0.5</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.birt.runtime.3_7_1</groupId>
            <artifactId>javax.wsdl</artifactId>
            <version>1.5.1</version>
        </dependency>

        <dependency>
            <groupId>jivesoftware</groupId>
            <artifactId>smack</artifactId>
            <version>3.1.0</version>
        </dependency>

        <dependency>
            <groupId>jivesoftware</groupId>
            <artifactId>smackx</artifactId>
            <version>3.1.0</version>
        </dependency>

        <dependency>
            <groupId>com.notnoop.apns</groupId>
            <artifactId>apns</artifactId>
            <version>1.0.0.Beta4</version>
        </dependency>

        <dependency>
            <groupId>org.apache.axis</groupId>
            <artifactId>axis</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>com.github.fernandospr</groupId>
            <artifactId>javapns-jdk16</artifactId>
            <version>2.2.1</version>
        </dependency>

        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
            <version>2.0</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
            <version>2.9</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet-core</artifactId>
            <version>2.9</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.libphonenumber</groupId>
            <artifactId>libphonenumber</artifactId>
            <version>6.1</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>1.7.1</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.rpc</groupId>
            <artifactId>jaxrpc-impl</artifactId>
            <version>1.1.3_01</version>
        </dependency>
        <dependency>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jsp-2.1</artifactId>
            <version>6.0.0</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>3.0</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>ojdbc</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.2.0</version>
        </dependency>
        <dependency>
            <groupId>ojdbc</groupId>
            <artifactId>orai18n</artifactId>
            <version>11.2.0.2.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>c3p0</groupId>
            <artifactId>c3p0</artifactId>
            <version>0.9.1.2</version>
        </dependency>

        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>12.0</version>
        </dependency>
        <dependency>
            <groupId>org.snmp4j</groupId>
            <artifactId>snmp4j</artifactId>
            <version>1.10.1</version>
        </dependency>
        <dependency>
            <groupId>org.snmp4j</groupId>
            <artifactId>snmp4j-agent</artifactId>
            <version>1.3.1</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.16</version>
        </dependency>
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib</artifactId>
            <version>2.2</version>
        </dependency>

        <!-- Jersey + Spring -->
        <dependency>
            <groupId>com.sun.jersey.contribs</groupId>
            <artifactId>jersey-spring</artifactId>
            <version>1.17.1</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-web</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-beans</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-context</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>com.oracle.coherence</groupId>
            <artifactId>coherence</artifactId>
            <version>12.1.2-0-0</version>
        </dependency>


    </dependencies>

weblogic.xml中

<?xml version="1.0" encoding="UTF-8"?>

<wls:weblogic-web-app
xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app"
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/ejb-jar_3_0.xsd
http://xmlns.oracle.com/weblogic/weblogic-web-app
http://xmlns.oracle.com/weblogic/weblogic-web-app/1.2/weblogic-web-app.xsd">

    <wls:container-descriptor>
        <wls:prefer-application-packages>
            <wls:package-name>com.sun.jersey.*</wls:package-name>
            <wls:package-name>com.sun.research.ws.wadl.*</wls:package-name>
            <wls:package-name>com.sun.ws.rs.ext.*</wls:package-name>


            <wls:package-name>org.codehaus.jackson.*</wls:package-name>


            <wls:package-name>org.codehaus.jettison.*</wls:package-name>


            <wls:package-name>javax.ws.rs.*</wls:package-name>


            <wls:package-name>org.objectweb.asm.*</wls:package-name>
        </wls:prefer-application-packages>
    </wls:container-descriptor>
    <context-root>cont</context-root>
</wls:weblogic-web-app>

2 个答案:

答案 0 :(得分:1)

weblogic.xml文件中删除以下语句后,问题已解决。

 <wls:package-name>javax.ws.rs.*</wls:package-name> 

答案 1 :(得分:0)

来自javadocs:this error can only occur at run time if the definition of some class has incompatibly changed since the currently executing method was last compiledhttp://docs.oracle.com/javase/7/docs/api/java/lang/AbstractMethodError.html

验证构建解决方案的所有部分时所使用的所有JAR文件的版本是否与运行时使用的版本相匹配。