Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Problem registering custom ProtocolHandler
Problem registering custom ProtocolHandler [message #78931] Wed, 13 December 2006 14:40 Go to next message
Eclipse UserFriend
Originally posted by: newslists.analytic-company.com

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
Re: Problem registering custom ProtocolHandler [message #78961 is a reply to message #78931] Thu, 14 December 2006 01:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: skaegi.sympatico.ca

Hi Christian,

Can you tell a bit more about the environment you're running under.
Also, if you can duplicate the problem in the debugger could you set a break
point on "java.net.MalformedURLException" to see if we can narrow down where
the exception is getting thrown from.

-Simon

"Christian Hager" <newslists@analytic-company.com> wrote in message
news:elp3cg$lmo$1@utils.eclipse.org...
> 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.j
ava: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.jav
a:527)
> at java.security.AccessController.doPrivileged(Native Method)
> at
>
com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispat ch(ObjectTable.j
ava:565)
> at
>
com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispat ch(ObjectTable.j
ava:540)
> at
>
com.sun.jini.jeri.internal.runtime.ObjectTable$RD.dispatch(O bjectTable.java:
778)
> at
>
net.jini.jeri.connection.ServerConnectionManager$Dispatcher. dispatch(ServerC
onnectionManager.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.jav
a: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_SE
RVER__________(Util.java:108)
> at
>
com.sun.jini.jeri.internal.runtime.Util.exceptionReceivedFro mServer(Util.jav
a:101)
> at
>
net.jini.jeri.BasicInvocationHandler.unmarshalThrow(BasicInv ocationHandler.j
ava:1303)
> at
>
net.jini.jeri.BasicInvocationHandler.invokeRemoteMethodOnce( BasicInvocationH
andler.java:832)
> at
>
net.jini.jeri.BasicInvocationHandler.invokeRemoteMethod(Basi cInvocationHandl
er.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.j
ava: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.jav
a:527)
> at java.security.AccessController.doPrivileged(Native Method)
> at
>
com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispat ch(ObjectTable.j
ava:565)
> at
>
com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispat ch(ObjectTable.j
ava:540)
> at
>
com.sun.jini.jeri.internal.runtime.ObjectTable$RD.dispatch(O bjectTable.java:
778)
> at
>
net.jini.jeri.connection.ServerConnectionManager$Dispatcher. dispatch(ServerC
onnectionManager.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.jav
a: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 rredClassProvide
r.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 asicInvocationDi
spatcher.java:1049)
> at
>
net.jini.jeri.BasicInvocationDispatcher.dispatch(BasicInvoca tionDispatcher.j
ava: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
>
>
Re: Problem registering custom ProtocolHandler [message #79037 is a reply to message #78961] Thu, 14 December 2006 09:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: newslists.analytic-company.com

Hi,

Ok some more to the environment. My System is a Win XP Pro running Java
1.5.0_08. My Application is consists of an Eclipse 3.2.0 RCP Plugin and some
additional Equinox Bundles. And I'm running Jini 2.1 with the Outrigger
JavaSpace implementation.

What I wan't to reach is that Jini uses a password protected Apache2 as
codebase. On the Jini newsgroup I found out that I have to register a custom
URLHandler to handle the login data because the standard Java URL
implementation doesn't support urls like http://user:pass@someserver.

At the beginning the Application stops two times on a breakpoint in my
custom handler. But then I get the Exception thrown from where I try to
retrieve the JavaSpace.

public void discovered (
DiscoveryEvent anEvent)
{
synchronized (this)
{
if (proxy != null)
return;
}
ServiceRegistrar[] myRegs = anEvent.getRegistrars ();
for (int i = 0; i < myRegs.length; i++)
{
ServiceRegistrar myReg = myRegs[i];
Object myProxy = null;
try
{
myProxy = myReg.lookup (serviceTemplate);
if (myProxy != null)
{
signalGotProxy (myProxy);
break;
}
}
catch (RemoteException anRE)
{
System.err.println ("ServiceRegistrar barfed");
anRE.printStackTrace (System.err);
}
}
}

When I register the new protocol in one bundle is it then also available in
all other bundles of the application?




"Simon Kaegi" <skaegi@sympatico.ca> schrieb im Newsbeitrag
news:elq97v$70l$1@utils.eclipse.org...
> Hi Christian,
>
> Can you tell a bit more about the environment you're running under.
> Also, if you can duplicate the problem in the debugger could you set a
> break
> point on "java.net.MalformedURLException" to see if we can narrow down
> where
> the exception is getting thrown from.
>
> -Simon
>
> "Christian Hager" <newslists@analytic-company.com> wrote in message
> news:elp3cg$lmo$1@utils.eclipse.org...
>> 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.j
> ava: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.jav
> a:527)
>> at java.security.AccessController.doPrivileged(Native Method)
>> at
>>
> com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispat ch(ObjectTable.j
> ava:565)
>> at
>>
> com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispat ch(ObjectTable.j
> ava:540)
>> at
>>
> com.sun.jini.jeri.internal.runtime.ObjectTable$RD.dispatch(O bjectTable.java:
> 778)
>> at
>>
> net.jini.jeri.connection.ServerConnectionManager$Dispatcher. dispatch(ServerC
> onnectionManager.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.jav
> a: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_SE
> RVER__________(Util.java:108)
>> at
>>
> com.sun.jini.jeri.internal.runtime.Util.exceptionReceivedFro mServer(Util.jav
> a:101)
>> at
>>
> net.jini.jeri.BasicInvocationHandler.unmarshalThrow(BasicInv ocationHandler.j
> ava:1303)
>> at
>>
> net.jini.jeri.BasicInvocationHandler.invokeRemoteMethodOnce( BasicInvocationH
> andler.java:832)
>> at
>>
> net.jini.jeri.BasicInvocationHandler.invokeRemoteMethod(Basi cInvocationHandl
> er.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.j
> ava: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.jav
> a:527)
>> at java.security.AccessController.doPrivileged(Native Method)
>> at
>>
> com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispat ch(ObjectTable.j
> ava:565)
>> at
>>
> com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispat ch(ObjectTable.j
> ava:540)
>> at
>>
> com.sun.jini.jeri.internal.runtime.ObjectTable$RD.dispatch(O bjectTable.java:
> 778)
>> at
>>
> net.jini.jeri.connection.ServerConnectionManager$Dispatcher. dispatch(ServerC
> onnectionManager.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.jav
> a: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 rredClassProvide
> r.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 asicInvocationDi
> spatcher.java:1049)
>> at
>>
> net.jini.jeri.BasicInvocationDispatcher.dispatch(BasicInvoca tionDispatcher.j
> ava: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
>>
>>
>
>
Re: Problem registering custom ProtocolHandler [message #79260 is a reply to message #79037] Fri, 15 December 2006 21:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: skaegi.sympatico.ca

Hi Christian,

> When I register the new protocol in one bundle is it then also available
in
> all other bundles of the application?

Yes. The OSGi framework will set the URLStreamHandlerFactory and so for your
use-case the new protocol is available when creating URLs across the whole
VM (e.g. code inside or outside bundles).

Did you have any luck tracking down exactly where the
"java.net.MalformedURLException" was thrown.
Are you running outrigger in the same process? I'm wondering if it's
possible that we're seeing the exception from another process?

Some other good places to stick some breakpoints:
org.eclipse.osgi.framework.internal.protocol.StreamHandlerFa ctory.createURLS
treamHandler(...)
-- let you walk through the protocol discovery step

org.eclipse.osgi.framework.internal.protocol.NullURLStreamHa ndlerService.ope
nConnection(...)
-- to check if your protocol has been unregistered (in which case your
URLStreamHandlerService is replaced with the "null" implementation)

HTH
-Simon

"Christian Hager" <newslists@analytic-company.com> wrote in message
news:elr771$fd3$1@utils.eclipse.org...
> Hi,
>
> Ok some more to the environment. My System is a Win XP Pro running Java
> 1.5.0_08. My Application is consists of an Eclipse 3.2.0 RCP Plugin and
some
> additional Equinox Bundles. And I'm running Jini 2.1 with the Outrigger
> JavaSpace implementation.
>
> What I wan't to reach is that Jini uses a password protected Apache2 as
> codebase. On the Jini newsgroup I found out that I have to register a
custom
> URLHandler to handle the login data because the standard Java URL
> implementation doesn't support urls like http://user:pass@someserver.
>
> At the beginning the Application stops two times on a breakpoint in my
> custom handler. But then I get the Exception thrown from where I try to
> retrieve the JavaSpace.
>
> public void discovered (
> DiscoveryEvent anEvent)
> {
> synchronized (this)
> {
> if (proxy != null)
> return;
> }
> ServiceRegistrar[] myRegs = anEvent.getRegistrars ();
> for (int i = 0; i < myRegs.length; i++)
> {
> ServiceRegistrar myReg = myRegs[i];
> Object myProxy = null;
> try
> {
> myProxy = myReg.lookup (serviceTemplate);
> if (myProxy != null)
> {
> signalGotProxy (myProxy);
> break;
> }
> }
> catch (RemoteException anRE)
> {
> System.err.println ("ServiceRegistrar barfed");
> anRE.printStackTrace (System.err);
> }
> }
> }
>
> When I register the new protocol in one bundle is it then also available
in
> all other bundles of the application?
>
>
>
>
> "Simon Kaegi" <skaegi@sympatico.ca> schrieb im Newsbeitrag
> news:elq97v$70l$1@utils.eclipse.org...
> > Hi Christian,
> >
> > Can you tell a bit more about the environment you're running under.
> > Also, if you can duplicate the problem in the debugger could you set a
> > break
> > point on "java.net.MalformedURLException" to see if we can narrow down
> > where
> > the exception is getting thrown from.
> >
> > -Simon
> >
> > "Christian Hager" <newslists@analytic-company.com> wrote in message
> > news:elp3cg$lmo$1@utils.eclipse.org...
> >> 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.j
> > ava: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.jav
> > a:527)
> >> at java.security.AccessController.doPrivileged(Native Method)
> >> at
> >>
> >
com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispat ch(ObjectTable.j
> > ava:565)
> >> at
> >>
> >
com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispat ch(ObjectTable.j
> > ava:540)
> >> at
> >>
> >
com.sun.jini.jeri.internal.runtime.ObjectTable$RD.dispatch(O bjectTable.java:
> > 778)
> >> at
> >>
> >
net.jini.jeri.connection.ServerConnectionManager$Dispatcher. dispatch(ServerC
> > onnectionManager.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.jav
> > a: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_SE
> > RVER__________(Util.java:108)
> >> at
> >>
> >
com.sun.jini.jeri.internal.runtime.Util.exceptionReceivedFro mServer(Util.jav
> > a:101)
> >> at
> >>
> >
net.jini.jeri.BasicInvocationHandler.unmarshalThrow(BasicInv ocationHandler.j
> > ava:1303)
> >> at
> >>
> >
net.jini.jeri.BasicInvocationHandler.invokeRemoteMethodOnce( BasicInvocationH
> > andler.java:832)
> >> at
> >>
> >
net.jini.jeri.BasicInvocationHandler.invokeRemoteMethod(Basi cInvocationHandl
> > er.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.j
> > ava: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.jav
> > a:527)
> >> at java.security.AccessController.doPrivileged(Native Method)
> >> at
> >>
> >
com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispat ch(ObjectTable.j
> > ava:565)
> >> at
> >>
> >
com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispat ch(ObjectTable.j
> > ava:540)
> >> at
> >>
> >
com.sun.jini.jeri.internal.runtime.ObjectTable$RD.dispatch(O bjectTable.java:
> > 778)
> >> at
> >>
> >
net.jini.jeri.connection.ServerConnectionManager$Dispatcher. dispatch(ServerC
> > onnectionManager.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.jav
> > a: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 rredClassProvide
> > r.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 asicInvocationDi
> > spatcher.java:1049)
> >> at
> >>
> >
net.jini.jeri.BasicInvocationDispatcher.dispatch(BasicInvoca tionDispatcher.j
> > ava: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
> >>
> >>
> >
> >
>
>
Re: Problem registering custom ProtocolHandler [message #79332 is a reply to message #79260] Mon, 18 December 2006 11:26 Go to previous messageGo to next message
Christian Hager is currently offline Christian HagerFriend
Messages: 53
Registered: July 2009
Location: Germany
Member
I'm running Outrigger from the Launcher that was included in the
installation (Launch-All.exe). Can the exception come directly from
Outrigger? Can I somehow also run Outrigger directly from an OSGi bundle?

Thanks again.

Christian
Re: Problem registering custom ProtocolHandler [message #79375 is a reply to message #79332] Mon, 18 December 2006 15:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: skaegi.sympatico.ca

> Can the exception come directly from Outrigger?
That's my best guess at the moment. It would still be good to verify where
the exception is being thrown in the debugger. ;)

I've run the LUS but not Outrigger or other spaces implementation "in" an
OSGi environment however it should be doable. That said, it should be fine
and perhaps simpler to use and configure Outrigger as is so long as an
"ahttp" URLStreamHandler is available to the VM runnning it.

-Simon

"Christian Hager" <ch.hager@gmail.com> wrote in message
news:ch.hager-79FF05.12255418122006@news.eclipse.org...
> I'm running Outrigger from the Launcher that was included in the
> installation (Launch-All.exe). Can the exception come directly from
> Outrigger? Can I somehow also run Outrigger directly from an OSGi bundle?
>
> Thanks again.
>
> Christian
Re: Problem registering custom ProtocolHandler [message #79450 is a reply to message #79375] Mon, 18 December 2006 16:57 Go to previous message
Christian Hager is currently offline Christian HagerFriend
Messages: 53
Registered: July 2009
Location: Germany
Member
Ok thanks for your help. Running Outrigger in a different process really
was the problem.
Previous Topic:cannot find the sqlmap-config.xml
Next Topic:questions on bundle and event
Goto Forum:
  


Current Time: Tue Apr 23 10:13:30 GMT 2024

Powered by FUDForum. Page generated in 0.03569 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top