2 Replies Latest reply on Aug 12, 2019 4:37 AM by Alex Luwal

    JndiException: Unable to lookup JNDI name [java:jboss/TransactionManager]

    Alex Luwal Newbie

      This exception I have got in time of deployment for most simple EJB+JPA application (for xa-datasource) without maven pom (WildFly 16/17, template was generated by Eclipse 2019-6 - File -> New -> EJB Project):

      Project's Java classes are not essential, may by Entity-POJO only (very simple too - id and message fields with getters/setters) as exception thrown on deployment stage.

       

      I've tried to find similar case for app deployment but without success. It's some strange situation. Especially, TransactionManager is present on JNDI and shown on Admin page:

       

      Summary for error on log:

      ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 1) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "MulticEJB.jar")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"MulticEJB.jar#MulticEJB\"" => "javax.persistence.PersistenceException: [PersistenceUnit: MulticEJB] Unable to build Hibernate SessionFactory

          Caused by: javax.persistence.PersistenceException: [PersistenceUnit: MulticEJB] Unable to build Hibernate SessionFactory

          Caused by: org.hibernate.engine.jndi.JndiException: unable to find transaction manager

          Caused by: org.hibernate.engine.jndi.JndiException: Unable to lookup JNDI name [java:jboss/TransactionManager]

          Caused by: javax.naming.NameNotFoundException: jboss -- service jboss.naming.context.java.jboss.exported.jboss"}}

       

      Configs is:

       

      jndi.properties

      java.naming.factory.initial=org.wildfly.naming.client.WildFlyInitialContextFactory

      java.naming.provider.url=http-remoting://localhost:8080

      # credential as login to Admin page

      java.naming.security.principal=master

      java.naming.security.credentials=masterpass

       

      persistence.xml

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

      <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence"

          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

          xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">

         

          <persistence-unit name="MulticEJB" transaction-type="JTA">

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

              <class>dev.packs.entity.TableOne</class>

               <properties>

                  <property name="hibernate.hbm2ddl.auto" value="update" />

                  <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />

                </properties>

          </persistence-unit>

      </persistence>

       

      standalone.xml

      <xa-datasource jndi-name="java:/MySqlTestXA" pool-name="MySqlTestXA">

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

              localhost

          </xa-datasource-property>

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

              test

          </xa-datasource-property>

          <xa-datasource-class>com.mysql.cj.jdbc.MysqlXADataSource</xa-datasource-class>

          <driver>mysql</driver>

          <xa-pool>

              <min-pool-size>2</min-pool-size>

              <max-pool-size>10</max-pool-size>

          </xa-pool>

          <security>

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

              <password>123456</password>

          </security>

      </xa-datasource>

      <driver name="mysql" module="com.mysql"/>

       

      module.xml

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

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

          <resources>

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

          </resources>

          <dependencies>

              <module name="javax.api"/>

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

          </dependencies>

      </module>

       

      P.S. I suppose that my experience is not enought for XA-datasource and Narayana details but I can't to find the way to go futher and deep (JNDI? XA? Hibernate? pom-configuration only? etc.)

        • 1. Re: JndiException: Unable to lookup JNDI name [java:jboss/TransactionManager]
          Frank Langelage Master

          Try to deploy the jar file without jndi.properties file inside.

          • 2. Re: JndiException: Unable to lookup JNDI name [java:jboss/TransactionManager]
            Alex Luwal Newbie

            Thanks for respond Frank! Its work. Unfortunately it's bad pattern from examples here.

             

            jndi.properties used for Client class only. This Client was used for quick bean lookup demonstration after deployment to AS and example works for most primitive methods like as return "OK". Otherwise, Client needs for another project for properly work.

             

            In this case Bean gathers from jndi.properties and try to find JNDI through http-remoting://localhost:8080. So Bean doesn't see java:boss namespace from remote JNDI request and deployment failed when needs for update datasource.

             

            In additional, I was some misleaded here by mark from WildFly documentation (13. Local JNDI): "Only entries within the java:jboss/exported context are accessible over remote JNDI" and tried to use <xa-datasource jndi-name="java:jboss/exported/MySqlTestXA">. But for this case I've lost attention in mention java:jboss/TransactionManager - it's without "exported".

             

            Good sound for me here is motivation to read lot of documentation and thank you again for support.