[jboss-jira] [JBoss JIRA] Commented: (JBAS-8687) JPA2 persistence.xml in WEB-INF\classes\META-INF\ not allways deployed before Web context initialisation
Geert Pante (JIRA)
jira-events at lists.jboss.org
Thu Dec 2 17:44:05 EST 2010
[ https://jira.jboss.org/browse/JBAS-8687?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12567303#comment-12567303 ]
Geert Pante commented on JBAS-8687:
-----------------------------------
Hi there,
I can get you the stacktrace next week.
But it's quite simple: we use the Spring ContextLoaderListener which is configured as a <listener> in web.xml, and this initializes the beans, configured in a separate XML, on the contextInitialized event as defined by the Servlet API: http://download.oracle.com/javaee/1.4/api/javax/servlet/ServletContextListener.html?is-external=true. This event is supposedly raised before initializing any filters or servlets, but I guess it should be after initializing JPA PersistenceUnits.
The XML snippet will result in:
Object entityManagerFactory = new InitialContext(null).lookup("java:jpa/CasEntityManagerFactory")
I want to repeat that 4 out of 5 times, this works like a charm.
We do have another web application on the same JBoss Instance, this one does not use a persistence.xml, but creates a Hibernate Configuration within the Spring ApplicationContext, so that works allways.
> JPA2 persistence.xml in WEB-INF\classes\META-INF\ not allways deployed before Web context initialisation
> --------------------------------------------------------------------------------------------------------
>
> Key: JBAS-8687
> URL: https://jira.jboss.org/browse/JBAS-8687
> Project: JBoss Application Server
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: EJB3
> Affects Versions: 6.0.0.CR1
> Environment: JBossAS [6.0.0.20101110-CR1 "Neo"]
> Java Runtime: Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
> Java VM: Java HotSpot(TM) 64-Bit Server VM 17.1-b03,Sun Microsystems Inc.
> OS-System: Windows 7 6.1,amd64
> Unchanged default profile, with Oracle DataSource.
> Reporter: Geert Pante
> Assignee: Carlo de Wolf
> Labels: deployer, jpa
> Attachments: persistence.xml
>
>
> I'm trying to run JASig CAS (http://www.jasig.org/cas) using the JpaTicketRegistry. This is done by putting a persistence.xml in WEB-INF\classes\META-INF with:
> <property name="jboss.entity.manager.factory.jndi.name" value="java:jpa/CasEntityManagerFactory"/>
> I refer to it from my Spring applicationContext
> <jee:jndi-lookup id="entityManagerFactory" jndi-name="java:jpa/CasEntityManagerFactory"/>.
> Most of the times this starts up correctly: first deploying and binding the Persistence Unit, and then starting the WebApplicationContext.
> But once every 5 times, it starts in the wrong order: we first get
> 13:13:55,150 INFO [TomcatDeployment] deploy, ctxPath=/cas
> 13:13:55,204 INFO [[/cas]] Initializing Spring root WebApplicationContext
> 13:13:55,204 INFO [ContextLoader] Root WebApplicationContext: initialization started
> 13:13:55,208 INFO [XmlWebApplicationContext] Refreshing Root WebApplicationContext: startup date [Tue Nov 30 13:13:55 CET 2010]; root of context hierarchy
> 13:13:56,039 ERROR [ContextLoader] Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: jpa not bound
> [...]
> 13:13:56,088 ERROR [StandardContext] Error filterStart
> 13:13:56,088 ERROR [StandardContext] Context [/cas] startup failed due to previous errors
> 13:13:56,089 INFO [[/cas]] Closing Spring root WebApplicationContext
> 13:13:56,095 ERROR [AbstractKernelController] Error installing to Start: name=jboss.web.deployment:war=/cas state=Create mode=Manual requiredState=Installed: org.jboss.deployers.spi.DeploymentException: URL file:/D:/Applications/jboss-6.0.0.CR1/server/mbip/deploy/cas-server-webapp-3.4.2.BAYER_7-SNAPSHOT.war/ deployment failed
> And only after this we get:
> 13:13:56,113 INFO [PersistenceUnitDeployment] Starting persistence unit persistence.unit:unitName=cas-server-webapp-3.4.2.EBIT_7-SNAPSHOT.war#CasPersistence
> 13:13:56,287 INFO [Version] Hibernate Commons Annotations 3.2.0.Final
> 13:13:56,294 INFO [Environment] Hibernate 3.6.0.Final
> 13:13:56,296 INFO [Environment] hibernate.properties not found
> 13:13:56,300 INFO [Environment] Bytecode provider name : javassist
> 13:13:56,304 INFO [Environment] using JDK 1.4 java.sql.Timestamp handling
> 13:13:56,393 INFO [Version] Hibernate EntityManager 3.6.0.Final
> 13:13:56,421 INFO [Ejb3Configuration] Processing PersistenceUnitInfo [
> name: CasPersistence
> ...]
> 13:13:56,928 INFO [SessionFactoryImpl] building session factory
> 13:13:57,137 INFO [SessionFactoryObjectFactory] Factory name: persistence.unit:unitName=cas-server-webapp-3.4.2.EBIT_7-SNAPSHOT.war#CasPersistence
> 13:13:57,139 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
> 13:13:57,141 INFO [SessionFactoryObjectFactory] Bound factory to JNDI name: persistence.unit:unitName=cas-server-webapp-3.4.2.EBIT_7-SNAPSHOT.war#CasPersistence
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list