0 Replies Latest reply: May 17, 2012 5:19 AM by 栗原 政彦 RSS

    Lookup failure of UserTransaction

    栗原 政彦 Newbie

      Lookup failure of UserTransaction

       

      Standanone Java Aplication is made, and it tries to do the EJB call with Remote.
      Because UserTransaction is not good at lookup, I am embarrassed.

      Is the specification of the JNDI name bad?

       

      Environment
      ==========

      Red Hat Enterprise Linux Server release 5.5 Beta (Tikanga)
      JBossAS7.1.0 Final
      java version "1.7.0_02"
      Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
      Java HotSpot(TM) Server VM (build 22.0-b10, mixed mode)

       

      It tries to access Remote EJB by using jboss-client-7.1.0.Final.jar

       

      SourceCode
      ==========

      final Properties env = new Properties();
      env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
      env.put(Context.PROVIDER_URL,"remote://localhost:4447");
      env.put(Context.SECURITY_PRINCIPAL, "apuser");
      env.put(Context.SECURITY_CREDENTIALS, "apuserpass");
      context = new InitialContext(env);

      UserTransaction userTransaction = (UserTransaction) context.lookup("java:comp/UserTransaction");

      At lookup, the following exception is generated.

      javax.naming.NameNotFoundException: comp/UserTransaction -- service jboss.naming.context.java.jboss.exported.comp.UserTransaction
      at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:97)
      at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:177)
      at org.jboss.naming.remote.protocol.v1.Protocol$1.handleServerMessage(Protocol.java:124)
      at org.jboss.naming.remote.protocol.v1.RemoteNamingServerV1$MessageReciever$1.run(RemoteNamingServerV1.java:70)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
      at java.lang.Thread.run(Thread.java:722)

       

      Relating file

      ========

       

      jndi.properties
      ===============

      java.naming.provider.url=remote://localhost:4447
      java.naming.factory.url.pkgs=org.jboss.ejb.client.naming

       

      jboss-ejb-client.properties
      ===========================

      remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
      remote.connections=default
      remote.connection.default.host=localhost
      remote.connection.default.port=4447
      remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
      remote.connection.default.username=admin
      remote.connection.default.password=password


      Supplementation matter

      Security has been added with add-user.sh as an application user. apuser/apuserpass


      Referred URL

      ==========

       

      EJB invocations from a remote client using JNDI
      https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI

      Examples of JNDI mappings in previous releases and how they might look now

      https://docs.jboss.org/author/display/AS71/How+do+I+migrate+my+application+from+AS5+or+AS6+to+AS7

      UserTransaction
      New Namespaces

       

      java:comp/UserTransaction
      java:jboss/UserTransaction

       

      Neither lookup can be done.