1 Reply Latest reply on May 14, 2004 2:26 AM by Juha Lindfors

    "env not bound" when deploying session bean - how to bind JN

    Heath Dill Newbie

      I am deploying a simple EJB, building using xdoclet, snippets of which follow:

      public class TopicSenderEJB extends BaseStatelessSessionEJB
      {
       /**
       * @ejb.bean
       * name="TopicSenderEJB"
       * jndi-name="ejb/TopicSenderEJB"
       * local-jndi-name="ejb/local/TopicSenderEJB"
       * type="Stateless"
       * view-type="local"
       *
       * @ejb.transaction
       * type="Supports"
       *
       * @ejb.util
       * generate="logical"
       */
      
      ....
       /**
       * ejbCreate()
       *
       * @ejb.create-method
       *
       * @ejb.transaction
       * type="Required"
       */
       public void ejbCreate() throws CreateException
       {
       Context context = null;
      
       try
       {
       context = new InitialContext();
      
       m_topic = (Topic)context.lookup("java:jms/TestTopic");
      
       TopicConnectionFactory connectionFactory = (TopicConnectionFactory)context.lookup("jms/TopicConnectionFactory");
      
       m_topicConnection = connectionFactory.createTopicConnection();
       }
       catch(Exception e)
       {
       throw new CreateException(e.getMessage());
       }
       }
      

      Which generates the following in jboss.xml:
       <session>
       <ejb-name>TopicSender</ejb-name>
       <jndi-name>TopicSender</jndi-name>
       <local-jndi-name>TopicSenderLocal</local-jndi-name
       </session>
      

      and the following names in TopicSenderHome.java:
       public static final String COMP_NAME="java:comp/env/ejb/TopicSender";
       public static final String JNDI_NAME="TopicSender";
      


      This final bit becomes troublesome when I deploy the bean; I get the following:

      24626 [main] ERROR com.authentica.jmstest.TopicMessagingService - Could not create TopicSender; exception in TopicSenderLocalHome.create()
      24657 [main] ERROR org.jboss.deployment.MainDeployer - could not create deployment: file:/C:/Programming/jboss/jmstest/server/default/tmp/deploy/tmp65483jmstes
      t.ear-contents/jmstest-service.sar
      org.jboss.deployment.DeploymentException: create operation failed for package file:/C:/Programming/jboss/jmstest/server/default/tmp/deploy/tmp65483jmstest.ear-c
      ontents/jmstest-service.sar; - nested throwable: (org.jboss.deployment.DeploymentException: Could not create TopicSender.env not bound; - nested throwable: (jav
      a.lang.RuntimeException: Could not create TopicSender.env not bound))
      at org.jboss.deployment.SARDeployer.create(SARDeployer.java:202)
      at org.jboss.deployment.MainDeployer.create(MainDeployer.java:786)
      at org.jboss.deployment.MainDeployer.create(MainDeployer.java:778) etc...

      Why is "env" not bound, and how can I remedy this? I was unable to find much in the JNDI documentation about binding specific namespaces before an EJB is deployed.

      -HDill

        • 1. Re:
          Juha Lindfors Master

          You're not showing all the relevant deployment descriptors to solve your problem. However, you will need to have an ejb reference in your ejb-jar.xml that links the private java:comp/env/ejb/TopicSender name to your TopicSender bean.

          HTH