Forum Stats

  • 3,741,014 Users
  • 2,248,356 Discussions


java.lang.NoClassDefFoundError: com/sun/xml/ws/developer/WSBindingProvider

bdzevel Member Posts: 45


I was seeing the following error:


I did some googling and found that I needed to specify the endorsed directory java option:

java -Djava.endorsed.dirs="/mypathtoendorseddir" -jar myjar.jar

This directory contained my jaxws-rt.jar file. It was kind of tricky but I was eventually able to get past this error. Now I'm stuck with the following nonsensical error:

java.lang.NoClassDefFoundError: com/sun/xml/ws/developer/WSBindingProvider

This error occurs when I try to cast a binding as that (a few lines down from the original "java/lang/String" error). I've downloaded the latest jaxws-rt.jar, but no luck. How is it unable to find this WSBindingProvider class when my project compiles and builds a jar file successfully? Granted, the code is being run on another machine (I'm building locally obviously), but the jaxws-rt.jar file is THERE. I even modified the class-path entry in the jar manifest to include "endorseddir/jaxws-rt.jar" (previously, I had this in a "lib" folder and was just referencing "jaxws-rt.jar" in the class-path).

Again, it's able to resolve the WSBindingProvider class from the code, and when I go to the definition it throws me into jaxws-rt.jar (without any sources of course, but it does understand that the class is in there).

I'm lost. Any ideas?

P.S. After pulling my hair out for a while trying to figure this out, I figured I'd just take all the references to WSBindingProvider out of my code and replace it with BindingProvider. Unfortunately, BindingProvider doesn't expose a setOutboundHeaders function which is used in certain parts of our code. BindingProvider, by the way, properly resolves.


  • bdzevel
    bdzevel Member Posts: 45
    edited Dec 13, 2013 5:05PM

    Well, now I'm pulling my hair out even more because I can't get it to resolve anything in jaxws-rt.jar at runtime. Note: compile-time still works FINE.

    I was messing with classpaths and stuff (and the endorsed dirs option of course) and it was "working" to the extent I had posted before, but then I kept playing with it and at some point I said, this isn't working and I need to reset all this stuff back to the way it was.

    ... so I did that. And now it won't resolve "PolicyException:"

    java.lang.NoClassDefFoundError: com/sun/xml/ws/policy/PolicyException

    This doesn't mean anything to you guys I bet, but that happens when it FIRST gets inside the web service code, which references PolicyException (doesn't even use it at that point.. I'm assuming the import is screwing it up when it's in the constructor). So now it won't resolve at all. Before, it was getting past this point and telling me the "method not found" error on the next line or this same error for WSBindingProvider two lines down, when it's actually being used. AWESOME.

    I downloaded the latest jaxws-rt.jar and all its dependencies, shoved that into my lib folder, and set the endorsed dir to that folder (There's kind of a web of dependencies here. jaxws-rt.jar expects all its dependencies to be in the same folder, it seems, so I don't know how it was "working" before when I just copied jaxws-rt.jar into my separate endorsed dir - but I can't move all of those files to endorsed because I need them in my project (which expects them to be in the lib folder)). What happened? It went back to my original "String" error (first error in the first post), which means it's not getting endorsed at all from that location.

    What a mess.

    Can someone tell me what the heck I'm supposed to do with this jar file?

This discussion has been closed.