[jboss-jira] [JBoss JIRA] (AS7-4435) CLONE - EAR deployment with initialize-in-order doesn't wait for persistence-unit if it's not used in the module

Stuart Douglas (JIRA) jira-events at lists.jboss.org
Tue Apr 10 20:52:54 EDT 2012


     [ https://issues.jboss.org/browse/AS7-4435?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stuart Douglas resolved AS7-4435.
---------------------------------

    Resolution: Done

    
> CLONE - EAR deployment with initialize-in-order doesn't wait for persistence-unit if it's not used in the module
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: AS7-4435
>                 URL: https://issues.jboss.org/browse/AS7-4435
>             Project: Application Server 7
>          Issue Type: Bug
>          Components: EE
>    Affects Versions: 7.1.1.Final
>         Environment: EAP 6.0.0.ER4.1, Seam 2.3.0.Beta2-SNAPSHOT (2012-04-06)
>            Reporter: Marek Schmidt
>            Assignee: Stuart Douglas
>              Labels: eap6_need_triage
>             Fix For: 7.1.2.Final-redhat1
>
>
> I have an Seam2 EAR application (Blog example from Seam distribution) which almost always fails to deploy with
> {noformat}
> javax.naming.NameNotFoundException: Error looking up blogEntityManagerFactory, service service jboss.naming.context.java.blogEntityManagerFactory is not started
> {noformat}
> The application.xml looks like this:
> {noformat}
> <?xml version="1.0" encoding="UTF-8"?>                                                                                                                                                                              
> <application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.x
> sd" version="6">                                                                                                                                                                                                    
>   <description>Examples for Seam 2 Framework in Java EE6 environment</description>                                                                                                                                  
>   <display-name>blog-ear</display-name>                                                                                                                                                                             
>   <initialize-in-order>true</initialize-in-order>                                                                                                                                                                   
>   <module>                                                                                                                                                                                                          
>     <ejb>blog-ejb.jar</ejb>                                                                                                                                                                                         
>   </module>                                                                                                                                                                                                         
>   <module>                                                                                                                                                                                                          
>     <web>                                                                                                                                                                                                           
>       <web-uri>blog-web.war</web-uri>                                                                                                                                                                               
>       <context-root>/seam-blog</context-root>                                                                                                                                                                       
>     </web>                                                                                                                                                                                                          
>   </module>                                                                                                                                                                                                         
>   <module>                                                                                                                                                                                                          
>     <ejb>jboss-seam.jar</ejb>                                                                                                                                                                                       
>   </module>                                                                                                                                                                                                         
>   <library-directory>lib</library-directory>                                                                                                                                                                        
> </application>   
> {noformat}
> The blog-ejb.jar contains persistence.xml:
> {noformat}
>                                                                                                                 
> <?xml version="1.0" encoding="UTF-8"?>                                        
> <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="entityManager">                                                                                                                                                                          
>       <provider>org.hibernate.ejb.HibernatePersistence</provider>                                                                                                                                                   
>       <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>                                                                                                                                           
>       <properties>                                                                                                                                                                                                  
>          <property name="hibernate.hbm2ddl.auto" value="create-drop"/>                                                                                                                                              
>          <property name="hibernate.show_sql" value="true"/>                                                                                                                                    
>                                                                                                                                                                                                                    
>          <property name="hibernate.cache.use_second_level_cache" value="true"/>                                                                                                                                     
>          <property name="hibernate.cache.use_query_cache" value="true"/>                                                                                                                                            
>          <property name="jboss.entity.manager.factory.jndi.name" value="java:/blogEntityManagerFactory"/>                                                                                                                                                                                                                                                 
>          <property name="hibernate.search.default.directory_provider" value="filesystem"/>                                                                                                                                                                                                                                                                  
>          <property name="hibernate.search.default.indexBase" value="./blogindexes"/>                                                                                                                                
>       </properties>                                                                                                                                                                                                 
>    </persistence-unit>                                                                                                                                                                                              
> </persistence>  
> {noformat}
> The persistence unit is accessed in Seam via JNDI
> (components.xml)
> {noformat}
>  <persistence:managed-persistence-context name="entityManager"                                                                                                                                                    
>                                             auto-create="true"                                                                                                                                                      
>                                             persistence-unit-jndi-name="java:/blogEntityManagerFactory"/>
> {noformat}
> This (usually) fails in the IndexerService, which is started automatically during servlet startup, as the java:/blogEntityManagerFactory is not yet ready. 
> Note that in the application.xml the "initialize-in-order" is defined, so the web module should not start before the blog-ejb.jar ( which contains the persistence.xml), is started. 
> Source of IndexerService:
> {noformat}
> package actions;
> import javax.ejb.Remove;
> import org.hibernate.search.jpa.FullTextEntityManager;
> import org.jboss.seam.ScopeType;
> import org.jboss.seam.annotations.Create;
> import org.jboss.seam.annotations.Destroy;
> import org.jboss.seam.annotations.In;
> import org.jboss.seam.annotations.Name;
> import org.jboss.seam.annotations.Scope;
> import org.jboss.seam.annotations.Startup;
> /**
>  * Index Blog entry at startup
>  *
>  * @author Emmanuel Bernard
>  * @author Sanne Grinovero
>  */
> @Name("indexerService")
> @Scope(ScopeType.APPLICATION)
> @Startup
> public class IndexerService
> {
>    @In
>    private FullTextEntityManager entityManager;
>    @Create
>    public void index() {
>       entityManager.createIndexer().start();
>    }
>    @Remove
>    @Destroy
>    public void stop() {}
> }
> {noformat}
> Also note that if I add the following bean to seam-ejb.jar it will correctly wait with the deployment of the web archive:
> {noformat}
> import javax.persistence.PersistenceUnit;
> import javax.persistence.EntityManagerFactory;
> import javax.ejb.Singleton;
> import javax.ejb.Startup;
> @Singleton
> @Startup
> public class Aargh
> {
>    @PersistenceUnit
>    private EntityManagerFactory emf;
> }
> {noformat}
> I believe this workaround shouldn't be necessary, and the initialize-in-order should also work with persistence units. 
> This issue affects all Seam2 EAR applications which use seam-managed entity manager in a @Startup bean, or any other legacy applications accessing persistence units through JNDI.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list