问题
I have developed a Web Service Client to connect with a web service deployed on Weblogic 10.3. When trying to instantiate a client object always get the same exception
java.lang.UnsupportedOperationException: Method not implemented.
at java.net.URLStreamHandler.openConnection(URLStreamHandler.java:80)
at java.net.URL.openConnection(URL.java:992)
Looking on the method implementation from URLStreamHandler I found it just throw the Exception
protected URLConnection openConnection(URL u, Proxy p) throws IOException {
throw new UnsupportedOperationException("Method not implemented.");
}
I suppose WebLogic needs you to pass a library with a child class of UrlStreamHandler providing an openConnection implementation but not sure exactly which it should be.
回答1:
Some other library in your project has probably registered an URLStreamHandler implementation that does not implement the openConnection method with the proxy parameter.
The default URLStreamHandler class is sun.net.www.protocol.http.Handler located in rt.jar.
In my case I used jcifs library which registered its own http Handler but did not implement the openConnection(URL, Proxy) method.
So, you should provide a Handler with an implementation of openConnection(URL, Proxy), or you should use the default Handler if possible.
Note: In my case, the url.openConnection method was called from com.sun.xml.internal.ws.api.EndpointAddress (rt.jar). In java 6, this throws UnsupportedOperationException. In java 7, this exception is catched in this EndpointAddress class and then url.openConnection is called without using a proxy. So updating to java 7 should also fix this problem.
回答2:
I got this exception when using an old WL client that did not override openConnection(URL u, Proxy p), and the weblogic handler sometimes was loaded first. Solution was to upgrade to newer WL version, with had that method overrided.
来源:https://stackoverflow.com/questions/19009237/method-not-implemented-when-calling-a-webservice-on-weblogic-10-3