LocalEjbSynchronizations JNDI lookup fails despite being initialized - Seam 2.2.0 and Glassfish
arsenalist Jan 18, 2010 6:57 PMI'm getting the following exception when I try to run my application on Seam 2.2.0 and Glassfish V2. I've shown the relevant bits of the stacktrace. I tried
java.lang.IllegalStateException: Could not start transaction at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:598) at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:583) at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsBeforePhase(SeamPhaseListener.java:327) at org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:144) Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.transaction.synchronizations at org.jboss.seam.Component.newInstance(Component.java:2144) at org.jboss.seam.Component.getInstance(Component.java:2021) at org.jboss.seam.Component.getInstance(Component.java:2000) Caused by: javax.naming.NameNotFoundException at com.sun.enterprise.naming.TransientContext.resolveContext(TransientContext.java:268) at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:191) at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:74) at com.sun.enterprise.naming.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:111) at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:398) at javax.naming.InitialContext.lookup(InitialContext.java:392) at org.jboss.seam.Component.instantiateSessionBean(Component.java:1400) at org.jboss.seam.Component.instantiate(Component.java:1364) at org.jboss.seam.Component.newInstance(Component.java:2122)
It's complaining about the org.jboss.seam.transaction.synchronizations component not being instantiated, but I see the following in the logs:
Component: org.jboss.seam.transaction.synchronizations, scope: EVENT, type: STATEFUL_SESSION_BEAN, class: org.jboss.seam.transaction.EjbSynchronizations, JNDI: library/EjbSynchronizations/local
I looked at the source code for Component.java and it fails at the following line.
Object bean = Naming.getInitialContext().lookup(jndiName);
This indicates that the jndiName can't be found, but I don't see what I'm doing wrong. The relevant sections of my config are below. My ear is named library.ear so the JNDI pattern library/#{ejbName}/local should resolve correctly:
Any help would be appreciated:
persistence.xml:
<persistence-unit name="libraryDatabase" transaction-type="JTA"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>jdbc/Library</jta-data-source> <properties> <property name="hibernate.show_sql" value="true"/> <property name="hibernate.transaction.flush_before_completion" value="true"/> <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.SunONETransactionManagerLookup" /> </properties> </persistence-unit>
components.xml:
<core:init jndi-pattern="library/#{ejbName}/local" debug="true"/> <transaction:ejb-transaction /> <persistence:entity-manager-factory name="dbFactory" persistence-unit-name="libraryDatabase"/> <persistence:managed-persistence-context name="em" auto-create="true" entity-manager-factory="#{dbFactory}" /> <ui:jpa-entity-loader entity-manager="#{em}"/>
application.xml:
<?xml version="1.0" encoding="UTF-8"?> <application> <display-name>library-ear</display-name> <module> <web> <web-uri>library.war</web-uri> <context-root>/library</context-root> </web> </module> <module> <ejb>library-ejbs-1.0-SNAPSHOT.jar</ejb> </module> <module> <ejb>jboss-seam-2.2.0.GA.jar</ejb> </module> </application>
web.xml:
<ejb-local-ref> <ejb-ref-name>library/LibraryManagerBean/local</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local>com.company.LibraryManager</local> </ejb-local-ref> <ejb-local-ref> <ejb-ref-name>library/EjbSynchronizations/local</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local>org.jboss.seam.transaction.LocalEjbSynchronizations</local> </ejb-local-ref>