• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem with first entity bean.  RSS feed

 
dee nara
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
I am new to J2ee and EJB. I tried to develop my first Entity Bean. The jar got deployed successfully. But when i try to run the java client, I get the following exception.
C:\dvdejb>java DvdClient
Got reference
Caught an exception.
java.rmi.ServerException: RemoteException occurred in server thread; nested exce
ption is:
java.rmi.ServerException: EJBException:; nested exception is:
javax.ejb.EJBException: setEntityContext(): after calling dbMakeConnecti
on() jdbc not bound
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:292)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
60)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
.java:701)
at java.lang.Thread.run(Thread.java:536)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Stream
RemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:
223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Sour
ce)
at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvo
kerProxy.java:138)
at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.jav
a:108)
at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.
java:77)
at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:8
0)
at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:198)
at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)
at $Proxy0.findByIsbn(Unknown Source)
at DvdClient.main(DvdClient.java:33)
Caused by: java.rmi.ServerException: EJBException:; nested exception is:
javax.ejb.EJBException: setEntityContext(): after calling dbMakeConnecti
on() jdbc not bound
at org.jboss.ejb.plugins.LogInterceptor.handleException(LogInterceptor.j
ava:357)
at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:1
33)
at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:487)
at org.jboss.ejb.Container.invoke(Container.java:730)
at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1058)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:
382)
at sun.reflect.GeneratedMethodAccessor51.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
60)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
.java:701)
at java.lang.Thread.run(Thread.java:536)
Caused by: javax.ejb.EJBException: setEntityContext(): after calling dbMakeConne
ction() jdbc not bound
at DvdBean.setEntityContext(DvdBean.java:129)
at org.jboss.ejb.EntityEnterpriseContext.<init>(EntityEnterpriseContext.
java:76)
at org.jboss.ejb.plugins.EntityInstancePool.create(EntityInstancePool.ja
va:86)
at org.jboss.ejb.plugins.AbstractInstancePool.get(AbstractInstancePool.j
ava:209)
at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInst
anceInterceptor.java:78)
at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInte
rceptor.java:79)
at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCrea
tionInterceptor.java:44)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInte
rceptor.java:111)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxIntercep
torCMT.java:178)
at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.ja
va:52)
at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityIntercep
tor.java:105)
at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:1
29)
... 15 more

Source code:
Home
import java.util.Collection;
import java.rmi.RemoteException;
import javax.ejb.*;
public interface DvdHome extends EJBHome {
public Dvd create(String isbn, String title, String format)
throws RemoteException, CreateException;

public Dvd findByPrimaryKey(String isbn)
throws FinderException, RemoteException;
public Collection findByIsbn(String isbn)
throws FinderException, RemoteException;

public Collection findByTitle(String title)
throws FinderException, RemoteException;

public Collection findByTitleWith(String title)
throws FinderException, RemoteException;
}
Remote
import javax.ejb.EJBObject;
import java.rmi.RemoteException;
public interface Dvd extends EJBObject {

public void setTitle(String newTitle)
throws RemoteException;

public void setFormat(String newFormat)
throws RemoteException;

public String getTitle()
throws RemoteException;
public String getFormat()
throws RemoteException;

public String getAsString()
throws RemoteException;
}
Bean class
import java.sql.*;
import java.util.*;
import javax.ejb.*;
import javax.naming.*;
import javax.sql.*;
public class DvdBean implements EntityBean {
private EntityContext entityContext;
private Connection connection;
private String dbName = "java:comp/env/jdbc/DvdDB";
/*bean state fields*/
private String isbn; //the primary key
private String title;
private String format;

/*methods in remote interface, access state fields*/

public void setTitle(String newTitle)
{
this.title = newTitle;
}

public void setFormat(String newFormat)
{
this.format = newFormat;
}

public String getTitle()
{
return title;
}

public String getFormat()
{
return format;
}

public String getAsString()
{
return("dvd = isbn: " + isbn + " title: " + title + " format: " + format);
}


/*methods in home interface, use table(s) */

public String ejbCreate(String isbn, String title, String format) throws CreateException
{
try
{
dbInsertRow(isbn, title, format);
} catch (Exception exception) {throw new EJBException("ejbCreate() bInsertRowCalled with isbn: " + isbn + " title: " + title + " format: " + format + " exception: " + exception.getMessage());}
this.isbn = isbn;
this.title = title;
this.format = format;
return isbn;
}
public String ejbFindByPrimaryKey(String primaryKey) throws FinderException
{
boolean result;

try
{
result = dbSelectByPrimaryKey(primaryKey);
} catch (Exception exception) {throw new EJBException("ejbFindByPrimaryKey(): after calling dbSelectByPrimaryKey " + exception.getMessage());}

if (result)
{
return primaryKey;
}
else
{
throw new ObjectNotFoundException ("ejbFindByPrimaryKey(): Row for id " + primaryKey + " not found.");
}
}
//differs from ejbFindByPrimaryKey in that it returns a collection, and so can return a null set
public Collection ejbFindByIsbn(String primaryKey) throws FinderException
{
Collection result;

try
{
result = dbSelectByIsbn(primaryKey);
} catch (Exception exception) {throw new EJBException("ejbCheckForPrimaryKey(): after calling dbSelectByIsbn " + exception.getMessage());}

return result;
}

public Collection ejbFindByTitle(String title) throws FinderException
{
Collection result;
try
{
result = dbSelectByTitle(title);
} catch (Exception exception) {throw new EJBException("ejbFindByTitle: after calling dbSelectByTitle() " + exception.getMessage());}
return result;
}

public Collection ejbFindByTitleWith(String title) throws FinderException
{
Collection result;
try
{
result = dbSelectByTitleWith(title);
} catch (Exception exception) {throw new EJBException("ejbFindByTitleWith: after calling dbSelectTitleWith() " + exception.getMessage());}
return result;
}

/*methods necessary in an entity bean */

public void ejbRemove()
{
try
{
dbDeleteRow(isbn);
} catch (Exception exception) {throw new EJBException("ejbRemove(): after calling dbDeleteRow() " + exception.getMessage());}
}
public void setEntityContext(EntityContext entityContext)
{
this.entityContext = entityContext;
try {
dbMakeConnection();
} catch (Exception exception) {throw new EJBException("setEntityContext(): after calling dbMakeConnection() " + exception.getMessage());}
}
public void unsetEntityContext()
{
try {
connection.close();
} catch (SQLException exception) {throw new EJBException("unsetEntityContext(): closing connection" + exception.getMessage());}
}
public void ejbActivate()
{
isbn = (String)entityContext.getPrimaryKey();
}
public void ejbPassivate() {
isbn = null;
}
public void ejbLoad()
{
try {
dbLoadRow();
} catch (Exception exception) {throw new EJBException("ejbLoad() bLoadRow called using this.isbn: " + this.isbn + " exception " + exception.getMessage());}
}

public void ejbStore()
{
try {
dbStoreRow();
} catch (Exception exception) {throw new EJBException("ejbStore(): " + exception.getMessage());
}
}
public void ejbPostCreate(String isbn, String title, String format) { }

/*db methods*/
private void dbMakeConnection() throws NamingException, SQLException
{
InitialContext initialContext = new InitialContext();
DataSource dataSource = (DataSource)initialContext.lookup(dbName);
connection = dataSource.getConnection();
}
private void dbInsertRow (String isbn, String title, String format) throws SQLException
{
String insertStatement = "insert into dvd values ( ? , ? , ? )";
PreparedStatement preparedStatement = connection.prepareStatement(insertStatement);
preparedStatement.setString(1, isbn);
preparedStatement.setString(2, title);
preparedStatement.setString(3, format);
preparedStatement.executeUpdate();
preparedStatement.close();
}
private void dbDeleteRow(String isbn) throws SQLException
{
String deleteStatement = "delete from dvd where isbn = ? ";
PreparedStatement preparedStatement = connection.prepareStatement(deleteStatement);
preparedStatement.setString(1, isbn);
preparedStatement.executeUpdate();
preparedStatement.close();
}
private boolean dbSelectByPrimaryKey(String primaryKey) throws SQLException
{
String selectStatement = "select isbn from dvd where isbn = ? ";
PreparedStatement preparedStatement = connection.prepareStatement(selectStatement);
preparedStatement.setString(1, primaryKey);
ResultSet resultSet = preparedStatement.executeQuery();
boolean result = resultSet.next();

preparedStatement.close();
return result;
}

private Collection dbSelectByIsbn(String isbnIn) throws SQLException
{
String selectStatement = "select isbn from dvd where isbn = ? ";
PreparedStatement preparedStatement = connection.prepareStatement(selectStatement);
preparedStatement.setString(1, isbnIn);

ResultSet resultSet = preparedStatement.executeQuery();

ArrayList arrayList = new ArrayList();
while (resultSet.next()) {
String isbn = resultSet.getString(1);
arrayList.add(isbn);
}

preparedStatement.close();
return arrayList;
}
private Collection dbSelectByTitle(String title) throws SQLException
{
String selectStatement = "select isbn from dvd where title = ? ";
PreparedStatement preparedStatement = connection.prepareStatement(selectStatement);
preparedStatement.setString(1, title);

ResultSet resultSet = preparedStatement.executeQuery();
ArrayList arrayList = new ArrayList();
while (resultSet.next()) {
String isbn = resultSet.getString(1);
arrayList.add(isbn);
}
preparedStatement.close();
return arrayList;
}
private Collection dbSelectByTitleWith(String title) throws SQLException
{
String selectStatement = "select isbn from dvd where title like ? ";
PreparedStatement preparedStatement = connection.prepareStatement(selectStatement);
preparedStatement.setString(1, "%" + title + "%");
ResultSet resultSet = preparedStatement.executeQuery();

ArrayList arrayList = new ArrayList();
while (resultSet.next()) {
String isbn = resultSet.getString("isbn");
arrayList.add(isbn);
}
preparedStatement.close();
return arrayList;
}

private void dbLoadRow() throws SQLException
{
String selectStatement = "select title, format from dvd where isbn = ? ";
PreparedStatement preparedStatement = connection.prepareStatement(selectStatement);
preparedStatement.setString(1, this.isbn);
ResultSet resultSet = preparedStatement.executeQuery();
if (resultSet.next()) {
this.title = resultSet.getString(1);
this.format = resultSet.getString(2);
preparedStatement.close();
}
else {
preparedStatement.close();
throw new NoSuchEntityException("dbLoadRow(): Row for isbn " + isbn + " not found in database.");
}
}
private void dbStoreRow() throws SQLException
{
String updateStatement = "update dvd set title = ? , format = ? where isbn = ?";
PreparedStatement preparedStatement = connection.prepareStatement(updateStatement);
preparedStatement.setString(1, title);
preparedStatement.setString(2, format);
preparedStatement.setString(3, isbn);
int rowCount = preparedStatement.executeUpdate();
preparedStatement.close();
if (rowCount == 0) {
throw new EJBException("dbStoreRow(): Storing row for isbn " + isbn + " failed.");
}
}
}
DVDClient code.
import java.util.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
public class DvdClient {
public static void main(String[] args)
{
try {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL,"localhost:1099");
env.put("java.naming.factory.url.pkgs","org.jboss.naming.org.jnp.interfaces");
Context initialContext = new InitialContext(env);
Object initialContextObject = initialContext.lookup"DvdEjb/DvdEJB");
System.out.println("Got reference");
DvdHome dvdHome = (DvdHome)PortableRemoteObject.narrow(initialContextObject, DvdHome.class);
Dvd bis;
Collection dvdCheck;
Iterator dvdCheckIterator;

//Check to see if this pk already exists.
//Maybe not an efficent way to do things, but an interesting example.
dvdCheck = dvdHome.findByIsbn("078063344X");
if (dvdCheck.isEmpty())
{
bis = dvdHome.create("078063344X", "Best of Show", "WS ");

}
else
{
dvdCheckIterator = dvdCheck.iterator();
bis = (Dvd)dvdCheckIterator.next();
}

System.out.println("after create: " + bis.getAsString());
bis.setTitle("Best in Show");
System.out.println("after change title: " + bis.getAsString());
Collection collection = dvdHome.findByTitle("Best in Show");
Iterator iterator=collection.iterator();
while (iterator.hasNext()) {
Dvd dvd = (Dvd)iterator.next();
System.out.println("in bis loop: " + dvd.getAsString());
}

Dvd rlr = null;
dvdCheck = dvdHome.findByIsbn("076783738X");
if (dvdCheck.isEmpty())
{
rlr = dvdHome.create("076783738X", "Run Lola Run", "WS-FS");
}

Dvd pf = null;
dvdCheck = dvdHome.findByIsbn("0780634551");
if (dvdCheck.isEmpty())
{
pf = dvdHome.create("0780634551", "Pink Flamingos", "WS ");
}

Dvd sil = null;
dvdCheck = dvdHome.findByIsbn("0788818937");
if (dvdCheck.isEmpty())
{
sil = dvdHome.create("0788818937", "Shakespeare in Love", "WS ");
}

Dvd tpb = null;
dvdCheck = dvdHome.findByIsbn("0792850769");
if (dvdCheck.isEmpty())
{
tpb = dvdHome.create("0792850769", "The Princess Bride", "WS ");
}

collection = dvdHome.findByTitleWith("in");
iterator=collection.iterator();
while (iterator.hasNext()) {
Dvd dvd = (Dvd)iterator.next();
System.out.println("in like loop: " + dvd.getAsString());
}
if (bis != null) {bis.remove();}//note: will remove from table
if (rlr != null) {rlr.remove();}//note: will remove from table only if we created rlr in this run
if (pf != null) {pf.remove();}//note: will remove from table only if we created pf in this run
if (sil != null) {sil.remove();}//note: will remove from table only if we created sil in this run
if (tpb != null) {tpb.remove();}//note: will remove from table only if we created tpb in this run
} catch (Exception exception) {
System.err.println("Caught an exception." );
exception.printStackTrace();
}
}
}
jboss.xml
<jboss>
<enterprise-beans>
<session>
<ejb-name>Demo</ejb-name>
<jndi-name>ejb/Demo</jndi-name>
</session>
</enterprise-beans>
</jboss>

ejb-jar.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>
<ejb-jar>
<display-name>DvdJAR</display-name>
<enterprise-beans>
<entity>
<display-name>DvdEJB</display-name>
<ejb-name>DvdEJB</ejb-name>
<home>DvdHome</home>
<remote>Dvd</remote>
<ejb-class>DvdBean</ejb-class>
<persistence-type>Bean</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>
<security-identity>
<description></description>
<use-caller-identity></use-caller-identity>
</security-identity>
<resource-ref>
<res-ref-name>DvdEjb/jdbc/DvdDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
</entity>
</enterprise-beans>
<assembly-descriptor>
<method-permission>
<unchecked />
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Remote</method-intf>
<method-name>getHandle</method-name>
<method-params />
</method>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Home</method-intf>
<method-name>remove</method-name>
<method-params>
<method-param>javax.ejb.Handle</method-param>
</method-params>
</method>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Home</method-intf>
<method-name>getHomeHandle</method-name>
<method-params />
</method>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Home</method-intf>
<method-name>findByTitleWith</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</method>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Home</method-intf>
<method-name>findByPrimaryKey</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</method>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Remote</method-intf>
<method-name>getAsString</method-name>
<method-params />
</method>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Remote</method-intf>
<method-name>isIdentical</method-name>
<method-params>
<method-param>javax.ejb.EJBObject</method-param>
</method-params>
</method>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Home</method-intf>
<method-name>getEJBMetaData</method-name>
<method-params />
</method>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Home</method-intf>
<method-name>findByTitle</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</method>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Remote</method-intf>
<method-name>setTitle</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</method>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Remote</method-intf>
<method-name>setFormat</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</method>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Home</method-intf>
<method-name>findByIsbn</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</method>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Remote</method-intf>
<method-name>getPrimaryKey</method-name>
<method-params />
</method>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Remote</method-intf>
<method-name>getFormat</method-name>
<method-params />
</method>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Home</method-intf>
<method-name>create</method-name>
<method-params>
<method-param>java.lang.String</method-param>
<method-param>java.lang.String</method-param>
<method-param>java.lang.String</method-param>
</method-params>
</method>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Remote</method-intf>
<method-name>getEJBHome</method-name>
<method-params />
</method>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Remote</method-intf>
<method-name>remove</method-name>
<method-params />
</method>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Remote</method-intf>
<method-name>getTitle</method-name>
<method-params />
</method>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Home</method-intf>
<method-name>remove</method-name>
<method-params>
<method-param>java.lang.Object</method-param>
</method-params>
</method>
</method-permission>
<container-transaction>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Home</method-intf>
<method-name>remove</method-name>
<method-params>
<method-param>java.lang.Object</method-param>
</method-params>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Remote</method-intf>
<method-name>setFormat</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Remote</method-intf>
<method-name>setTitle</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Home</method-intf>
<method-name>create</method-name>
<method-params>
<method-param>java.lang.String</method-param>
<method-param>java.lang.String</method-param>
<method-param>java.lang.String</method-param>
</method-params>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Home</method-intf>
<method-name>findByPrimaryKey</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Home</method-intf>
<method-name>remove</method-name>
<method-params>
<method-param>javax.ejb.Handle</method-param>
</method-params>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Remote</method-intf>
<method-name>getAsString</method-name>
<method-params />
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Home</method-intf>
<method-name>findByIsbn</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Home</method-intf>
<method-name>findByTitle</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Remote</method-intf>
<method-name>getTitle</method-name>
<method-params />
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Remote</method-intf>
<method-name>getFormat</method-name>
<method-params />
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Remote</method-intf>
<method-name>remove</method-name>
<method-params />
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>DvdEJB</ejb-name>
<method-intf>Home</method-intf>
<method-name>findByTitleWith</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you configured a datasource in JBoss for "java:comp/env/jdbc/DvdDB"?
(we also have a dedicated forum for JBoss where you can figure out how to do that if you haven't already)
Oh, and welcome to the JavaRanch!
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dee,
My guess is that you're probably doing something that you're not allowed to do in the "setEntityContext()" method. The EJB specification details what operations can and can't be done in the "setEntityContext()" method. Have you studied the relevant section?
Good Luck,
Avi.
 
dee nara
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
Thanks for the suggestions. I had not configured the datasource properly. Now,I have created an empty database in access and accordingly given the System DSN too. A different error is coming up. can anybody help me out one more time?
java.rmi.ServerException: RemoteException occurred in server thread; nested exce
ption is:
java.rmi.ServerException: EJBException:; nested exception is:
javax.ejb.EJBException: ejbCheckForPrimaryKey(): after calling dbSelectB
yIsbn null
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:292)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
Thanks,
dee.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!