[
http://jira.jboss.com/jira/browse/JBSEAM-1583?page=comments#action_12367474 ]
Michael Youngstrom commented on JBSEAM-1583:
--------------------------------------------
seam:component will use a spring instantiated bean as a Seam bean and wraps this spring
bean instance with the standard seam interceptors (if intercept==true). Seam uses a proxy
to achieve it's interceptor functionality. Seam components require a no-arg
constructor.
Looking at the Seam 2.0. code it appears some stuff has changed recently with regard to
how interception is done. Let me know if this functionality will work for you:
* <seam:component intercept="false"/> will make the spring bean a seam
component inject static variables such as @Logger and not try to create a seam proxy (no
need for no-arg constructor).
* <seam:component intercept="true"/> will make the spring bean a seam
component and create a seam proxy. @Logger will work but the spring bean will require a
no-arg constructor.
* <seam:component/> will use Seam's method of determining if interception is
needed or not (no interception if it is an entity bean or has the @BypassInterceptors on
the class).
Will that work for you and remove the need for JBSEAM-1584?
seam:component intercept uses Seam standard rules by default
------------------------------------------------------------
Key: JBSEAM-1583
URL:
http://jira.jboss.com/jira/browse/JBSEAM-1583
Project: JBoss Seam
Issue Type: Bug
Components: Spring
Affects Versions: 2.0.0.BETA1
Reporter: Magnus Heino
Assigned To: Michael Youngstrom
From spring-seam-2.0.xsd, intercept:
Determines whether Seam interceptors should be wrapped around a bean, by overriding
Seam's default rules.
Seldom do you want the seam interceptors wrapped around a sprig singleton. Auto will use
choose no
interception for a singleton and use Seam standard rules otherwise.
Looking at the code, I can't find anything about this "no interception for a
singleton" default.
This bean
<bean id="processRepository"
class="se.lantmateriet.wfl.dataaccess.WsProcessRepository">
<constructor-arg value="http://localhost/avtal/avtalservice.asmx"/>
<seam:component/>
</bean>
fails like this:
12:45:35,203 DEBUG [ProxyUtils] Creating proxy for Spring Seam component
'processRepository' using class:
se.lantmateriet.wfl.dataaccess.WsProcessRepository
12:45:35,282 INFO [DefaultListableBeanFactory] Destroying singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@8c2d94: defining
beans [org.jboss.seam.ioc.spring.seamComponentPostProcessor,processRepository]; root of
factory hierarchy
12:45:35,297 ERROR [[/wfl-seam]] Exception sending context initialized event to listener
instance of class org.jboss.seam.servlet.SeamListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'processRepository' defined in ServletContext resource
[/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is
org.jboss.seam.InstantiationException: Could not instantiate Seam component:
processRepository
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:430)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:255)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:252)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:287)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:689)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:358)
at org.jboss.seam.ioc.spring.ContextLoader.startupContextLoader(ContextLoader.java:64)
at org.jboss.seam.ioc.spring.ContextLoader.create(ContextLoader.java:43)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:124)
at org.jboss.seam.Component.callComponentMethod(Component.java:1957)
at org.jboss.seam.Component.callCreateMethod(Component.java:1880)
at org.jboss.seam.Component.newInstance(Component.java:1859)
at org.jboss.seam.contexts.Contexts.startup(Contexts.java:304)
at org.jboss.seam.contexts.Contexts.startup(Contexts.java:278)
at org.jboss.seam.contexts.ServletLifecycle.endInitialization(ServletLifecycle.java:98)
at org.jboss.seam.init.Initialization.init(Initialization.java:508)
at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:34)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3854)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4359)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:761)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:741)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)
Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component:
processRepository
at org.jboss.seam.Component.newInstance(Component.java:1853)
at org.jboss.seam.Component.getInstance(Component.java:1756)
at org.jboss.seam.Component.getInstance(Component.java:1735)
at org.jboss.seam.Component.getInstance(Component.java:1729)
at
org.jboss.seam.ioc.spring.SeamComponentPostProcessor.postProcessAfterInitialization(SeamComponentPostProcessor.java:49)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:314)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1184)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:407)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:255)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:252)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:287)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:689)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:358)
at org.jboss.seam.ioc.spring.ContextLoader.startupContextLoader(ContextLoader.java:64)
at org.jboss.seam.ioc.spring.ContextLoader.create(ContextLoader.java:43)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:124)
at org.jboss.seam.Component.callComponentMethod(Component.java:1957)
at org.jboss.seam.Component.callCreateMethod(Component.java:1880)
at org.jboss.seam.Component.newInstance(Component.java:1859)
at org.jboss.seam.contexts.Contexts.startup(Contexts.java:304)
at org.jboss.seam.contexts.Contexts.startup(Contexts.java:278)
at org.jboss.seam.contexts.ServletLifecycle.endInitialization(ServletLifecycle.java:98)
at org.jboss.seam.init.Initialization.init(Initialization.java:508)
Caused by: java.lang.InstantiationException:
se.lantmateriet.wfl.dataaccess.WsProcessRepository_$$_javassist_0
at java.lang.Class.newInstance0(Class.java:340)
at java.lang.Class.newInstance(Class.java:308)
at org.jboss.seam.ioc.ProxyUtils.enhance(ProxyUtils.java:71)
at org.jboss.seam.ioc.IoCComponent.instantiateJavaBean(IoCComponent.java:94)
at org.jboss.seam.Component.instantiate(Component.java:1154)
at org.jboss.seam.Component.newInstance(Component.java:1849)
at org.jboss.seam.Component.getInstance(Component.java:1756)
at org.jboss.seam.Component.getInstance(Component.java:1735)
at org.jboss.seam.Component.getInstance(Component.java:1729)
at
org.jboss.seam.ioc.spring.SeamComponentPostProcessor.postProcessAfterInitialization(SeamComponentPostProcessor.java:49)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:314)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1184)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:407)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:255)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:252)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:287)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:689)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:358)
at org.jboss.seam.ioc.spring.ContextLoader.startupContextLoader(ContextLoader.java:64)
at org.jboss.seam.ioc.spring.ContextLoader.create(ContextLoader.java:43)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:124)
at org.jboss.seam.Component.callComponentMethod(Component.java:1957)
at org.jboss.seam.Component.callCreateMethod(Component.java:1880)
If I change <seam:component/> to <seam:component
intercept="false"/> everything works.
1. Default for stateless spring beans seems to be true since seam standard rules are
applied if intercept is null, that is not defined. bug?
2. Why would I want to use intercept="true" anyway? What interceptors will be
added?
3. Why is it failing with intercept="true"?
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira