Define JNDI for EntityManager Wildfly 26.0.0.Final
I tried to update a web app from jboss 5.1.0.GA to Wildfly 26.0.0.Final.
I use:
- jboss-seam 2.2.1.CR2
- jdk 8u202
The last error was:
ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 36) MSC000001: Failed to start service jboss.deployment.subunit."example.ear"."example.war".undertow-deployment: org.jboss.msc.service.StartException in service jboss.deployment.subunit."example.ear"."example.war".undertow-deployment: java.lang.RuntimeException: org.jboss.seam.InstantiationException: Could not instantiate Seam component: controlEnvioSumas
Caused by: java.lang.IllegalArgumentException: EntityManagerFactory not found in JNDI : java:/exampleEntityManagerFactory at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManagerFactoryFromJndiOrValueBinding(ManagedPersistenceContext.java:261)
Caused by: javax.naming.NameNotFoundException: exampleEntityManagerFactory -- service jboss.naming.context.java.exampleEntityManagerFactory
Update a web app from jboss 5.1.0.GA to Wildfly 26.Final And updated jars and persistence.xml and components.xml and jboss-deployment-structure.xml
Here is my files configurations:
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence>
<persistence-unit name="example">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/exampleDatasource</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
<property name="hibernate.connection.release_mode" value="auto"/>
<property name="hibernate.transaction.flush_before_completion" value="true"/>
<property name="hibernate.transaction.auto_close_session" value="false"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.use_sql_comments" value="false"/>
<property name="jboss.entity.manager.jndi.name" value="java:/exampleEntityManager"/>
<property name="jboss.entity.manager.factory.jndi.name" value="java:/exampleEntityManagerFactory"/>
<property name="hibernate.jdbc.batch_size" value="2000"/>
<property name="hibernate.jdbc.fetch_size" value="1000"/>
<property name="hibernate.cache.use_second_level_cache" value="false"/>
<property name="hibernate.cache.use_query_cache" value="false"/>
<property name="hibernate.default_batch_fetch_size" value="1000"/>
<property name="hibernate.order_inserts" value="true"/>
<property name="hibernate.order_updates" value="true"/>
<property name="hibernate.jdbc.batch_versioned_data" value="true"/>
</properties>
</persistence-unit>
</persistence>
components.xml:
<?xml version="1.0" encoding="UTF-8"?>
<components >
<core:init debug="@debug@" jndi-pattern="@jndiPattern@"/>
<core:manager concurrent-request-timeout="500"
conversation-timeout="12000000"
conversation-id-parameter="cid"
parent-conversation-id-parameter="pid"/>
<web:hot-deploy-filter url-pattern="*.seam"/>
<persistence:managed-persistence-context name="entityManager" auto-create="true" persistence-unit-jndi-name="java:/exampleEntityManagerFactory"/>
<drools:rule-base name="securityRules">
<drools:rule-files>
<value>/security.drl</value>
</drools:rule-files>
</drools:rule-base>
<security:rule-based-permission-resolver security-rules="#{securityRules}"/>
<security:identity authenticate-method="#{authenticator.authenticate}" remember-me="true"/>
<event type="org.jboss.seam.security.notLoggedIn">
<action execute="#{redirect.captureCurrentView}"/>
</event>
<event type="org.jboss.seam.security.loginSuccessful">
<action execute="#{redirect.returnToCapturedView}"/>
</event>
<web:multipart-filter create-temp-files="true"
max-request-size="100000000"
url-pattern="*.seam" />
<async:quartz-dispatcher/>
</components>
jboss-deployment-structure.xml:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
<deployment>
<dependencies>
<module name="org.hibernate.validator" />
</dependencies>
<resources>
<resource-root path="jboss-seam.jar" />
</resources>
</deployment>
<sub-deployment name="example.war">
<dependencies>
<module name="deployment.example.ear.example.jar" />
</dependencies>
</sub-deployment>
</jboss-deployment-structure>