2 Replies Latest reply on Jun 18, 2013 8:17 AM by m.improta

    CDI support - Persistence unit hanging when deploying

    m.improta

      When using the CDI support in Infinispan 5.1.2.FINAL to define a Producer, the JBoss 7.1.1 hangs in the persistence unit when starting the deployment unit.

      This is the crime scene:

       

      public class CacheFactory {

       

          @ConfigureCache("myCache")

          @MyCache

          @Produces

          public Configuration createOptionScreenerCacheConfig() {

              return new ConfigurationBuilder()

       

              .transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL)

       

              .eviction().maxEntries(10000).strategy(EvictionStrategy.LRU)

       

                      .build();

          }

       

      Otherwise, here is the output of the JBoss deployment:

       

      09:27:18,076 INFO  [org.jboss.weld.deployer] (MSC service thread 1-3) JBAS016005: Starting Services for CDI deployment: ngp-core-ear-0.0.9-SNAPSHOT.ear

      09:27:18,078 INFO  [org.jboss.weld.deployer] (MSC service thread 1-17) JBAS016008: Starting weld service for deployment ngp-core-ear-0.0.9-SNAPSHOT.ear

      09:27:18,119 INFO  [org.infinispan.cdi.InfinispanExtension] (MSC service thread 1-17) ISPN017001: Infinispan CDI extension version: 5.1.2.FINAL

      09:27:18,122 INFO  [org.jboss.solder.config.xml.bootstrap.XmlConfigExtension] (MSC service thread 1-17) Solder Config XML provider starting...

      09:27:18,124 INFO  [org.jboss.solder.config.xml.bootstrap.XmlConfigExtension] (MSC service thread 1-17) Loading XmlDocumentProvider: org.jboss.solder.config.xml.bootstrap.ResourceLoaderXmlDocumentProvider

      09:27:18,128 INFO  [org.jboss.solder.Version] (MSC service thread 1-17) Solder 3.1.0.Final (build id: 3.1.0.Final)

      09:27:18,438 INFO  [org.jboss.as.jpa] (MSC service thread 1-9) JBAS011402: Starting Persistence Unit Service 'ngp-core-ear-0.0.9-SNAPSHOT.ear/ngp-core-war-0.0.9-SNAPSHOT.war#ngpcore'

      09:27:18,439 INFO  [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-9) HHH000204: Processing PersistenceUnitInfo [

          name: ngpcore

          ...]

      09:27:18,478 INFO  [org.jboss.as.ejb3] (MSC service thread 1-15) JBAS014142: Started message driven bean 'CoreEventMDB' with 'hornetq-ra-0.0.2' resource adapter

      09:27:18,581 INFO  [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (MSC service thread 1-9) HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider

      09:27:18,584 INFO  [org.hibernate.dialect.Dialect] (MSC service thread 1-9) HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect

      09:27:18,586 INFO  [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] (MSC service thread 1-9) HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory

      09:27:18,587 INFO  [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (MSC service thread 1-9) HHH000397: Using ASTQueryTranslatorFactory

       

       

      Here it hangs for a while, 'til it outputs:

       

       

      09:28:16,905 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "ngp-core-ear-0.0.9-SNAPSHOT.ear" was rolled back with failure message Operation cancelled

      09:28:16,905 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015052: Did not receive a response to the deployment operation within the allowed timeout period [60 seconds]. Check the server configuration file and the server logs to find more about the status of the deployment.

      09:28:16,929 INFO  [org.jboss.as.jpa] (MSC service thread 1-3) JBAS011403: Stopping Persistence Unit Service 'ngp-core-ear-0.0.9-SNAPSHOT.ear/ngp-core-war-0.0.9-SNAPSHOT.war#ngpcore'

       

       

      If I comment out the @ConfigureCache, it works fine (yet without cache...).

       

      The definition of the persistence unit in persistence.xml it's pretty simple:

       

      <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_2_0.xsd"

          version="2.0">

          <persistence-unit name="ngpcore">

              <jta-data-source>java:/ngpcore</jta-data-source>

          </persistence-unit>

      </persistence>

       

       

      Using MySql, this is modules/com/mysql/main/module.xml:

       

      <?xml version="1.0" encoding="UTF-8"?>

       

      <module xmlns="urn:jboss:module:1.0" name="com.mysql">

        <resources>

          <resource-root path="mysql-connector-java-5.1.21-bin.jar"/>

        </resources>

        <dependencies>

          <module name="javax.api"/>

          <module name="javax.transaction.api"/>

        </dependencies>

      </module>

       

       

      This is the datasource configuration in standalone.xml:

       

       

                      <xa-datasource jta="true" jndi-name="java:/ngpcore" pool-name="ngp-core" enabled="true" use-java-context="true" use-ccm="true">

                          <xa-datasource-property name="ServerName">

                              localhost

                          </xa-datasource-property>

                          <xa-datasource-property name="DatabaseName">

                              ngp_core

                          </xa-datasource-property>

                          <driver>mysql</driver>

                          <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>

                          <xa-pool>

                              <min-pool-size>5</min-pool-size>

                              <max-pool-size>30</max-pool-size>

                              <prefill>true</prefill>

                          </xa-pool>

                          <security>

                              <user-name>user</user-name>

                              <password>pass</password>

                          </security>

                          <validation>

                              <validate-on-match>false</validate-on-match>

                              <background-validation>false</background-validation>

                          </validation>

                          <statement>

                              <prepared-statement-cache-size>1000</prepared-statement-cache-size>

                              <share-prepared-statements>true</share-prepared-statements>

                          </statement>

                      </xa-datasource>

       

       

      It doesn't work even when defining the datasource not as xa.

       

      Any help would be appreciated, as this trouble it's jinxing me for a while.

        • 1. Re: CDI support - Persistence unit hanging when deploying
          m.improta

          The JBoss seems to get in trouble when defining Infinispan caches in standalone.xml AND via CDI.

          As I was already configuring the Hibernate second level cache in standalone.xml, now I configure there also myCache:

           

           

                  <subsystem xmlns="urn:jboss:domain:infinispan:1.2" default-cache-container="hibernate">

                      <cache-container name="hibernate" default-cache="local-query">

                          <local-cache name="entity">

                              <transaction mode="NON_XA"/>

                              <eviction strategy="LRU" max-entries="10000"/>

                              <expiration max-idle="100000"/>

                          </local-cache>

                          <local-cache name="local-query">

                              <transaction mode="NONE"/>

                              <eviction strategy="LRU" max-entries="10000"/>

                              <expiration max-idle="100000"/>

                          </local-cache>

                          <local-cache name="timestamps">

                              <transaction mode="NONE"/>

                              <eviction strategy="NONE"/>

                          </local-cache>

                      </cache-container>

                      <cache-container name="myContainer" default-cache="myCache" jndi-name="java:jboss/infinispan/myContainer">

                          <local-cache name="myCache">

                              <transaction mode="NON_XA"/>

                              <eviction strategy="LRU" max-entries="10000"/>

                              <expiration max-idle="30000"/>

                          </local-cache>

                      </cache-container>

                  </subsystem>

           

           

          The factory class is now merely a retrieval of the cache defined in standalone.xml:

           

          public class CacheFactory {

              @Resource(lookup = "java:jboss/infinispan/myContainer")

              private CacheContainer container;

           

              @MyCache

              @Produces

              public Cache<String, ModuleResponseCacheEntry> getCache() {

                  return container.getCache("myCache");

              }

          }

           

           

          I still would appreciate any suggestion to be able to configure the Cache via CDI.

          1 of 1 people found this helpful
          • 2. Re: CDI support - Persistence unit hanging when deploying
            m.improta

            I appreciate any help. Thanks in advance.