0

I developed a webservice and deployed it to websphere 7.0 and developed a dynamic dispatch client using JAX-WS APIs which also runs on same application server. I get error at the following line:

Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE);
Error:
Caused by: java.lang.NoSuchMethodError: com/sun/istack/logging/Logger.getLogger(Ljava/lang/Class;)Lcom/sun/istack/logging/Logger;
at com.sun.xml.ws.api.config.management.policy.ManagementAssertion.<clinit>(ManagementAssertion.java:87)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:167)
at com.sun.xml.ws.server.MonitorBase.createManagedObjectManager(MonitorBase.java:177)
at com.sun.xml.ws.client.Stub.<init>(Stub.java:196)
at com.sun.xml.ws.client.Stub.<init>(Stub.java:174)
at com.sun.xml.ws.client.dispatch.DispatchImpl.<init>(DispatchImpl.java:129)
at com.sun.xml.ws.client.dispatch.SOAPMessageDispatch.<init>(SOAPMessageDispatch.java:77)
at com.sun.xml.ws.api.pipe.Stubs.createSAAJDispatch(Stubs.java:143)
at com.sun.xml.ws.api.pipe.Stubs.createDispatch(Stubs.java:264)
at com.sun.xml.ws.client.WSServiceDelegate.createDispatch(WSServiceDelegate.java:390)
at com.sun.xml.ws.client.WSServiceDelegate.createDispatch(WSServiceDelegate.java:401)
at com.sun.xml.ws.client.WSServiceDelegate.createDispatch(WSServiceDelegate.java:383)
at javax.xml.ws.Service.createDispatch(Service.java:336) 

I included the following dependency.

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

I also tried adding policy dependency (versions - 2.2 and 2.2.1)

<dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>policy</artifactId>
        <version>2.2.1</version>
</dependency>

Any ideas on what more dependencies I need to add?

Mizipzor
  • 51,151
  • 22
  • 97
  • 138
Susmitha Pandi
  • 155
  • 1
  • 3
  • 11
  • if you're stuck with Netbeans 8 and having issues like this, and are trying to figure out where the libraries are loaded from, I found this post handy (Netbeans adds libraries to classpath behind the scenes): https://stackoverflow.com/questions/6207190/how-do-i-reference-libraries-in-netbeans – hello_earth Jan 28 '21 at 10:48

4 Answers4

1

The jaxb-impl jar (2.2) contains the same logging classes as the istack-commons-runtime jar.

Add the following exclusions in order to correct the version mismatch:

<dependency>
    <groupId>com.sun.xml.ws</groupId>
    <artifactId>jaxws-rt</artifactId>
    <version>2.2</version>
    <exclusions>
        <exclusion>
            <artifactId>istack-commons-runtime</artifactId>
            <groupId>com.sun.istack</groupId>
        </exclusion>
    </exclusions>
</dependency>
Marco
  • 8,958
  • 1
  • 36
  • 56
0

I believe that JAX-WS 2.1 is already built into Java 6, so you shouldn't need to bundle it with your application (assuming you're using Java 6, that is). If you try, you're likely to get classloading errors like this one.

Try removing all of the jax-ws JARs from the app, including jaxws-api.

skaffman
  • 398,947
  • 96
  • 818
  • 769
0

The problem is the fact that there are likely multiple occurrences of this class - Logger (com.sun.istack.logging.Logger) in the class path.

When the code is compiled it had access to this Logger class which is different from what is found by the run time.

Two possibilities:

  1. There in only one copy of Logger in run time and it does not match what was used during compilation.

  2. There are multiple copies of this Logger and the class loader finds the incorrect copy first hence reports this error.

Check the JARs that contains this file.

It is typically found in jaxb-osgi.jar.

HTH Manglu

Siddharth
  • 9,349
  • 16
  • 86
  • 148
Manglu
  • 10,744
  • 12
  • 44
  • 57
0

I had the same issue and the problem was related with jaxb version compatibility. Apache Camel camel-core dependency was importing jaxb-core and jaxb-impl. Removing them from the dependency from jaxws-rt solved the problem.

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-core</artifactId>
    <version>${org.apache.camel.version}</version>
    <exclusions>
        <exclusion>
             <groupId>com.sun.xml.bind</groupId>
             <artifactId>jaxb-core</artifactId>
         </exclusion>
         <exclusion>
             <groupId>com.sun.xml.bind</groupId>
             <artifactId>jaxb-impl</artifactId>
         </exclusion>
    </exclusions>
</dependency>
David Buck
  • 3,752
  • 35
  • 31
  • 35