Re: Bind main/access classes to JNDI

k jee <[email protected]>
Newsgroups gmane.comp.jakarta.ojb.user
Message-ID <[email protected]>
Armin, Thank you for your response.
   
  If I specify JNDI name like jdbc/testdsn in the repository_database.xml, everything works fine. 
  But the problem is, it makes a direct JNDI connection and Websphere is not letting me use the Resource-Ref settings set in the web.xml file.
   
  So I tried to use the indirect JNDI by creating a startup class that will bind the datasource alias to the JNDI. For this I followed the weblogic example from the OJB site.
   
  I had a create my class that implements serializable in order to bind it to the JNDI. is there any OJB class that I can use to bind the JNDI name in my startup class.
   
  Please help.
   
  Thanks.

Armin Waibel <[email protected]> wrote:
  Hi,

k jee wrote:
> Hi All,
> 
> I am trying to use indirect JNDI for my web app in websphere application server.
> 
> I followed the following doc and created OjbPbstartup class as explained.
> 
> http://db.apache.org/ojb/docu/guides/deployment.html#bind-to-jndi
> 
> When I try to access the getObjectByQuery function, I get the following error. Can any one help? Please....

I assume that that the CCE occur while jndi lookup of the DataSource in 
method ConnectionFactoryAbstractImpl#newConnectionFromDataSource


InitialContext ic = new InitialContext();
ds = (DataSource) ic.lookup(jcd.getDatasourceName());


In the mapping of the jdbc-connection-descriptor you have to specify the 
jndi-name of the DataSource (to access the DB) defined on your 
appServer. It seems you set the name of your OJB access-class (bound to 
JNDI by yourself) instead.

regards,
Armin

> 
> [Servlet Error]-[com/mydir/pkg/OjbPbStartup incompatible with javax/sql/DataSource]: java.lang.ClassCastException: com/mydir/pkg/OjbPbStartup incompatible with javax/sql/DataSource
> at java.lang.Throwable.(Throwable.java)
> at java.lang.Throwable.(Throwable.java)
> at java.lang.ClassCastException.(ClassCastException.java:53)
> at org.apache.ojb.broker.accesslayer.ConnectionFactoryAbstractImpl.newConnectionFromDataSource(Unknown Source)
> at org.apache.ojb.broker.accesslayer.ConnectionFactoryAbstractImpl.lookupConnection(Unknown Source)
> at org.apache.ojb.broker.accesslayer.ConnectionFactoryManagedImpl.lookupConnection(Unknown Source)
> at org.apache.ojb.broker.accesslayer.ConnectionManagerImpl.getConnection(Unknown Source)
> at org.apache.ojb.broker.accesslayer.StatementManager.getPreparedStatement(Unknown Source)
> at org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeQuery(Unknown Source)
> at org.apache.ojb.broker.accesslayer.RsQueryObject.performQuery(Unknown Source)
> at org.apache.ojb.broker.accesslayer.RsIterator.(Unknown Source)
> at org.apache.ojb.broker.core.RsIteratorFactoryImpl.createRsIterator(Unknown Source)
> at org.apache.ojb.broker.core.PersistenceBrokerImpl.getRsIteratorFromQuery(Unknown Source)
> at org.apache.ojb.broker.core.PersistenceBrokerImpl.getIteratorFromQuery(Unknown Source)
> at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQuery(Unknown Source)
> at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Unknown Source)
> at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Unknown Source)
> at com.mydir.pkg.dao.tmpDAO.findByPK(tmpDAO.java)
> at com.mydir.pkg.actions.UserLoginAction.execute(UserLoginAction.java:136)
> at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
> at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
> at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
> at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
> at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
> at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
> at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
> at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
> at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
> at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
> at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:61)
> at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:974)
> at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:564)
> at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
> at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119)
> at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
> at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
> at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
> at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
> at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
> at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
> at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:439)
> at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java)
> 
> 
> ---------------------------------
> The fish are biting.
> Get more visitors on your site using Yahoo! Search Marketing.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



 
---------------------------------
Don't get soaked.  Take a quick peak at the forecast 
 with theYahoo! Search weather shortcut.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.