Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » RCP + spring(classloading problems with eclipse RCP and spring)
RCP + spring [message #505699] Mon, 04 January 2010 09:56 Go to next message
No real name is currently offline No real nameFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: RCP + spring [message #717239 is a reply to message #505699] Fri, 19 August 2011 17:06 Go to previous message
Al  is currently offline Al Friend
Messages: 1
Registered: August 2011
Junior Member
Have you resolved this yet?
I am getting a similar error with a project I am working on.
I believe this problem i similar to an indirect reference error.
because spring is making a remote call to some other module the library that is being referenced needs to exist in both places. if the library does not exist in the originators class path then the object cannot be deserialized because the class definition was never loaded into the class loader.

I may be off the mark here but I'm pretty confident in this train of thought.
Previous Topic:Headless/multi-platform build - what is the preferred way to do that?
Next Topic:How to Disable close option in a view
Goto Forum:
  


Current Time: Tue Apr 16 22:47:23 GMT 2024

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

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

Back to the top