[
http://jira.jboss.com/jira/browse/JBSEAM-1108?page=comments#action_12357395 ]
Michael Youngstrom commented on JBSEAM-1108:
--------------------------------------------
One way to loosen this constraint and the @Synchronized constraint JBSEAM-1077 might be to
create a "strict" flag in component that SpringComponent could override to
remove these checks.
Loosen restrictions around @PersistenceContext
----------------------------------------------
Key: JBSEAM-1108
URL:
http://jira.jboss.com/jira/browse/JBSEAM-1108
Project: JBoss Seam
Issue Type: Bug
Affects Versions: 1.2.0.GA
Reporter: Michael Youngstrom
Fix For: 1.3.0.BETA1
Spring can utilize the @PersistenceContext annotation in a bean to auto inject an
EntityManager. However, if you create a Spring bean with @PersistenceContext on one of
its fields and make it a Seam component Seam assumes that's invalid and throws an
exception. It would be nice if Seam could loosen validation of the @PersistenceContext to
better accommodate unconventional uses.
Caused by:
java.lang.IllegalArgumentException: @PersistenceContext may only be used on session bean
or message driven bean components: userService
at org.jboss.seam.Component.initMembers(Component.java:663)
at org.jboss.seam.Component.<init>(Component.java:253)
at org.jboss.seam.Component.<init>(Component.java:203)
at org.jboss.seam.ioc.IoCComponent.<init>(IoCComponent.java:56)
at org.jboss.seam.ioc.spring.SpringComponent.<init>(SpringComponent.java:152)
at
org.jboss.seam.ioc.spring.SpringComponent.addSpringComponent(SpringComponent.java:82)
at
org.jboss.seam.ioc.spring.SeamNamespaceHandler$SeamComponentBeanDefinitionDecorator.decorate(SeamNamespaceHandler.java:186)
at
org.springframework.beans.factory.xml.NamespaceHandlerSupport.decorate(NamespaceHandlerSupport.java:106)
at
org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.decorateIfRequired(BeanDefinitionParserDelegate.java:1142)
at
org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.decorateBeanDefinitionIfRequired(BeanDefinitionParserDelegate.java:1132)
at
org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.processBeanDefinition(DefaultBeanDefinitionDocumentReader.java:237)
at
org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:151)
at
org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:130)
at
org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:90)
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:458)
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:353)
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:280)
at
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:131)
at
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:147)
at
org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
at
org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)
at
org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:100)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:298)
at org.jboss.seam.ioc.spring.ContextLoader.startupContextLoader(ContextLoader.java:59)
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:585)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:20)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:123)
at org.jboss.seam.Component.callComponentMethod(Component.java:1834)
at org.jboss.seam.Component.callCreateMethod(Component.java:1757)
at org.jboss.seam.Component.newInstance(Component.java:1746)
at org.jboss.seam.contexts.Lifecycle.startup(Lifecycle.java:175)
at org.jboss.seam.contexts.Lifecycle.endInitialization(Lifecycle.java:145)
at org.jboss.seam.init.Initialization.init(Initialization.java:504)
at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:33)
--
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