RCP + spring [message #505699] |
Mon, 04 January 2010 09:56  |
No real name Messages: 3 Registered: December 2009 |
Junior Member |
|
|
Hi all,
I am trying to integrate spring into my RCP app. There are some problems with classloading.
Here's the relevant code:
public static boolean login(String server, String user, String password) {
try {
HttpInvokerProxyFactoryBean remoteProxyFactory = new HttpInvokerProxyFactoryBean();
remoteProxyFactory
.setServiceInterface(RemoteAuthenticationManager.class);
StringBuilder url = new StringBuilder();
if (!server.startsWith("http://"))
url.append("http://");
url.append(server).append("/remoting");
remoteProxyFactory.setServiceUrl(url.toString() + "/RemoteAuthenticationManager");
remoteProxyFactory.afterPropertiesSet(); // <- line 46.
...
The required Spring bundles are added as a dependency to my bundle. When the code executes, it throws the following exception:
java.lang.IllegalArgumentException: interface org.springframework.security.providers.rcp.RemoteAuthenticationManager is not visible from class loader
at java.lang.reflect.Proxy.getProxyClass(Proxy.java:353)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:581)
at org.springframework.aop.framework.JdkDynamicAopProxy.getProxy(JdkDynamicAopProxy.java:117)
at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:112)
at org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean.afterPropertiesSet(HttpInvokerProxyFactoryBean.java:62)
at myplugin.Remoting.login(Remoting.java:46)
...
Now it all comes down to the method java.lang.reflect.Proxy#getProxyClass(ClassLoader loader, Class<?>... interfaces). Debugging revealed that the ClassLoader given to the method was the same as Thread.currentThread().getContextClassLoader() in the login method of my plugin. When I added the line:
...
Class.forName("org.springframework.security.providers.rcp.RemoteAuthenticationManager",false,Thread.currentThread().getContextClassLoader()); // <- the new line
remoteProxyFactory.afterPropertiesSet(); //<-- line 46.
...
before the invocation of the afterPropertiesSet() method in my plugin code, it all worked fine. So if anybody could explain to me what is happening there (something to do with parent classloaders?) I would be very grateful.
Unfortunately this is not where my problems end. Few lines after the first excerpt I have:
Authentication request = new UsernamePasswordAuthenticationToken(user, password);
Authentication result = provider.authenticate(request); // <- line 90
and I get the following exception:
org.springframework.remoting.RemoteAccessException: Could not deserialize result from HTTP invoker remote service [http://localhost:8080/remoting/RemoteAuthenticationManager]; nested exception is java.lang.ClassNotFoundException: org.springframework.remoting.support.RemoteInvocationResult
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.convertHttpInvokerAccessException(HttpInvokerClientInterceptor.java:208)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:145)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy0.attemptAuthentication(Unknown Source)
at org.springframework.security.providers.rcp.RemoteAuthenticationProvider.authenticate(RemoteAuthenticationProvider.java:61)
at myplugin.Remoting.login(Remoting.java:90)
...
Here adding the Class.forName() won't help. I tried the trick explained in http://www.eclipsezone.com/eclipse/forums/t61831.html but it doesn't help either. Do I need to add buddy classloading to spring bundles (between spring bundles?). I have probably misunderstood some basic stuff. I would appreciate if anyone can provide me with some pointers on what/where to investigate further.
Thanks.
|
|
|
Re: RCP + spring [message #506084 is a reply to message #505699] |
Wed, 06 January 2010 02:41   |
Eclipse User |
|
|
|
Originally posted by: jccanova.gmail.com
OFF Topic:
sorry use your question but, what you bunbled in the spring osgi ?
All jars form spring + your jars + dependencies ?
Also, the application context you load/stop in osgi start/stop;
Im starting to read how i can use spring in a rcp.... any info can help;
Regards.
<l6hmus@gmail.com> wrote in message news:hhsvgu$kvh$1@build.eclipse.org...
> Hi all,
>
> I am trying to integrate spring into my RCP app. There are some problems
> with classloading.
> Here's the relevant code:
>
> public static boolean login(String server, String user, String password) {
> try {
> HttpInvokerProxyFactoryBean remoteProxyFactory = new
> HttpInvokerProxyFactoryBean();
> remoteProxyFactory
> .setServiceInterface(RemoteAuthenticationManager.class);
> StringBuilder url = new StringBuilder();
> if (!server.startsWith("http://"))
> url.append("http://");
> url.append(server).append("/remoting");
> remoteProxyFactory.setServiceUrl(url.toString() +
> "/RemoteAuthenticationManager");
> remoteProxyFactory.afterPropertiesSet(); // <- line 46.
> ...
>
>
> The required Spring bundles are added as a dependency to my bundle. When
> the code executes, it throws the following exception:
>
>
> java.lang.IllegalArgumentException: interface
> org.springframework.security.providers.rcp.RemoteAuthenticat ionManager is
> not visible from class loader
> at java.lang.reflect.Proxy.getProxyClass(Proxy.java:353)
> at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:581)
> at
> org.springframework.aop.framework.JdkDynamicAopProxy.getProx y(JdkDynamicAopProxy.java:117)
> at
> org.springframework.aop.framework.ProxyFactory.getProxy(Prox yFactory.java:112)
> at
> org.springframework.remoting.httpinvoker.HttpInvokerProxyFac toryBean.afterPropertiesSet(HttpInvokerProxyFactoryBean.java :62)
> at myplugin.Remoting.login(Remoting.java:46)
> ...
>
>
> Now it all comes down to the method
> java.lang.reflect.Proxy#getProxyClass(ClassLoader loader, Class<?>...
> interfaces). Debugging revealed that the ClassLoader given to the method
> was the same as Thread.currentThread().getContextClassLoader() in the
> login method of my plugin. When I added the line:
>
>
> ..
> Class.forName(" org.springframework.security.providers.rcp.RemoteAuthenticat ionManager ",false,Thread.currentThread().getContextClassLoader());
> // <- the new line
> remoteProxyFactory.afterPropertiesSet(); //<-- line 46.
> ..
>
>
> before the invocation of the afterPropertiesSet() method in my plugin
> code, it all worked fine. So if anybody could explain to me what is
> happening there (something to do with parent classloaders?) I would be
> very grateful.
>
> Unfortunately this is not where my problems end. Few lines after the first
> excerpt I have:
>
>
> Authentication request = new UsernamePasswordAuthenticationToken(user,
> password);
> Authentication result = provider.authenticate(request); // <- line 90
>
>
> and I get the following exception:
>
>
> org.springframework.remoting.RemoteAccessException: Could not deserialize
> result from HTTP invoker remote service
> [http://localhost:8080/remoting/RemoteAuthenticationManager]; nested
> exception is java.lang.ClassNotFoundException:
> org.springframework.remoting.support.RemoteInvocationResult
> at
> org.springframework.remoting.httpinvoker.HttpInvokerClientIn terceptor.convertHttpInvokerAccessException(HttpInvokerClien tInterceptor.java:208)
> at
> org.springframework.remoting.httpinvoker.HttpInvokerClientIn terceptor.invoke(HttpInvokerClientInterceptor.java:145)
> at
> org.springframework.aop.framework.ReflectiveMethodInvocation .proceed(ReflectiveMethodInvocation.java:172)
> at
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke( JdkDynamicAopProxy.java:202)
> at $Proxy0.attemptAuthentication(Unknown Source)
> at
> org.springframework.security.providers.rcp.RemoteAuthenticat ionProvider.authenticate(RemoteAuthenticationProvider.java:6 1)
> at myplugin.Remoting.login(Remoting.java:90)
> ...
>
>
> Here adding the Class.forName() won't help. I tried the trick explained in
> http://www.eclipsezone.com/eclipse/forums/t61831.html but it doesn't help
> either. Do I need to add buddy classloading to spring bundles (between
> spring bundles?). I have probably misunderstood some basic stuff. I would
> appreciate if anyone can provide me with some pointers on what/where to
> investigate further.
>
> Thanks.
|
|
|
|
Powered by
FUDForum. Page generated in 0.01873 seconds