Problem registering custom ProtocolHandler [message #460081] |
Wed, 13 December 2006 04:14  |
Eclipse User |
|
|
|
Hello everyone
I'm trying to register a custom protocol handler with an eclipse rcp bundle
using the approach given in Chapter 11 of the OSGi Specification V4. The new
protocol handler should connect to a password protected http server using an
url string like "<username>:<password>@someurl". Therefore I define the new
protocol ahttp using the following URLStreamHandler.
public class ProtectedHttpURLStreamHandler
extends AbstractURLStreamHandlerService
{
public URLConnection openConnection (
URL url) throws IOException
{
// TODO: create a custom URLConnection which handles the following
URLConnection conn = null;
String user = null;
String passwd = null;
String enc = null;
if (url.getUserInfo () != null)
{
user = url.getUserInfo ().substring (0, url.getUserInfo ().indexOf
(":"));
passwd = url.getUserInfo ().substring (url.getUserInfo ().indexOf (":") +
1);
enc = new BASE64Encoder ().encode ((user + ":" + passwd).getBytes ());
}
String host = url.getHost ();
url = new URL ("http", host , url.getPath ());
System.out.println (url.toString ());
conn = url.openConnection ();
if (enc != null)
{
conn.setRequestProperty ("Authorization", "Basic " + enc);
}
//System.getProperties().put( "http.proxyAuthToken", enc );
return conn; }
}
In the activator of the rcp application I'm registering the protocol with
the following code
public void start(BundleContext context) throws Exception {
super.start(context);
Hashtable<String, String[]> properties = new Hashtable<String,
String[]> ();
properties.put (URLConstants.URL_HANDLER_PROTOCOL, new String[] {
"ahttp" });
context.registerService (URLStreamHandlerService.class.getName (),
new ProtectedHttpURLStreamHandler(), properties);
}
I need the custom protocol to connect to a password protected http codebase
for Jini (RMI). When I start the programm he first seems to find the custom
handler as I can see from debugging. He calls it several times. But the
suddenly I get the following exception. Important to me seems the
java.net.MalformedURLException: unknown protocol: ahttp. So suddenly he
seems to not find the handler anymore. The class the exception is coming
from is in another bundle so may there is a problem with the classloaders.
java.rmi.ServerException: RemoteException in server thread; nested exception
is:
java.rmi.UnmarshalException: unmarshalling method/arguments; nested
exception is:
java.net.MalformedURLException: unknown protocol: ahttp
at
net.jini.jeri.BasicInvocationDispatcher.dispatch(BasicInvoca tionDispatcher.java:644)
at
com.sun.jini.jeri.internal.runtime.ObjectTable$6.run(ObjectT able.java:597)
at net.jini.export.ServerContext.doWithServerContext(ServerCont ext.java:103)
at
com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispat ch0(ObjectTable.java:595)
at
com.sun.jini.jeri.internal.runtime.ObjectTable$Target.access $700(ObjectTable.java:212)
at
com.sun.jini.jeri.internal.runtime.ObjectTable$5.run(ObjectT able.java:568)
at
com.sun.jini.start.AggregatePolicyProvider$6.run(AggregatePo licyProvider.java:527)
at java.security.AccessController.doPrivileged(Native Method)
at
com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispat ch(ObjectTable.java:565)
at
com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispat ch(ObjectTable.java:540)
at
com.sun.jini.jeri.internal.runtime.ObjectTable$RD.dispatch(O bjectTable.java:778)
at
net.jini.jeri.connection.ServerConnectionManager$Dispatcher. dispatch(ServerConnectionManager.java:148)
at com.sun.jini.jeri.internal.mux.MuxServer$2.run(MuxServer.jav a:244)
at
com.sun.jini.start.AggregatePolicyProvider$5.run(AggregatePo licyProvider.java:513)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.jini.jeri.internal.mux.MuxServer$1.run(MuxServer.jav a:241)
at com.sun.jini.thread.ThreadPool$Worker.run(ThreadPool.java:13 6)
at java.lang.Thread.run(Thread.java:595)
at
com.sun.jini.jeri.internal.runtime.Util.__________EXCEPTION_ RECEIVED_FROM_SERVER__________(Util.java:108)
at
com.sun.jini.jeri.internal.runtime.Util.exceptionReceivedFro mServer(Util.java:101)
at
net.jini.jeri.BasicInvocationHandler.unmarshalThrow(BasicInv ocationHandler.java:1303)
at
net.jini.jeri.BasicInvocationHandler.invokeRemoteMethodOnce( BasicInvocationHandler.java:832)
at
net.jini.jeri.BasicInvocationHandler.invokeRemoteMethod(Basi cInvocationHandler.java:659)
at
net.jini.jeri.BasicInvocationHandler.invoke(BasicInvocationH andler.java:528)
at com.sun.jini.reggie.$Proxy0.lookup(Unknown Source)
at com.sun.jini.reggie.RegistrarProxy.lookup(RegistrarProxy.jav a:112)
at org.ac.computegrid.utils.ServiceFinder.discovered(ServiceFin der.java:131)
at net.jini.discovery.LookupDiscovery$1.run(LookupDiscovery.jav a:977)
at java.security.AccessController.doPrivileged(Native Method)
at net.jini.discovery.LookupDiscovery$Notifier.run(LookupDiscov ery.java:923)
Caused by: java.rmi.UnmarshalException: unmarshalling method/arguments;
nested exception is:
java.net.MalformedURLException: unknown protocol: ahttp
at
net.jini.jeri.BasicInvocationDispatcher.dispatch(BasicInvoca tionDispatcher.java:619)
at
com.sun.jini.jeri.internal.runtime.ObjectTable$6.run(ObjectT able.java:597)
at net.jini.export.ServerContext.doWithServerContext(ServerCont ext.java:103)
at
com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispat ch0(ObjectTable.java:595)
at
com.sun.jini.jeri.internal.runtime.ObjectTable$Target.access $700(ObjectTable.java:212)
at
com.sun.jini.jeri.internal.runtime.ObjectTable$5.run(ObjectT able.java:568)
at
com.sun.jini.start.AggregatePolicyProvider$6.run(AggregatePo licyProvider.java:527)
at java.security.AccessController.doPrivileged(Native Method)
at
com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispat ch(ObjectTable.java:565)
at
com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispat ch(ObjectTable.java:540)
at
com.sun.jini.jeri.internal.runtime.ObjectTable$RD.dispatch(O bjectTable.java:778)
at
net.jini.jeri.connection.ServerConnectionManager$Dispatcher. dispatch(ServerConnectionManager.java:148)
at com.sun.jini.jeri.internal.mux.MuxServer$2.run(MuxServer.jav a:244)
at
com.sun.jini.start.AggregatePolicyProvider$5.run(AggregatePo licyProvider.java:513)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.jini.jeri.internal.mux.MuxServer$1.run(MuxServer.jav a:241)
at com.sun.jini.thread.ThreadPool$Worker.run(ThreadPool.java:13 6)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.net.MalformedURLException: unknown protocol: ahttp
at java.net.URL.<init>(URL.java:574)
at java.net.URL.<init>(URL.java:464)
at java.net.URL.<init>(URL.java:413)
at
net.jini.loader.pref.PreferredClassProvider.pathToURLs(Prefe rredClassProvider.java:1409)
at
net.jini.loader.pref.PreferredClassProvider.loadClass(Prefer redClassProvider.java:483)
at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java :247)
at net.jini.loader.ClassLoading.loadClass(ClassLoading.java:138 )
at net.jini.io.MarshalInputStream.resolveClass(MarshalInputStre am.java:296)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream .java:1544)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.ja va:1466)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStre am.java:1699)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java :1305)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java: 348)
at com.sun.jini.jeri.internal.runtime.Util.unmarshalValue(Util. java:221)
at
net.jini.jeri.BasicInvocationDispatcher.unmarshalArguments(B asicInvocationDispatcher.java:1049)
at
net.jini.jeri.BasicInvocationDispatcher.dispatch(BasicInvoca tionDispatcher.java:599)
.... 17 more
I would be grateful if anybody could point me to what I'm doing wrong.
Thanks in advance for any help.
Christian Hager
|
|
|
|
Powered by
FUDForum. Page generated in 0.03441 seconds