[JBoss Seam] - seam gen war on tomcat - @startup dependency problem
by matt.drees
I've been trying to get a war seam-gen project running on Tomcat, and I've been successful at getting the right jars, I believe. However, I am having problems with the EntityManagerFactory component starting before the embedded EJB container is started (which fails because the datasource isn't in jndi). It's strange because integration tests don't have any problems.
I think the issue is the EntityManagerFactory component is declared to depend on the microcontainer, but not eejb.
(its declaration for reference:)
| @Scope(ScopeType.APPLICATION)
| @Intercept(NEVER)
| @Startup(depends="org.jboss.seam.core.microcontainer")
| public class EntityManagerFactory
|
I think during tests the ejb component is luckily started before the EMF component, but on tomcat it unluckily isn't. It seems like "org.jboss.seam.core.ejb" ought to be added to EntityManagerFacatory's startup dependency list.
Does this sound reasonable?
releveant components.xml:
| <core:managed-persistence-context name="entityManager"
| auto-create="true"
| entity-manager-factory="#{crsEntityManagerFactory}"/>
|
| <core:entity-manager-factory name="crsEntityManagerFactory"
| persistence-unit-name="crs"/>
|
| <core:ejb installed="@embeddedEjb@"/>
|
log/stacktrace:
| 11:55:21,268 INFO [Lifecycle] starting up: crsEntityManagerFactory
| 11:55:21,393 INFO [Version] Hibernate EntityManager 3.2.0.CR1
| 11:55:21,440 INFO [Version] Hibernate Annotations 3.2.0.CR1
| 11:55:21,471 INFO [Environment] Hibernate 3.2 cr2
| ...more non-interesting EMF startup stuff...
| 11:55:29,540 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.LocalOnlyContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
| 11:55:29,619 ERROR [NamingHelper] Could not obtain initial context
| javax.naming.NamingException: Local server is not initialized
| at org.jnp.interfaces.LocalOnlyContextFactory.getInitialContext(LocalOnlyContextFactory.java:45)
| at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
| at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
| at javax.naming.InitialContext.init(Unknown Source)
| at javax.naming.InitialContext.<init>(Unknown Source)
| at org.hibernate.util.NamingHelper.getInitialContext(NamingHelper.java:28)
| at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
| at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
| at org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:29)
| at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:61)
| at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1928)
| at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1211)
| at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:631)
| at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:760)
| at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:151)
| at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:205)
| at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114)
| at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
| at org.jboss.seam.core.EntityManagerFactory.startup(EntityManagerFactory.java:74)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| 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:1850)
| at org.jboss.seam.Component.callCreateMethod(Component.java:1765)
| at org.jboss.seam.Component.newInstance(Component.java:1754)
| 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)
| at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3729)
| at org.apache.catalina.core.StandardContext.start(StandardContext.java:4187)
| at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1175)
| at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:527)
| at org.apache.catalina.manager.HTMLManagerServlet.doGet(HTMLManagerServlet.java:104)
| at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
| at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
| at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
| at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
| at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
| at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
| at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
| at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
| at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
| at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
| at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
| at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
| at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
| at java.lang.Thread.run(Unknown Source)
| 11:55:29,650 FATAL [DatasourceConnectionProvider] Could not find datasource: java:/crsDatasource
| javax.naming.NamingException: Local server is not initialized
| at org.jnp.interfaces.LocalOnlyContextFactory.getInitialContext(LocalOnlyContextFactory.java:45)
| at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
| at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
| at javax.naming.InitialContext.init(Unknown Source)
| at javax.naming.InitialContext.<init>(Unknown Source)
| at org.hibernate.util.NamingHelper.getInitialContext(NamingHelper.java:28)
| at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
| at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
| at org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:29)
| at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:61)
| at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1928)
| at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1211)
| at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:631)
| at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:760)
| at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:151)
| at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:205)
| at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114)
| at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
| at org.jboss.seam.core.EntityManagerFactory.startup(EntityManagerFactory.java:74)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| 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:1850)
| at org.jboss.seam.Component.callCreateMethod(Component.java:1765)
| at org.jboss.seam.Component.newInstance(Component.java:1754)
| 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)
| at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3729)
| at org.apache.catalina.core.StandardContext.start(StandardContext.java:4187)
| at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1175)
| at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:527)
| at org.apache.catalina.manager.HTMLManagerServlet.doGet(HTMLManagerServlet.java:104)
| at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
| at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
| at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
| at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
| at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
| at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
| at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
| at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
| at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
| at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
| at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
| at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
| at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
| at java.lang.Thread.run(Unknown Source)
| 11:55:29,650 ERROR [[/crs]] Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
| javax.persistence.PersistenceException: org.hibernate.HibernateException: Could not find datasource
| at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:217)
| at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114)
| at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
| at org.jboss.seam.core.EntityManagerFactory.startup(EntityManagerFactory.java:74)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| 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:1850)
| at org.jboss.seam.Component.callCreateMethod(Component.java:1765)
| at org.jboss.seam.Component.newInstance(Component.java:1754)
| 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)
| at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3729)
| at org.apache.catalina.core.StandardContext.start(StandardContext.java:4187)
| at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1175)
| at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:527)
| at org.apache.catalina.manager.HTMLManagerServlet.doGet(HTMLManagerServlet.java:104)
| at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
| at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
| at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
| at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
| at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
| at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
| at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
| at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
| at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
| at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
| at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
| at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
| at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
| at java.lang.Thread.run(Unknown Source)
| Caused by: org.hibernate.HibernateException: Could not find datasource
| at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:56)
| at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
| at org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:29)
| at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:61)
| at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1928)
| at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1211)
| at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:631)
| at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:760)
| at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:151)
| at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:205)
| ... 38 more
| Caused by: javax.naming.NamingException: Local server is not initialized
| at org.jnp.interfaces.LocalOnlyContextFactory.getInitialContext(LocalOnlyContextFactory.java:45)
| at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
| at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
| at javax.naming.InitialContext.init(Unknown Source)
| at javax.naming.InitialContext.<init>(Unknown Source)
| at org.hibernate.util.NamingHelper.getInitialContext(NamingHelper.java:28)
| at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
| ... 47 more
| Apr 17, 2007 11:55:29 AM org.apache.catalina.core.StandardContext start
| SEVERE: Error listenerStart
| Apr 17, 2007 11:55:29 AM org.apache.catalina.core.StandardContext start
| SEVERE: Context [/crs] startup failed due to previous errors
|
persistence.xml:
| <?xml version="1.0" encoding="UTF-8"?>
| <!-- Persistence deployment descriptor for dev profile -->
| <persistence xmlns="http://java.sun.com/xml/ns/persistence"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
| version="1.0">
|
| <persistence-unit name="crs">
| <provider>org.hibernate.ejb.HibernatePersistence</provider>
| <jta-data-source>java:/crsDatasource</jta-data-source>
| <properties>
| <property name="hibernate.hbm2ddl.auto" value="update"/>
| <property name="hibernate.cache.use_query_cache" value="true"/>
| <property name="hibernate.show_sql" value="true"/>
| <property name="jboss.entity.manager.factory.jndi.name" value="java:/crsEntityManagerFactory"/>
| </properties>
| </persistence-unit>
|
| </persistence>
|
I got things working by using persistence-unit-jndi-name in components.xml, but I want to also be able to deploy to jboss as a war, which means I need to use the EntityManagerFactory component, as I understand it.
Thanks for any feedback.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4038037#4038037
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4038037
19 years, 1 month
[JBoss Seam] - Problems Starting Page Flows
by Delphi's Ghost
I've been looking into pageflows and come across a number of oddities which, maybe I'm misunderstand the where's and whens of pageflows, but maybe someone has some insights.
I have test.xml that contains a bunch of test links with the different ways of starting page flows :
Using propagation and pageflow inline on an s:link
Annotating the action method with @Begin(pageflow="TestFlow")
A plain action method that starts a page flow manually
Test.xhtml
| <s:link value="inline pageflow with xxx outcome" action="#{TestAction.stringFunc('xxx')}" propagation="begin" pageflow="TestFlow"/><br/>
| <s:link value="inline pageflow with 'page1' outcome" action="#{TestAction.stringFunc('page1')}" propagation="begin" pageflow="TestFlow"/><br/>
| <s:link value="inline pageflow with 'next' outcome" action="#{TestAction.stringFunc('next')}" propagation="begin" pageflow="TestFlow"/><br/>
| <s:link value="annotated pageflow with 'xxx' outcome" action="#{TestAction.annotatedStringFunc('xxx')}"/><br/>
| <s:link value="annotated pageflow with 'page1' outcome" action="#{TestAction.annotatedStringFunc('page1')}"/><br/>
| <s:link value="annotated pageflow with 'next' outcome" action="#{TestAction.annotatedStringFunc('next')}"/><br/>
| <s:link value="Manual PageFlow start in code" action="#{TestAction.manualStartFlow}"/><br/>
|
|
My bean actions are listed below :
| public String manualStartFlow() {
| log.info("Manual StartFlow called");
| Pageflow.instance().begin("TestFlow");
| return "ManualStartFlow";
| }
|
|
| public String stringFunc(String input) {
| log.info("Called String Func with '#0'", input);
| return input;
| }
|
| @Begin(pageflow="TestFlow")
| public String annotatedStringFunc(String input) {
| log.info("Called annotated String Func with '#0'", input);
| return input;
| }
|
|
I have added the page flow into the components.xml file and written the flow as follows :
| <?xml version="1.0"?>
|
| <pageflow-definition xmlns="http://jboss.com/products/seam/pageflow"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://jboss.com/products/seam/pageflow http://jboss.com/products/seam/pageflow-1.2.xsd"
| name="TestFlow">
|
|
| <start-page name="teststart" view-id="/testpage1.xhtml">
| <transition name="next" to="test2" />
| <transition name="ManualStartFlow" to="test2"/>
| <transition name="page1" to="test1"/>
| <redirect/>
| </start-page>
|
|
| <page name="test1" view-id="/testpage1.xhtml">
| <transition name="next" to="test2" />
| </page>
|
| <page name="test2" view-id="/testpage2.xhtml">
| <transition name="next" to="test3" />
| <transition name="prev" to="test1" />
| </page>
|
| <page name="test3" view-id="/testpage3.xhtml"
| no-conversation-view-id="/meetinglist.xhtml">
| <transition name="prev" to="test2" />
| </page>
|
| </pageflow-definition>
|
Obviosuly, this is testing code which is why page 1 appears in the start-page and test1 page.
The problem is that one of the following happens :
The conversation, and page flow starts but there is no navigation to page 1. This usually happens when the outcome is 'xxx' from the string function.
If I return "next" or "ManualStartFlow" as the outcome, I end up on page 2 of the flow
If I return "page1" from the outcome I end up on page 1, probably because of the transition from start-page to page 'page1'.
Once I am in the pages (testpage1,2 or 3) everything works fine, I just have problems starting the flow.
In cases where I stay on the same page (test.xhtml) and I end up in a conversation and try to start a new one I obviously get the Seam Debug Page because of starting a conversation from an existing one (which is fine). On the debug page, I can see the list of conversations, and despite not navigating there, they all say testpage1.xhtml in the view id. This indicates to me that the conversation and flow is starting, it's just not navigating in cases where I return 'xxx' from the outcome of the methods.
I would have thought that if you click a link, button, or call a method that starts a pageflow, then you would automatically end up on the view-id referenced by the start-page definition (in this case testpage1). Currently it looks like I need to return an outcome that will determine where you go automatically from the page-start view id, and not returning an expected outcome results in staying on the same page.
Is that the case?
DG
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4038030#4038030
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4038030
19 years, 1 month