You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jun Tsai <Ju...@gmail.com> on 2005/09/02 08:01:06 UTC

@InjectObject spring beans proxyed with Spring-AOP problem.

Hmm, I'm using the @InjectObject to inject spring
beans not proxyed with spring-aop and it's working great. but if use 
@InjectObject to inject spring beans proxyed with Spring-AOP ,It throws 
a java.lang.IllegalArgumentException:
	argument type mismatch.




Jun Tsai


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: @InjectObject spring beans proxyed with Spring-AOP problem.

Posted by Jun Tsai <ju...@gmail.com>.
If I access the object by spring directly,all works fine.
Only when I use T4-B5 to inject the spring object proxyed with 
Spring-AOP,IllegalArgumentException was thrown.
If I use T4-B5 to inject the spring object without spring-AOP.all works 
fine.
why?
Thanks.
Jun Tsai

 On 9/2/05, jocsch <jo...@freaquac.de> wrote: 
> 
> Just a thought:
> Did you try to extract an interface out of the class and make a proxy on
> the interface? Then cglib should be omitted and a jdk dynamic proxy (or
> something like that) would be created.
> Don't know if it works but I remember I had a similar issue with proxied
> classes once in spring tests.
> 
> Markus
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


-- 
Welcome to China Java Users Group(CNJUG).
http://cnjug.dev.java.net

Re: @InjectObject spring beans proxyed with Spring-AOP problem.

Posted by jocsch <jo...@freaquac.de>.
Just a thought:
Did you try to extract an interface out of the class and make a proxy on
the interface? Then cglib should be omitted and a jdk dynamic proxy (or
something like that) would be created.
Don't know if it works but I remember I had a similar issue with proxied
classes once in spring tests.

Markus



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: @InjectObject spring beans proxyed with Spring-AOP problem.

Posted by Jun Tsai <Ju...@gmail.com>.
Krutyakov Roman wrote:
> В Птн, 02/09/2005 в 14:01 +0800, Jun Tsai пишет:
> 
>>Hmm, I'm using the @InjectObject to inject spring
>>beans not proxyed with spring-aop and it's working great. but if use 
>>@InjectObject to inject spring beans proxyed with Spring-AOP ,It throws 
>>a java.lang.IllegalArgumentException:
>>	argument type mismatch.
>>Jun Tsai
> 
> Tapestry version?
> 

beta-5

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: @InjectObject spring beans proxyed with Spring-AOP problem.

Posted by Krutyakov Roman <ma...@rs.com.ua>.
В Птн, 02/09/2005 в 14:01 +0800, Jun Tsai пишет:
> Hmm, I'm using the @InjectObject to inject spring
> beans not proxyed with spring-aop and it's working great. but if use 
> @InjectObject to inject spring beans proxyed with Spring-AOP ,It throws 
> a java.lang.IllegalArgumentException:
> 	argument type mismatch.
> Jun Tsai
Tapestry version?

-- 
Roman Krutyakov


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: @InjectObject spring beans proxyed with Spring-AOP problem.

Posted by Jun Tsai <Ju...@gmail.com>.
Patrick Casey wrote:

> 
> 	One (possible serious voodoo) things that often help:
> 
> 	Make all the methods of your testService public (not package scope,
> *public*).
> 

My TestService is:

public class TestService{
	public void test(){
		System.out.println("okay");
	}
}

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: @InjectObject spring beans proxyed with Spring-AOP problem.

Posted by Jun Tsai <Ju...@gmail.com>.
Patrick Casey wrote:
> 	Maybe it's Hivemind that's doing the enhancing, not Spring?
> Alternately it might be the annotation library or some other agency. I've
> had a lot of weirdness with CGLIC enhanced classes in the past (like they
> screw up potentially simple things like using the == operator to test for
> object identity if one side of the identity is "enhanced" into a new proxy
> in the meantime).
> 
> 	Recently, my CGLIB problems seem to have settled down, which leads
> me to believe that I've probably just sub-consciously taken the "stop
> hitting your head on the wall if it hurts" approach to solving the problem. 
> 
> 	I suspect it's something subtle, because as I mentioned
> theoretically 
> 
> 	Foo f = (Foo) GCLIB_Enhanced_Foo should work


I have tried it.same problem happen.
> 
> 	Other than pointing at GCLIB as a possible place to look, I can't
> offer any more help unfortunately :(.
> 
> 	In the meantime, I need to get to bed; a day spent watching disaster
> video and being utterly unable to do anything is catching up with me.
> 

Thank you.

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


RE: @InjectObject spring beans proxyed with Spring-AOP problem.

Posted by Patrick Casey <pa...@adelphia.net>.
	Maybe it's Hivemind that's doing the enhancing, not Spring?
Alternately it might be the annotation library or some other agency. I've
had a lot of weirdness with CGLIC enhanced classes in the past (like they
screw up potentially simple things like using the == operator to test for
object identity if one side of the identity is "enhanced" into a new proxy
in the meantime).

	Recently, my CGLIB problems seem to have settled down, which leads
me to believe that I've probably just sub-consciously taken the "stop
hitting your head on the wall if it hurts" approach to solving the problem. 

	I suspect it's something subtle, because as I mentioned
theoretically 

	Foo f = (Foo) GCLIB_Enhanced_Foo should work

	Other than pointing at GCLIB as a possible place to look, I can't
offer any more help unfortunately :(.

	In the meantime, I need to get to bed; a day spent watching disaster
video and being utterly unable to do anything is catching up with me.

	--- Pat

> -----Original Message-----
> From: Jun Tsai [mailto:Jun.Tsai@gmail.com]
> Sent: Friday, September 02, 2005 12:21 AM
> To: Tapestry users
> Subject: Re: @InjectObject spring beans proxyed with Spring-AOP problem.
> 
> Patrick Casey wrote:
> > 	CGLIB is an enhancement library that a lot of open source packages
> > use to create dynamic proxies of your classes (usually to bolt on their
> > specific accessors and proxy code to your POJOs). It's used by both
> spring
> > and hibernate pretty extensively, and it looks like you've got spring
> > running. So what's happening is that spring is enhancing your class for
> you.
> >
> > 	*However* and this is the part where I get less helpful, an enhanced
> > class *should* be a subclass of the original class, hence it should
> still be
> > assignable. So, *in theory* you shouldn't get the error you're getting.
> In
> > theory, of course, theory and practice are the same.
> >
> > 	One (possible serious voodoo) things that often help:
> >
> > 	Make all the methods of your testService public (not package scope,
> > *public*).
> >
> > 	--- Pat
> >
> 
> Thank your reply.
> If I don't use @InjectObject,I can get the TestService directly by
> Spring and the testService object works fine.
> 
> why?
> 
> Jun Tsai
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: @InjectObject spring beans proxyed with Spring-AOP problem.

Posted by Jun Tsai <Ju...@gmail.com>.
Patrick Casey wrote:
> 	CGLIB is an enhancement library that a lot of open source packages
> use to create dynamic proxies of your classes (usually to bolt on their
> specific accessors and proxy code to your POJOs). It's used by both spring
> and hibernate pretty extensively, and it looks like you've got spring
> running. So what's happening is that spring is enhancing your class for you.
> 
> 	*However* and this is the part where I get less helpful, an enhanced
> class *should* be a subclass of the original class, hence it should still be
> assignable. So, *in theory* you shouldn't get the error you're getting. In
> theory, of course, theory and practice are the same.
> 
> 	One (possible serious voodoo) things that often help:
> 
> 	Make all the methods of your testService public (not package scope,
> *public*).
> 
> 	--- Pat
> 

Thank your reply.
If I don't use @InjectObject,I can get the TestService directly by 
Spring and the testService object works fine.

why?

Jun Tsai

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


RE: @InjectObject spring beans proxyed with Spring-AOP problem.

Posted by Patrick Casey <pa...@adelphia.net>.
	CGLIB is an enhancement library that a lot of open source packages
use to create dynamic proxies of your classes (usually to bolt on their
specific accessors and proxy code to your POJOs). It's used by both spring
and hibernate pretty extensively, and it looks like you've got spring
running. So what's happening is that spring is enhancing your class for you.

	*However* and this is the part where I get less helpful, an enhanced
class *should* be a subclass of the original class, hence it should still be
assignable. So, *in theory* you shouldn't get the error you're getting. In
theory, of course, theory and practice are the same.

	One (possible serious voodoo) things that often help:

	Make all the methods of your testService public (not package scope,
*public*).

	--- Pat

> -----Original Message-----
> From: Jun Tsai [mailto:Jun.Tsai@gmail.com]
> Sent: Thursday, September 01, 2005 11:48 PM
> To: Tapestry users
> Subject: Re: @InjectObject spring beans proxyed with Spring-AOP problem.
> 
> Jun Tsai wrote:
> > I find if I use
> >
> > @InjectObject("spring:testService")
> > public abstract ITestService getTestService();
> >
> > It throws a java.lang.IllegalArgumentException:
> >     argument type mismatch.
> >
> >
> > If I use
> > @InjectObject("spring:testService")
> > public abstract Object getTestService();
> >
> 
> 
> ITestService testService=(ITestService)getTestService();
> 
> The code throws java.lang.ClassCastException.I debug this.I find the
> class is TestService$$EnhanceByCGLIB$$b324af4b.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: @InjectObject spring beans proxyed with Spring-AOP problem.

Posted by Jun Tsai <Ju...@gmail.com>.
Jun Tsai wrote:
> I find if I use
> 
> @InjectObject("spring:testService")
> public abstract ITestService getTestService();
> 
> It throws a java.lang.IllegalArgumentException:
>     argument type mismatch.
> 
> 
> If I use
> @InjectObject("spring:testService")
> public abstract Object getTestService();
> 


ITestService testService=(ITestService)getTestService();

The code throws java.lang.ClassCastException.I debug this.I find the 
class is TestService$$EnhanceByCGLIB$$b324af4b.



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: @InjectObject spring beans proxyed with Spring-AOP problem.

Posted by Jun Tsai <Ju...@gmail.com>.
I find if I use

@InjectObject("spring:testService")
public abstract ITestService getTestService();

It throws a java.lang.IllegalArgumentException:
     argument type mismatch.


If I use
@InjectObject("spring:testService")
public abstract Object getTestService();

I works great.


What's happen?

Who can tell me ?

Thanks .

Jun Tsai

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org