• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Error getting local home for entity bean in Websphere 5.1

 
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to use an entity bean with a session bean. The session bean is called by a servlet.

I get the remote stub from the session bean fine, but when I try to find the local home of the entity bean, I get this error when I call initContext.lookup()...

"RemoteException occurred in server thread; nested exception is: java.rmi.RemoteException: ; nested exception is: java.lang.ClassCastException: com/ibm/ws/rsadapter/jdbc/WSJdbcDataSource incompatible with entityBeans/InvoiceEntityLocalHome"

I assume I am missing setting a reference somewhere. Here is the session bean method...

package sessionBeans;

import java.util.Date;

import javax.ejb.CreateException;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import entityBeans.InvoiceEntityLocal;
import entityBeans.InvoiceEntityLocalHome;

/**
* Bean implementation class for Enterprise Bean: InvoiceSession
*/
public class InvoiceSessionBean implements javax.ejb.SessionBean {
private javax.ejb.SessionContext mySessionCtx;

protected InvoiceEntityLocalHome invEntityLocalHome;
protected InvoiceEntityLocal invEntityLocal;
protected String jndiInvAdd = "InvoiceEntityLocalHome";
private InitialContext initContext = null;

public boolean callInvoiceEntity(String invNum){
boolean rc = true;
Date key = new Date();

try {
invEntityLocalHome= (InvoiceEntityLocalHome)initContext.lookup(jndiInvAdd);
invEntityLocal = invEntityLocalHome.create(key);
invEntityLocal.setInvNum(invNum);
} catch (NamingException e) {
rc = false;
} catch (CreateException e) {
rc = false;
}

return rc;
}
 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like that Naming entry is configured with a data source other than your Local Home .


Lin
 
M Burke
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using the jndi name of the local interface.

How do I create a data source? Is that something that is made when I bind the entity bean to a table?

I also read that a session bean can't get a local home of a entity bean. I don't know if that is true.
 
author & internet detective
Posts: 40198
816
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You create a data source on the server. If using WebSphere Application Server, this is done through the admin console. If using WSAD, this is done through the server perspective.

A session bean can get the local home of an entity bean if it is in the same ejb-jar or EJB project.
 
M Burke
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Jeanne, the two beans are in the same project.
[ December 22, 2004: Message edited by: M Burke ]
 
    Bookmark Topic Watch Topic
  • New Topic