We are commiting the BMP stuff today (stephan gruschke) and I will rewire
the BMP/CMP stuff ASAP.

Stay tuned, a new binary will ship with that.

patience.
marc

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Primoz Furlan
Sent: Tuesday, July 11, 2000 6:19 AM
To: [EMAIL PROTECTED]
Subject: [jBoss-User] BMP problems in CVS version


Hi all,

Jboss is realy cool. But one thing that I tried did not work. With BMP
entity beans the binary version works when the create method on the bean is
called and does not work with find methods - OK. But the new CVS version
downloaded today with the same classes and xml descriptors - the find
methods work ok, but the create method does not anymore -  it throws errors
shown bellow? And one more thing, if findByPimaryKey method is called on the
bean first and then the create method is called, my client application just
waits forever - cycles and there are now errors thrown by the container or
the client. I use oracle 8.1.6 and jdk1.3. Persistence is on the Oracle DB.
The code for my example is here:

Error thrown by the new CVS container with the create method:

        at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
        at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:156)
        at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:219)
        at
oracle.jdbc.driver.OracleStatement.prepare_for_new_get(OracleStatemen
t.java:2285)
        at
oracle.jdbc.driver.OracleStatement.getStringValue(OracleStatement.jav
a:2430)
        at
oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.
java:285)
        at
oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:130
8)
        at ejbShop.MerchantBean_BMP.getConnection(MerchantBean_BMP.java:140)
        at ejbShop.MerchantBean_BMP.ejbCreate(MerchantBean_BMP.java:77)
        at java.lang.reflect.Method.invoke(Native Method)
        at
org.jboss.ejb.EntityContainer.createHome(EntityContainer.java:379)
        at java.lang.reflect.Method.invoke(Native Method)
        at
org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityC
ontainer.java:512)
        at
org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(Ent
itySynchronizationInterceptor.java:147)
        at
org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInst
anceInterceptor.java:77)
        at
org.jboss.ejb.plugins.TxInterceptor$RunInvokeHome.run(TxInterceptor.j
ava:349)
        at
org.jboss.ejb.plugins.TxInterceptor.runWithTransactions(TxInterceptor
.java:223)
        at
org.jboss.ejb.plugins.TxInterceptor.invokeHome(TxInterceptor.java:84)

        at
org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityIntercep
tor.java:75)
        at
org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:1
01)
        at
org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:306)
        at
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invokeHome(JRM
PContainerInvoker.java:166)
        at
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invokeHome(JRM
PContainerInvoker.java:130)
        at java.lang.reflect.Method.invoke(Native Method)
        at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
        at sun.rmi.transport.Transport$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.rmi.transport.Transport.serviceCall(Unknown Source)
        at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown
Sour
ce)
        at java.lang.Thread.run(Unknown Source)
        at
org.jboss.ejb.EntityContainer.createHome(EntityContainer.java:400)
        at java.lang.reflect.Method.invoke(Native Method)
        at
org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityC
ontainer.java:512)
        at
org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(Ent
itySynchronizationInterceptor.java:147)
        at
org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInst
anceInterceptor.java:77)
        at
org.jboss.ejb.plugins.TxInterceptor$RunInvokeHome.run(TxInterceptor.j
ava:349)
        at
org.jboss.ejb.plugins.TxInterceptor.runWithTransactions(TxInterceptor
.java:223)
        at
org.jboss.ejb.plugins.TxInterceptor.invokeHome(TxInterceptor.java:84)

        at
org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityIntercep
tor.java:75)
        at
org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:1
01)
        at
org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:306)
        at
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invokeHome(JRM
PContainerInvoker.java:166)
        at
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invokeHome(JRM
PContainerInvoker.java:130)
        at java.lang.reflect.Method.invoke(Native Method)
        at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
        at sun.rmi.transport.Transport$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.rmi.transport.Transport.serviceCall(Unknown Source)
        at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown
Sour
ce)
        at java.lang.Thread.run(Unknown Source)
[Merchant_BMP] java.sql.SQLException: Exhausted Resultset
[Merchant_BMP] Create1.4
[Default] javax.ejb.CreateException: Create
failed:java.lang.reflect.InvocationT
argetException

Error thrown by the client:

javax.ejb.CreateException: Create
failed:java.lang.reflect.InvocationTargetException
        at
sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown
Source)
        at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
        at sun.rmi.server.UnicastRef.invoke(Unknown Source)
        at
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker_Stub.invokeHome(Unkno
wn Source)
        at
org.jboss.ejb.plugins.jrmp.interfaces.HomeProxy.invoke(HomeProxy.java:79)
        at $Proxy0.create(Unknown Source)
        at ejbShop.ejbShopClient.<init>(ejbShopClient.java:21)
        at ejbShop.ejbShopClient.main(ejbShopClient.java:49)

Remote interface:

package ejbShop;

import java.rmi.*;
import javax.ejb.*;

public interface Merchant extends EJBObject {

  public abstract void setName(String name) throws RemoteException;

  public abstract String getName() throws RemoteException;

  public abstract void setUsername(String username) throws RemoteException;

  public abstract String getUsername() throws RemoteException;

  public abstract void setPassword(String password) throws RemoteException;

  public abstract String getPassword() throws RemoteException;

  public abstract void setEmail(String email) throws RemoteException;

  public abstract String getEmail() throws RemoteException;

}

Home interface:

package ejbShop;

import java.rmi.*;
import javax.ejb.*;
import java.util.*;

public interface MerchantHome extends EJBHome {

  public Merchant create(Integer merchantId)
                      throws RemoteException, CreateException;

  public Merchant findByPrimaryKey(Integer merchantId)
                      throws RemoteException, FinderException;

}

Bean class:

package ejbShop;

import java.rmi.*;
import javax.ejb.*;

public class MerchantBean implements EntityBean {
  EntityContext entityContext;

  public int id;
  public int shop_id;
  public String name;
  public String username;
  public String password;
  public int access_level;
  public String email;


  public MerchantBean() {
  }

  public Integer ejbCreate(Integer idObj) throws RemoteException,
CreateException {
    this.id = idObj.intValue();
    return null;
  }

  public void ejbPostCreate(Integer idObj) throws RemoteException,
CreateException {}

  public void ejbActivate() throws RemoteException {
  }

  public void ejbLoad() throws RemoteException {
  }

  public void ejbPassivate() throws RemoteException {
  }

  public void ejbRemove() throws RemoteException, RemoveException {
  }

  public void ejbStore() throws RemoteException {
  }

  public void setName(String name) {
    this.name = name;
  }

  public String getName() {
    return name;
  }

  public void setUsername(String username) {
    this.username = username;
  }

  public String getUsername() {
    return username;
  }

  public void setPassword(String password) {
    this.password = password;
  }

  public String getPassword() {
    return password;
  }

  public void setEmail(String email) {
    this.email = email;
  }

  public String getEmail() {
    return email;
  }

  public void setEntityContext(EntityContext context) throws RemoteException
{
    entityContext = context;
  }

  public void unsetEntityContext() throws RemoteException {
    entityContext = null;
  }
}

BMP bean class extends the upper bean class:

package ejbShop;

import java.sql.*;
import javax.sql.*;
import java.util.*;
import javax.ejb.*;
import java.rmi.*;
import javax.naming.*;

public class MerchantBean_BMP
          extends MerchantBean {

public void ejbLoad() throws RemoteException {
    Connection con=null;
    try {
System.out.println("Load1");
      Integer primaryKey =
       (Integer)entityContext.getPrimaryKey();
      con = this.getConnection();
      Statement sqlStmt = con.createStatement();
      ResultSet results = sqlStmt.executeQuery("SELECT * FROM Merchant WHERE
ID = " + primaryKey.intValue());
System.out.println("Load2");
      if (results.next()) {
        // get the name information
        //from the Merchant table
        name = results.getString("name");
        username = results.getString("username");
        password = results.getString("password");
        email = results.getString("email");
      }
    } catch (SQLException sqle) {
      throw new EJBException(sqle);
    } finally {
      try {
        if (con!=null)
          con.close();
       } catch (SQLException e) {throw new EJBException(e);}
    }
  }

  public void ejbStore() throws RemoteException {
    Connection con=null;
System.out.println("Store1");

    try {
      Integer primaryKey =
        (Integer)entityContext.getPrimaryKey();
      con = this.getConnection();
      PreparedStatement sqlPrep =
      con.prepareStatement(
         "UPDATE Merchant set " +
         "name = ?, username = ?, " +
         "password = ?, email = ? " +
         "WHERE id = ?");
      sqlPrep.setString(1,name);
      sqlPrep.setString(2,username);
      sqlPrep.setString(3,password);
      sqlPrep.setString(4,email);
      sqlPrep.setInt(5,primaryKey.intValue());
      sqlPrep.executeUpdate();
    System.out.println("Store2");
    } catch (SQLException sqle) {
      throw new EJBException(sqle);
    } finally {
      try {
        if (con!=null)
          con.close();
       } catch (SQLException e) {throw new EJBException(e);}
    }
  }

  public Integer ejbCreate(Integer idObj) throws RemoteException,
CreateException {
    this.id = idObj.intValue();
    System.out.println("Create1");
    Connection con=null;
    try {
      con = this.getConnection();
      System.out.println("Create1.4");
      Statement sqlStmt =  con.createStatement();
      String s="INSERT INTO Merchant (id) VALUES (" + id + ")";
      System.out.println("Create1.5"+sqlStmt+" id "+id);
      System.out.println("Create1.6"+s);
      sqlStmt.executeUpdate(s);
    System.out.println("Create2");
      return idObj;
    } catch(SQLException sqle) {
     sqle.printStackTrace();
      throw new EJBException(sqle);
    } finally {
      try {
        if (con!=null)
          con.close();
       } catch (SQLException e) {
        System.out.println("create"+e);

        throw new EJBException(e);}
    }
  }

  public void ejbRemove() throws RemoteException, RemoveException {
    Integer primaryKey =
     (Integer)entityContext.getPrimaryKey();
    System.out.println("Remove1");
    Connection con=null;
    try {
      con = this.getConnection();
      Statement sqlStmt =
      con.createStatement();
      sqlStmt.executeUpdate("DELETE FROM Merchant WHERE id = " +
                   primaryKey.intValue());
      System.out.println("Remove2");
    } catch(SQLException sqle) {
      throw new EJBException(sqle);
    } finally {
      try {
        if (con!=null)
          con.close();
       } catch (SQLException e) {throw new EJBException(e);}
    }
  }

  private Connection getConnection()
         throws SQLException {

     try {
     System.out.println("GetConn1");
      InitialContext jndiContext =
         new InitialContext();
     DataSource source = (DataSource)
                        jndiContext.lookup("Oracle");
     Connection con=null;
     con = source.getConnection();
     if (con!=null)
      System.out.println("Oracle je najden!");
    Statement sqlStmt = con.createStatement();
    ResultSet results = sqlStmt.executeQuery("SELECT * FROM Merchant WHERE
ID = 1");
    System.out.println("GetConn2");
    results.next();
    System.out.println(results.getString("name"));
     return con;
   } catch (Exception e) {
      e.printStackTrace();
      return null;
    }

  }

public Integer ejbFindByPrimaryKey(Integer primaryKey)
               throws ObjectNotFoundException {
    Connection con=null;
    try {
        System.out.println("Find1");
        con = this.getConnection();
        Statement sqlStmt =
            con.createStatement();

        ResultSet results = sqlStmt.executeQuery("SELECT * FROM Merchant " +
                             " WHERE ID = " + primaryKey.intValue());
       System.out.println("find metoda select stavek! " + primaryKey);
        if (results.next()) {
            System.out.println("Find objekt obstaja");
            return primaryKey;
        } else
            throw new ObjectNotFoundException();
    } catch (SQLException sqle) {
        throw new EJBException(sqle);
    } finally {
      try {
        if (con!=null)
          con.close();
       } catch (SQLException e) {throw new EJBException(e);}
    }
}


}

Thanks.

Primoz, Gasper



--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]

Reply via email to