• Post Reply Bookmark Topic Watch Topic
  • New Topic

unable to access database,what shall i do??  RSS feed

 
megan yin
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help first!!!
I write a session bean to access mydatabase and show the data in client.My ide is jbuilder7 and weblogic7,os is win2000 server,database is sql server 2000.
I use weblogic to config my Database Connection Pool and Tx Data Source.I set the JNDI name as sqlSession1.My URL and Driver classname is ----URL=jdbc:weblogic:mssqlserver4:mydatabase@localhost:1433
Driver Classname=weblogic.jdbc.mssqlserver4.Driver
My method getConnection as following:
protected Connection getConnection() throws SQLException, NamingException { //get a reference to the naming service
InitialContext context=new InitialContext();
DataSource ds=(DataSource) context.lookup("java:comp/env/jdbc/sqlSession1");
return ds.getConnection();
}
When i use jbuilder7 create the EJBtest client,and run,the error message is following:
********************************************
E:\bea\jdk131_03\bin\javaw -classpath "E:\yl\jb7ex\Session1\classes;E:\bea\weblogic700\server\lib\weblogic.jar;E:\bea\jdk131_03\jre\lib\i18n.jar;E:\bea\jdk131_03\jre\lib\jaws.jar;E:\bea\jdk131_03\jre\lib\rt.jar;E:\bea\jdk131_03\jre\lib\sunrsasign.jar;E:\bea\jdk131_03\lib\dt.jar;E:\bea\jdk131_03\lib\htmlconverter.jar;E:\bea\jdk131_03\lib\tools.jar" session1.PaperLevelTestClient2
java.rmi.RemoteException: Error in ejbCreate:; nested exception is:
javax.ejb.CreateException: unable to access database:javax.naming.NameNotFoundException: Unable to resolve 'app/ejb/Tpaper.jar#PaperLevel/comp/env/jdbc/sqlSession1' Resolved: 'app/ejb/Tpaper.jar#PaperLevel/comp/env' Unresolved:'jdbc' ; remaining name 'jdbc/sqlSession1'
Start server side stack trace:
java.rmi.RemoteException: Error in ejbCreate:; nested exception is:
javax.ejb.CreateException: unable to access database:javax.naming.NameNotFoundException: Unable to resolve 'app/ejb/Tpaper.jar#PaperLevel/comp/env/jdbc/sqlSession1' Resolved: 'app/ejb/Tpaper.jar#PaperLevel/comp/env' Unresolved:'jdbc' ; remaining name 'jdbc/sqlSession1'
javax.ejb.CreateException: unable to access database:javax.naming.NameNotFoundException: Unable to resolve 'app/ejb/Tpaper.jar#PaperLevel/comp/env/jdbc/sqlSession1' Resolved: 'app/ejb/Tpaper.jar#PaperLevel/comp/env' Unresolved:'jdbc' ; remaining name 'jdbc/sqlSession1'
at session1.PaperLevelBean.ejbCreate(PaperLevelBean.java:29)
at session1.PaperLevelBean_rfko7c_Impl.ejbCreate(PaperLevelBean_rfko7c_Impl.java:112)
at java.lang.reflect.Method.invoke(Native Method)
at weblogic.ejb20.pool.StatelessSessionPool.createBean(StatelessSessionPool.java:148)
at weblogic.ejb20.pool.StatelessSessionPool.getBean(StatelessSessionPool.java:98)
at weblogic.ejb20.manager.StatelessManager.preInvoke(StatelessManager.java:154)
at weblogic.ejb20.internal.BaseEJBObject.preInvoke(BaseEJBObject.java:126)
at weblogic.ejb20.internal.StatelessEJBObject.preInvoke(StatelessEJBObject.java:61)
at session1.PaperLevelBean_rfko7c_EOImpl.getLevelId(PaperLevelBean_rfko7c_EOImpl.java:83)
at session1.PaperLevelBean_rfko7c_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:359)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:114)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:313)
at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:762)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:308)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:152)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:133)
End server side stack trace
; nested exception is:
javax.ejb.CreateException: unable to access database:javax.naming.NameNotFoundException: Unable to resolve 'app/ejb/Tpaper.jar#PaperLevel/comp/env/jdbc/sqlSession1' Resolved: 'app/ejb/Tpaper.jar#PaperLevel/comp/env' Unresolved:'jdbc' ; remaining name 'jdbc/sqlSession1'
Start server side stack trace:
javax.ejb.CreateException: unable to access database:javax.naming.NameNotFoundException: Unable to resolve 'app/ejb/Tpaper.jar#PaperLevel/comp/env/jdbc/sqlSession1' Resolved: 'app/ejb/Tpaper.jar#PaperLevel/comp/env' Unresolved:'jdbc' ; remaining name 'jdbc/sqlSession1'
at session1.PaperLevelBean.ejbCreate(PaperLevelBean.java:29)
at session1.PaperLevelBean_rfko7c_Impl.ejbCreate(PaperLevelBean_rfko7c_Impl.java:112)
at java.lang.reflect.Method.invoke(Native Method)
at weblogic.ejb20.pool.StatelessSessionPool.createBean(StatelessSessionPool.java:148)
at weblogic.ejb20.pool.StatelessSessionPool.getBean(StatelessSessionPool.java:98)
at weblogic.ejb20.manager.StatelessManager.preInvoke(StatelessManager.java:154)
at weblogic.ejb20.internal.BaseEJBObject.preInvoke(BaseEJBObject.java:126)
at weblogic.ejb20.internal.StatelessEJBObject.preInvoke(StatelessEJBObject.java:61)
at session1.PaperLevelBean_rfko7c_EOImpl.getLevelId(PaperLevelBean_rfko7c_EOImpl.java:83)
at session1.PaperLevelBean_rfko7c_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:359)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:114)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:313)
at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:762)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:308)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:152)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:133)
End server side stack trace

javax.ejb.CreateException: unable to access database:javax.naming.NameNotFoundException: Unable to resolve 'app/ejb/Tpaper.jar#PaperLevel/comp/env/jdbc/sqlSession1' Resolved: 'app/ejb/Tpaper.jar#PaperLevel/comp/env' Unresolved:'jdbc' ; remaining name 'jdbc/sqlSession1'
Start server side stack trace:
javax.ejb.CreateException: unable to access database:javax.naming.NameNotFoundException: Unable to resolve 'app/ejb/Tpaper.jar#PaperLevel/comp/env/jdbc/sqlSession1' Resolved: 'app/ejb/Tpaper.jar#PaperLevel/comp/env' Unresolved:'jdbc' ; remaining name 'jdbc/sqlSession1'
at session1.PaperLevelBean.ejbCreate(PaperLevelBean.java:29)
at session1.PaperLevelBean_rfko7c_Impl.ejbCreate(PaperLevelBean_rfko7c_Impl.java:112)
at java.lang.reflect.Method.invoke(Native Method)
at weblogic.ejb20.pool.StatelessSessionPool.createBean(StatelessSessionPool.java:148)
at weblogic.ejb20.pool.StatelessSessionPool.getBean(StatelessSessionPool.java:98)
at weblogic.ejb20.manager.StatelessManager.preInvoke(StatelessManager.java:154)
at weblogic.ejb20.internal.BaseEJBObject.preInvoke(BaseEJBObject.java:126)
at weblogic.ejb20.internal.StatelessEJBObject.preInvoke(StatelessEJBObject.java:61)
at session1.PaperLevelBean_rfko7c_EOImpl.getLevelId(PaperLevelBean_rfko7c_EOImpl.java:83)
at session1.PaperLevelBean_rfko7c_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:359)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:114)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:313)
at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:762)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:308)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:152)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:133)
End server side stack trace

<<no stack trace available>>
*************************************
I think my database config is right and ejb server is works well.So i cannott think out any ways to correct this problem.
What's wrong and how can i correct it?
 
shiva shankar
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats' a problem of the JNDI look up (NameNotFoundException) ..check if the datasource is bound properly to that name.
shiva
 
megan yin
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My JNDI name is sqlSession1.
Now i can see my database table correctly in Datasources list in jbuilder.Then i test the connectiong pool and Tx data sources in weblogic.It seems that all of above works well.
Can you say more detail about check method and crack way of my ques?
Thank you very much!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!