2 Replies Latest reply on Jan 11, 2002 6:48 AM by Sachin

    unable to connect to db from entity bean

    Sachin Newbie

      Hi All,
      I am having a problem accessing db from entity bean. i am using jboss 2.4.x. i am using bmp.

      The res reference in ejb-jar.xml looks as:

      <resource-ref>
      <res-ref-name>java:/MacaDB</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      <res-sharing-scope>Shareable</res-sharing-scope>
      </resource-ref>
      the jboss.jcml looks as:

      org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl
      MacaDB
      jdbc:postgresql://IP:port/db
      user
      passs
      false


      The standardjaws.xml looks as:
      java:/MacaDB
      <type-mapping>MacaDB</type-mapping>
      false


      The error i get while accessing db is:
      [UsersEB] TRANSACTION ROLLBACK EXCEPTION:Unable to connect to database. jdbc not bound; nested exception is:
      javax.ejb.EJBException: Unable to connect to database. jdbc not bound
      [UsersEB] javax.ejb.EJBException: Unable to connect to database. jdbc not bound
      [UsersEB] at macamanageuser.UsersEB.setEntityContext(UsersEB.java:520)
      [UsersEB] at org.jboss.ejb.EntityEnterpriseContext.(EntityEnterpriseContext.java:78)
      [UsersEB] at org.jboss.ejb.plugins.EntityInstancePool.create(EntityInstancePool.java:81)
      [UsersEB] at org.jboss.ejb.plugins.AbstractInstancePool.get(AbstractInstancePool.java:143)
      [UsersEB] at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:143)
      [UsersEB] at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:108)
      [UsersEB] at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:135)
      [UsersEB] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:307)
      [UsersEB] at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:86)
      [UsersEB] at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:103)
      [UsersEB] at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:106)
      [UsersEB] at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:420)
      [UsersEB] at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invokeHome(JRMPContainerInvoker.java:441)
      [UsersEB] at org.jboss.ejb.plugins.jrmp.interfaces.HomeProxy.invokeHome(HomeProxy.java:237)
      [UsersEB] at org.jboss.ejb.plugins.jrmp.interfaces.HomeProxy.invoke(HomeProxy.java:182)
      [UsersEB] at $Proxy71.findByUser_UserName(Unknown Source)
      [UsersEB] at macamanageuser.UsersSB.getUserId(UsersSB.java:435)
      [UsersEB] at java.lang.reflect.Method.invoke(Native Method)
      [UsersEB] at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:543)
      [UsersEB] at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:87)
      [UsersEB] at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:133)
      [UsersEB] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:307)
      [UsersEB] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:99)
      [UsersEB] at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:128)
      [UsersEB] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:195)
      [UsersEB] at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:286)
      [UsersEB] at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:489)
      [UsersEB] at org.jboss.ejb.plugins.jrmp.interfaces.GenericProxy.invokeContainer(GenericProxy.java:335)
      [UsersEB] at org.jboss.ejb.plugins.jrmp.interfaces.StatelessSessionProxy.invoke(StatelessSessionProxy.java:123)
      [UsersEB] at $Proxy49.getUserId(Unknown Source)
      [UsersEB] at _0002fLoginGUI_0002ejspLoginGUI_jsp_0._jspService(_0002fLoginGUI_0002ejspLoginGUI_jsp_0.java:313)
      [UsersEB] at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
      [UsersEB] at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      [UsersEB] at org.apache.jasper.servlet.JspServlet$JspCountedServlet.service(JspServlet.java:130)
      [UsersEB] at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      [UsersEB] at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:282)
      [UsersEB] at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)
      [UsersEB] at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
      [UsersEB] at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      [UsersEB] at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
      [UsersEB] at org.apache.tomcat.core.Handler.service(Handler.java:287)
      [UsersEB] at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
      [UsersEB] at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)
      [UsersEB] at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
      [UsersEB] at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
      [UsersEB] at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
      [UsersEB] at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
      [UsersEB] at java.lang.Thread.run(Unknown Source)


      where UsersEB is my entity bean.

      I believe there is something wrong on my part but am unable to spot it.
      Can anyone help me?

      Thanks in advance


        • 1. Re: unable to connect to db from entity bean
          Adrian Brock Master

          How are you trying to get your data source?

          Is it initialContext().lookup("jdbc/MacaDB") ?

          It should be lookup("java:/MacaDB")

          Regards,
          Adrian

          • 2. Re: unable to connect to db from entity bean
            Sachin Newbie

            Hi,
            Thanks for the help. i have now solved the problem and my application works fine. I actually had developed the application on J2EE server by SUN. Using that i was relieved from the work of forming the xml files. Also the convention of the jndi naming is different from that of jboss. so when i started porting the application from j2ee to jboss, i did not make the necessary changes in the jndi name.
            Like j2ee needs jndi names in java:comp/env/...

            Also i used jsp in my application and had to solve the classpath problem. i got all the needed help from the forums here.
            So thanks to all who contributed and i will also try to contribute something now based on my past experience.
            Also i have another requirement of accessing a lotus notes database from my application along with the relational db. Has anybody come across such a requirement or content on web or discussion thread?

            Thanks in advance,
            Sachin