Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@Webservice annotation exception on weblogic

I am trying to run my application which contain JAX WS (2.1) Webservice using JDeveloper 11g R2(11.1.2.3.0) in JDK 1.6.0_31-b05. The error is coming from @WebService annotation present on the class.
When I am running the application, I am getting below error,

java.lang.IllegalArgumentException: Argument(s) "type" can't be null.
  at com.sun.xml.bind.api.TypeReference.<init>(TypeReference.java:89)
  at com.sun.xml.ws.model.RuntimeModeler.processDocWrappedMethod(RuntimeModeler.java:758)
  at com.sun.xml.ws.model.RuntimeModeler.processMethod(RuntimeModeler.java:678)
  at com.sun.xml.ws.model.RuntimeModeler.processClass(RuntimeModeler.java:428)
  at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:277)
  at com.sun.xml.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:363)
  at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:202)
  at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:496)
  at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:539)
  at weblogic.wsee.jaxws.JAXWSDeployedServlet.getEndpoint(JAXWSDeployedServlet.java:183)

It seems that embedded Web Logic is using the internal libraries instead of provided one from JDK. The classes RuntimeModeler or TypeReference are present in JDK rt.jar starts with package com.sun.xml.ws.internal. Weblogic is picking these classes from glassfish.jaxb_1.0.0.0_2-1-12.jar & glassfish.jaxws.rt_1.2.0.0_2-1-5.jar, but these jars are not part of my application.

  1. I have already used weblogic.xml with below tag,

    <prefer-web-inf-classes>true</prefer-web-inf-classes>
    
  2. I tried adding jaxws-api.jar & jws-api.jar in DefaultDomain/lib directory, but that didn't work

Any clue how to resolve this exception or how to force weblogic to use jdk runtime classes? The same application work properly on stand alone weblogic.

like image 621
Ahmed KARABIBENE Avatar asked Nov 04 '22 06:11

Ahmed KARABIBENE


1 Answers

I had the same problem and found the answer here: http://www.intropro.com/resources/blog/66-argument-s-type-can-t-be-null

In short - the problem appears because you have jaxb-impl in you classpath which overrides WebLogics own jaxb, You may not explicitly refer to this dependency from your pom.xml, but some of your other dependencies do. In my case I had apache-cxf as maven dependency and it had jaxb 2.1.13 as sub-dependency with scope "compile". All I had to do is exclude this apaches jaxb and add my own dependency with scope "provided" to explicitly use WebLogics jaxb.

in pom.xml it looked like this:

<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-frontend-jaxws</artifactId>
    <version>2.7.2</version>
    <exclusions>
        <exclusion>
            <artifactId>jaxb-impl</artifactId>
            <groupId>com.sun.xml.bind</groupId>
        </exclusion>
    </exclusions>
</dependency>

<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-impl</artifactId>
    <scope>provided</scope>
    <version>2.1.13</version>
</dependency>

You can use eclipses "Dependency Hierarchy" tab in pom.xml view or simply command line "mvn dependency:tree" to find out how jaxb-impl made it to your classpath.

like image 178
troy Avatar answered Nov 11 '22 17:11

troy