Ok. In the trunk version of Spring framework, one can also use ordinary
Java (interface based) proxies, so I guess it is better to wait with
this functionality until the next minor version of Spring is released. I
turned it off in our trunk.
In Cocoon we use a call stack for handling some environment data (like
the current sitemap and servlet context, request and response). There is
such a call stack both in Cocoon core and in the servlet service
framework. These call stacks are currently used through calling static
functions - EnvironmentHelper.getCurrentEnvironment() in core and
CallStack.getCurrentFrame() in the servlet service fw. The drawback with
this is that it is much harder to reuse components that depend on static
calls outside Cocoon. It is also harder to follow the code and to do
unit testing.
What I work on now is to create a custom "call scope" for Spring (see
http://static.springframework.org/spring/docs/2.0.x/reference/beans.html#beans-factory-scopes)
that makes it possible to mark beans as having call scope. These beans
are like ordinary beans and can be dependency injected, but internally
they use the current call stack. The scoped proxy make sure that a user
always gets the current value of the bean.
If it works well we could use a the same stack for both th sitemap and
for the servlet services and replace all the static calls in the code
with ordinary dependency injection.
I'll continue to develop the stuff but it seem like we need to wait for
the next Spring release before we can turn it on in Cocoon.
/Daniel
Rice Yeh skrev:
No. But I think this is a bug in the method setBeanFactory(..) of
class org.springframework.aop.scope.ScopedProxyFactoryBean in
springframeowrk 2.0.2. In the last line of this method, it is
this.proxy = pf.getProxy();
,where getProxy() is not passed a classloader. In the latest CVS
version, the last line of the same method is
this.proxy
= pf.getProxy(cbf.getBeanClassLoader());
, where classloader is passed.
Regards,
Rice
On 2/6/07, *Daniel Fagerstrom* <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:
Any suggestion about what to do about it?
/Daniel
Rice Yeh skrev:
> I do have cglib-2.1_3.jar in the WEB/lib directory. By tracing the
> code, I find the classloader used in Enhancer is the classloder of
> javax.servlet.http.HttpServletRequest, which is an instance of
> org.codehaus.classworlds.RealmClassLoader . RealmClassLoader
just include
> class path used in jetty, not include path in WEB/lib. Hence, an
> exception java.lang.NoClassDefFoundError:
org/springframework/aop/scope
> /ScopedObject is thrown.
>
> Rice
>
> On 2/6/07, *Daniel Fagerstrom* < [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
> <mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>> wrote:
>
> It looks like you are lacking the cglib. It is (since yesterday)
> part of
> the dependencies for cocoon-servlet-service-impl. It should be
> included
> in your cocoon-webapp dependencies by transitive dependency
> handling. It
> works for me. It might be that you need to clean and rebuild
your
> cocoon-webapp or something.
>
> /Daniel
>
> Rice Yeh skrev:
> > Hi,
> > Running the latest code from trunk, I get an error as
the title
> > described.
> > The following is the exception stack:
> >
> > Caused by:
org.springframework.beans.factory.BeanCreationException:
> > Error creati
> > ng bean with name ' javax.servlet.http.HttpServletRequest
> /callstack':
> > Initializat
> > ion of bean failed; nested exception is
> > org.springframework.aop.framework.AopCon
> > figException: Couldn't generate CGLIB subclass of class
[interface
> > javax.servlet
> > .http.HttpServletRequest]: Common causes of this problem
include
> using
> > a final c
> > lass or a non-visible class; nested exception is
> > net.sf.cglib.core.CodeGeneratio
> > nException: java.lang.reflect.InvocationTargetException--
>null
> >
> ...
>
>