[
http://jira.jboss.com/jira/browse/JBSEAM-1636?page=comments#action_12368478 ]
Przemyslaw Jaskierski commented on JBSEAM-1636:
-----------------------------------------------
Mike I've done both things. Still fails. Now I have:
1. AppContext:
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://jboss.com/products/seam/spring-seam
http://jboss.com/products/seam/spring-seam-2.0.xsd">
<bean id="pecpHibernateSessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation"
value="classpath:conf/hibernate/hibernate.cfg.xml" />
<property name="configurationClass"
value="org.hibernate.cfg.AnnotationConfiguration"/>
<property name="namingStrategy">
<bean
class="edg.persistence.hibernate.extensions.UnderscoreAwareNamingStrategy"/>
</property>
</bean>
2. components.xml
http://jboss.com/products/seam/spring
http://jboss.com/products/seam/spring-2.0.xsd">
<core:init transaction-management-enabled="true"
debug="true"/>
<core:manager conversation-timeout="120000"
concurrent-request-timeout="500"
conversation-id-parameter="k"/>
<spring:context-loader config-locations="classpath:conf/spring/core.xml,
classpath:conf/spring/persistence-common.xml,
classpath:conf/spring/persistence-hibernate.xml,
classpath:conf/spring/statistics.xml"/>
<persistence:managed-hibernate-session
name="pecpSeamManagedHibernateSession" auto-create="true"
session-factory="#{pecpHibernateSessionFactory}"/>
<transaction:hibernate-transaction
session="#{pecpSeamManagedHibernateSession}"/>
Like I said before I have Session-scoped Seam component which in his @Create method call
indirectly something like:
Session hibernateSession = (Session)
Component.getInstance("pecpSeamManagedHibernateSession");
But in the stacktrace below every piece of my view that tries to get handle to
sessionFactory fails on the same JNDI (?) lookup.
after this Seam produces huge circular rolling stacktrace that basically renders this:
java.lang.IllegalArgumentException: SessionFactory not found in JNDI:
java:/pecpSeamManagedHibernateSession
org.jboss.seam.persistence.ManagedHibernateSession.getSessionFactoryFromJndiOrValueBinding(ManagedHibernateSession.java:238)
org.jboss.seam.persistence.ManagedHibernateSession.initSession(ManagedHibernateSession.java:81)
org.jboss.seam.persistence.ManagedHibernateSession.getSession(ManagedHibernateSession.java:112)
sun.reflect.GeneratedMethodAccessor36.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:124)
org.jboss.seam.Component.callComponentMethod(Component.java:1974)
org.jboss.seam.Component.unwrap(Component.java:2000)
org.jboss.seam.Component.getInstance(Component.java:1787)
org.jboss.seam.Component.getInstance(Component.java:1740)
org.jboss.seam.Component.getInstance(Component.java:1734)
egd.persistence.hibernate.session.SeamDrivenHibernateSessionProvider.getSession(SeamDrivenHibernateSessionProvider.java:13)
egd.persistence.hibernate.session.HibernateSessionUtil.getSession(HibernateSessionUtil.java:26)
egd.persistence.hibernate.dao.AbstractHibernateDAO.getSession(AbstractHibernateDAO.java:22)
egd.persistence.hibernate.dao.CategoryDAO.getRootCategory(CategoryDAO.java:32)
egd.client.jsf.backers.applicationstate.ApplicationStateBacker.initData(ApplicationStateBacker.java:27)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:49)
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:151)
org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:87)
egd.client.jsf.backers.applicationstate.ApplicationStateBacker_$$_javassist_2.initData(ApplicationStateBacker_$$_javassist_2.java)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:124)
org.jboss.seam.Component.callComponentMethod(Component.java:1974)
org.jboss.seam.Component.callCreateMethod(Component.java:1897)
org.jboss.seam.Component.newInstance(Component.java:1876)
org.jboss.seam.Component.getInstance(Component.java:1773)
org.jboss.seam.Component.getInstance(Component.java:1740)
org.jboss.seam.Component.getInstance(Component.java:1734)
org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:60)
javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
org.jboss.el.parser.AstValue.getValue(AstValue.java:63)
org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
javax.faces.component.ValueBindingValueExpressionAdapter.getValue(ValueBindingValueExpressionAdapter.java:102)
egd.client.jsf.components.SubcategoriesTreeComponent.getRootCategoryValueBinding(SubcategoriesTreeComponent.java:109)
egd.client.jsf.components.SubcategoriesTreeComponent.encodeEnd(SubcategoriesTreeComponent.java:74)
org.jboss.seam.ui.util.cdk.RendererBase.renderChild(RendererBase.java:190)
org.jboss.seam.ui.util.cdk.RendererBase.renderChildren(RendererBase.java:166)
org.jboss.seam.ui.renderkit.CacheRendererBase.doEncodeChildren(CacheRendererBase.java:59)
org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:577)
org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:233)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:183)
org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:125)
org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:107)
org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:78)
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:383)
net.sf.ehcache.constructs.web.filter.GzipFilter.doFilter(GzipFilter.java:75)
net.sf.ehcache.constructs.web.filter.Filter.doFilter(Filter.java:92)
root case:
javax.naming.NamingException: Local server is not initialized
org.jnp.interfaces.LocalOnlyContextFactory.getInitialContext(LocalOnlyContextFactory.java:45)
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
javax.naming.InitialContext.init(InitialContext.java:223)
javax.naming.InitialContext.<init>(InitialContext.java:197)
org.jboss.seam.util.Naming.getInitialContext(Naming.java:37)
org.jboss.seam.util.Naming.getInitialContext(Naming.java:50)
org.jboss.seam.persistence.ManagedHibernateSession.getSessionFactoryFromJndiOrValueBinding(ManagedHibernateSession.java:234)
org.jboss.seam.persistence.ManagedHibernateSession.initSession(ManagedHibernateSession.java:81)
org.jboss.seam.persistence.ManagedHibernateSession.getSession(ManagedHibernateSession.java:112)
sun.reflect.GeneratedMethodAccessor36.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:124)
org.jboss.seam.Component.callComponentMethod(Component.java:1974)
org.jboss.seam.Component.unwrap(Component.java:2000)
org.jboss.seam.Component.getInstance(Component.java:1787)
org.jboss.seam.Component.getInstance(Component.java:1740)
org.jboss.seam.Component.getInstance(Component.java:1734)
egd.persistence.hibernate.session.SeamDrivenHibernateSessionProvider.getSession(SeamDrivenHibernateSessionProvider.java:13)
egd.persistence.hibernate.session.HibernateSessionUtil.getSession(HibernateSessionUtil.java:26)
egd.persistence.hibernate.dao.AbstractHibernateDAO.getSession(AbstractHibernateDAO.java:22)
egd.persistence.hibernate.dao.CategoryDAO.getRootCategory(CategoryDAO.java:32)
egd.client.jsf.backers.applicationstate.ApplicationStateBacker.initData(ApplicationStateBacker.java:27)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:49)
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:151)
org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:87)
egd.client.jsf.backers.applicationstate.ApplicationStateBacker_$$_javassist_2.initData(ApplicationStateBacker_$$_javassist_2.java)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:124)
org.jboss.seam.Component.callComponentMethod(Component.java:1974)
org.jboss.seam.Component.callCreateMethod(Component.java:1897)
org.jboss.seam.Component.newInstance(Component.java:1876)
org.jboss.seam.Component.getInstance(Component.java:1773)
org.jboss.seam.Component.getInstance(Component.java:1740)
org.jboss.seam.Component.getInstance(Component.java:1734)
org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:60)
javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
org.jboss.el.parser.AstValue.getValue(AstValue.java:63)
org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
javax.faces.component.ValueBindingValueExpressionAdapter.getValue(ValueBindingValueExpressionAdapter.java:102)
egd.client.jsf.components.SubcategoriesTreeComponent.getRootCategoryValueBinding(SubcategoriesTreeComponent.java:109)
egd.client.jsf.components.SubcategoriesTreeComponent.encodeEnd(SubcategoriesTreeComponent.java:74)
org.jboss.seam.ui.util.cdk.RendererBase.renderChild(RendererBase.java:190)
org.jboss.seam.ui.util.cdk.RendererBase.renderChildren(RendererBase.java:166)
org.jboss.seam.ui.renderkit.CacheRendererBase.doEncodeChildren(CacheRendererBase.java:59)
org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:577)
org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:233)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:183)
org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:125)
org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:107)
org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:78)
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:383)
net.sf.ehcache.constructs.web.filter.GzipFilter.doFilter(GzipFilter.java:75)
net.sf.ehcache.constructs.web.filter.Filter.doFilter(Filter.java:92)
Cannot inject Spring-bound HibernateSessionFactory to Seam-managed
Hibernate Session
------------------------------------------------------------------------------------
Key: JBSEAM-1636
URL:
http://jira.jboss.com/jira/browse/JBSEAM-1636
Project: JBoss Seam
Issue Type: Bug
Components: Spring
Environment: Tomcat 6.0.13, Spring 2.0.6, Seam CVS 08072007
Reporter: Przemyslaw Jaskierski
Assigned To: Michael Youngstrom
Priority: Minor
Attachments: seamComponentNamespaceStackTrace.txt.zip,
springELResolverStackTrace.txt.zip, springStartedFromSeam.txt.zip
Filling this PR as requested by Mike.
For a full story please read related topic. As you requested I tried to reproduce
environment from my previous unsuccessful attempts. It's a little bit frustrating but
after assembling it once again now Spring EL resolver seams to working somewhat in some
aspects. But let's try to report step by step.
1. Spring-EL approach: Spring-bound session factory, referenced in components, Spring EL
resolver put into faces-config. There are two cases:
1.a. I have Seam-session-scoped bean that in @Create tries to get Hibernate session and
retrieve some information from RDBMS. I have abstracted Seam-managed-hibernate-session
access, and this additional layer simply invokes
Component.instance(NAME_OF_SEAM_MANAGED_HIBERNATE_SESSION_COMPONENT_DECLARED_IN_COMPONENTSXML)
instead of relying in @In. This layer is completely pluggable and allows to select
HibernateSession manager (Seam, Spring OSIV, custom one for Test) and inject it into data
access layer.
Ok, so this @Create call renders a bunch of extremely huge stacktreace (WORKED in
Microncontainer/Seam 1.3 combo flawlessly). You can see these stracktraces in
springELResolverStackTrace.txt.zip file.
1.b. Every following HibernateSession access seams to WORK now (I swear It didn't
:(). Strange... Anyway I cannot use it because of 1.a.
1.1 components.xml
<persistence:managed-hibernate-session
name="seamManagedHibernateSession" auto-create="true"
session-factory="#{hibernateSessionFactory}"/>
<transaction:hibernate-transaction
session="#{seamManagedHibernateSession}"/>
2. Spring namespace approach: Spring-bound session factory, referenced in components.xml,
<seam:component> added to Factory definition in application context:
<bean id="pecpHibernateSessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
scope="prototype">
<seam:component class="org.hibernate.impl.SessionFactoryImpl"/>
<property name="dataSource" ref="dataSource" />
<property name="configLocation"
value="classpath:conf/hibernate/hibernate.cfg.xml" />
<property name="configurationClass"
value="org.hibernate.cfg.AnnotationConfiguration"/>
<property name="namingStrategy">
<bean
class="egd.persistence.hibernate.extensions.UnderscoreAwareNamingStrategy"/>
</property>
</bean>
Spring listener put AFTER Seam listener in web.xml. App contexts configured from Spring
listener. Result: java.lang.IllegalStateException: No active application scope. See
seamComponentNamespaceStackTrace.txt.zip.
2.1. components.xml like in 1.1.
3. <spring:context-loader> approach. Everything like in point 2., but Spring
listener removed from web.xml.
Result: "Seam cannot wrap JDK proxied IoC beans. Please use CGLib or Javassist
proxying instead" - stracktrace in
springStartedFromSeam.txt.zip
3.1. components.xml
<core:init transaction-management-enabled="true"
debug="true"/>
<core:manager conversation-timeout="120000"
concurrent-request-timeout="500"
conversation-id-parameter="k"/>
<spring:context-loader config-locations="classpath:conf/spring/core.xml,
classpath:conf/spring/persistence-common.xml,
classpath:conf/spring/persistence-hibernate.xml,
classpath:conf/spring/statistics.xml"/>
<persistence:managed-hibernate-session
name="seamManagedHibernateSession" auto-create="true"
session-factory="#{hibernateSessionFactory}"/>
<transaction:hibernate-transaction
session="#{seamManagedHibernateSession}"/>
That's all info I can get about this. Having a model example of such integration that
I was struggling with would be a quite nice POC.
Now I need to get back to code, because I lost a lot of time lately :). Will happy live
with my current workaround for a while :).
--
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