Discussions

EJB programming & troubleshooting: javax.naming.NameNotFoundException: xas not bound

  1. Hi, Can someone give an advise or idea on how to solve this problem. I already faced this problem since 3 weeks and could not find any solution. Here is error that i got: 11:57:58,790 ERROR [LoginBean] ADM-LoginBean-[ejbCreate]-Exception in CreateException javax.naming.NameNotFoundException: XAS not bound at org.jnp.server.NamingServer.getBinding(NamingServer.java:529) at org.jnp.server.NamingServer.getBinding(NamingServer.java:537) at org.jnp.server.NamingServer.getObject(NamingServer.java:543) at org.jnp.server.NamingServer.lookup(NamingServer.java:296) at org.jnp.server.NamingServer.lookup(NamingServer.java:270) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:774) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627) at javax.naming.InitialContext.lookup(InitialContext.java:351) at com.xybase.xas.helper.DataSourceFactory.getDataSource(DataSourceFactory.java:127) at com.xybase.xas.xadm.ejb.LoginBean.ejbCreate(LoginBean.java:105) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.jboss.ejb.StatelessSessionEnterpriseContext.(StatelessSessionEnterpriseContext.java:78) at org.jboss.ejb.plugins.StatelessSessionInstancePool.create(StatelessSessionInstancePool.java:49) at org.jboss.ejb.plugins.AbstractInstancePool.get(AbstractInstancePool.java:184) at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invokeHome(StatelessSessionInstanceInterceptor.java:95) at org.jboss.ejb.plugins.CallValidationInterceptor.invokeHome(CallValidationInterceptor.java:56) at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:125) As what I understand, there is problem when program to getconnection to database at this line: public static DataSource getDataSource(String jndiName) throws NamingException { DataSourceFactory instance = getInstance(); DataSource ds = (DataSource) instance.cache.get(jndiName); if (ds == null) { ds = (DataSource) ctx.lookup(jndiName); instance.cache.put(jndiName, ds); } return ds; } could anyone help me on this.
  2. Reply[ Go to top ]

    Is the "XAS" datasource defined and bound ? (check server startup logs if you already defined the datasource there should be some logs indicating it was bound ) Is the JNDI name - "XAS" correct ? If datasource is defined in resource reference of ejb, try accessing it as "java:comp/env/jdbc/XAS" provided the reference is named jdbc/XAS.
  3. XAS not bound[ Go to top ]

    Regarding on your first statement, I try to paste log here. How can I put the resource reference in EJB? Because currently I didn't put any resource reference in EJB. Using the jboss.xml or web.xml? Additional info, this is a web based application. Before this its running on Oracle Application Server and now I try to migrate to JBOSS AS. Here is from the log file: 08:51:59,813 INFO [QuartzResourceAdapter] start quartz!!! 08:51:59,917 INFO [SimpleThreadPool] Job execution threads will use class loader of thread: main 08:51:59,991 INFO [QuartzScheduler] Quartz Scheduler v.1.5.2 created. 08:51:59,995 INFO [RAMJobStore] RAMJobStore initialized. 08:51:59,995 INFO [StdSchedulerFactory] Quartz scheduler 'DefaultQuartzScheduler' initialized from default resource file in Quartz package: 'quartz.properties' 08:51:59,995 INFO [StdSchedulerFactory] Quartz scheduler version: 1.5.2 08:51:59,995 INFO [QuartzScheduler] Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED started. 08:52:00,271 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=JmsXA' to JNDI name 'java:JmsXA' 08:52:00,477 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=OracleDS' to JNDI name 'java:OracleDS' 08:52:08,879 INFO [A] Bound to JNDI name: queue/A 08:52:08,884 INFO [B] Bound to JNDI name: queue/B 08:52:08,889 INFO [C] Bound to JNDI name: queue/C 08:52:08,893 INFO [D] Bound to JNDI name: queue/D 08:52:08,897 INFO [ex] Bound to JNDI name: queue/ex 08:52:08,996 INFO [testTopic] Bound to JNDI name: topic/testTopic 08:52:09,001 INFO [securedTopic] Bound to JNDI name: topic/securedTopic 08:52:09,005 INFO [testDurableTopic] Bound to JNDI name: topic/testDurableTopic 08:52:09,010 INFO [testQueue] Bound to JNDI name: queue/testQueue 08:52:09,057 INFO [UILServerILService] JBossMQ UIL service available at : /127.0.0.1:8093 08:52:09,687 INFO [DLQ] Bound to JNDI name: queue/DLQ 08:52:10,444 INFO [TomcatDeployer] deploy, ctxPath=/jmx-console, warUrl=.../deploy/jmx-console.war/ 08:52:10,883 INFO [EARDeployer] Init J2EE application: file:/apps/jboss-4.2.2.GA/server/default/deploy/xas.ear
  4. Here is content in oracle-ds.xml: OracleDS jdbc:oracle:thin:@localhost:1521:SID <!-- See on WIKI page below how to use Oracle's thin JDBC driver to connect with enterprise RAC. --> <!-- Here are a couple of the possible OCI configurations. For more information, see http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/java.920/a96654/toc.htm <connection-url>jdbc:oracle:oci:@youroracle-tns-name</connection-url> or <connection-url>jdbc:oracle:oci:@(description=(address=(host=youroraclehost)(protocol=tcp)(port=1521))(connect_data=(SERVICE_NAME=yourservicename)))</connection-url> Clearly, its better to have TNS set up properly. --> oracle.jdbc.driver.OracleDriver passwd passwd
  5. From the stack trace looks like 1. The application is using an Stateless Session Bean named LoginBean. 2. The application hence must be having both EJB and Web Component (as you have mentioned that it has a Web component as well) 3. You are looking up a datasource in the EJBCreate method of the LoginBean. 4. The only data source created on the server is OracleDS. Asssuming that OracleDS points to the desired database, you can add the following to the session bean declaration in your ejb-jar.xml ... jdbc/XAS javax.sql.DataSource Container ... (In that case you have to lookup java:comp/env/jdbc/XAS as Rajiv had pointed out) Next you have to point jdbc/XAS to OracleDS on Server, through the following entry in jboss.xml jdbc/XAS java:/OracleDS
  6. Thanks you very muchh.. You all helped me to solve this problem. Now I can bring up and connect to the db. Thanks to all..