This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Ladies and gentlemen, I have been able to deploy a BMP bean, and deploy it to JBoss. I�m writing code to stress is, the result of it have not been very satistfactory. I have created a BMP entity bean called product. I have put together a Java client that tells to the home interface of the bean to create 100000 objects. When arriving to the object 62000 approx., an "out of memory" error comes up. I do not know if that�s because this is not the way I am supposed to stress the product, or what. If you guys have ans answer for this, please answer. I have the error message that my client shows, and the code that I use for the strees test. Thanks much to all! ---------------- Error ---------------------------------- java.rmi.ServerError: Error occurred in server thread; nested exception is: java.lang.OutOfMemoryError at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:289) 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:534) 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:135) at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.jav a:87) at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor. java:46) at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:4 5) at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:173) at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85) at $Proxy2.create(Unknown Source) at test.client.TestClient.main(TestClient.java:49) Caused by: java.lang.OutOfMemoryError ---------------------- Code for the stress test ------------------------- package test.client; import javax.naming.InitialContext; import javax.rmi.PortableRemoteObject; import test.interfaces.ProductHome; import test.interfaces.ProductPK; import test.interfaces.ProductData; import test.interfaces.Product; public class TestClient { public static void main(String[] args){ try { InitialContext lContext = new InitialContext();
dProduct.setProductId(i); dProduct.setProductName(Integer.toString(i) + ". A name for the bean"); dProduct.setDescription("Description of the bean"); dProduct.setPrice(234);
Product lProduct = prodHome.create(dProduct);
lProduct = null;
i = i + 1; }
} catch( Exception e ){ e.printStackTrace(); } }
Claudio Gualberto
Ranch Hand
Joined: Oct 13, 2002
Posts: 47
posted
0
I think you're better to post the BMP code here, as your container-configuration if it's not the default for BMP.
Hi, Claudio. Thanks for answering. This is my jboss.xml file: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.0//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_0.dtd"> <jboss> <enterprise-beans> <!-- To add beans that you have deployment descriptor info for, add a file to your XDoclet merge directory called jboss-beans.xml that contains the <session></session>, <entity></entity> and <message-driven></message-driven> markup for those beans. --> <entity> <ejb-name>User</ejb-name> <jndi-name>User</jndi-name> </entity> <entity> <ejb-name>Product</ejb-name> <jndi-name>Product</jndi-name> <local-jndi-name>ProductLocal</local-jndi-name> </entity> <session> <ejb-name>Adder</ejb-name> <jndi-name>Adder</jndi-name> <local-jndi-name>AdderLocal</local-jndi-name> </session> </enterprise-beans> <resource-managers> </resource-managers> </jboss> This is the code used to generate the bean: import test.interfaces.ProductPK; import test.interfaces.ProductData;
/** * The Entity bean represents a TestEntity with BMP * * @author Andreas Schaefer * @version $Revision: 1.1 $ * * @ejb:bean name="Product" * display-name="Entity that supports products(BMP)" * type="BMP" * jndi-name="Product" * * @ejb:env-entry name="DataSourceName" * value="java:/BelisarioDS" * * @ejb:transaction type="Required" * * @ejb ata-object extends="test.interfaces.AbstractData" * setdata="false" * **/ public abstract class ProductBean implements EntityBean {
/** * Store the data within the provided data object into this bean. * * @param pProductBean The Value Object containing the ProductBean values * * @ejb:interface-method view-type="remote" **/ public void setValueObject( ProductData pProductBean ) throws InvalidValueException { setProductId( pProductBean.getProductId() ); setDescription( pProductBean.getDescription() ); setProductName( pProductBean.getProductName() ); setPrice (pProductBean.getPrice()); }
/** * Create and return a TestEntity data object populated with the data from * this bean. * * @return Returns a TestEntity value object containing the data within this * bean. * * @ejb:interface-method view-type="remote" **/ public ProductData getValueObject() { ProductData lData = new ProductData();
/** * Describes the instance and its content for debugging purpose * * @return Debugging information about the instance and its content **/ public String toString() { return "TestBMPEntityBean [ " + getValueObject() + " ]"; }
/** * Mark the Entity as changed that needs to be saved **/ protected abstract void makeDirty(); /** * Mark the Entity as synchronized with the DB and does * not need to be saved **/ protected abstract void makeClean();
private void save( boolean pIsNew ) {
Connection con = null; PreparedStatement ps = null; String sql = null; try { if( pIsNew ) { // Note that the Primary Key "Id" is the last to match the UPDATE statement sql = "INSERT INTO Products" + " (ProductName, Description, Price, ProductId)" + " VALUES" + " (?, ?, ?, ?)"; } else { sql ="UPDATE Products" + " SET ProductName=?, Description=?, Price=?" + " WHERE ProductId=?"; }
con = getConnection(); ps = con.prepareStatement(sql); ps.setString(1, getProductName()); ps.setString(2, getDescription()); ps.setDouble(3, getPrice()); ps.setInt(4, getProductId()); ps.executeUpdate(); } catch(SQLException e) { //System.out.println(e.toString()); throw new EJBException( "Could not save record to DB: " + e.getMessage() ); } finally { try { if (ps != null) ps.close(); if (con != null) con.close(); } catch (SQLException e ){ } }
}
// ------------------------------------------------------------------------- // Properties (Getters/Setters) // ------------------------------------------------------------------------- /** * Retrieve the Product�s entity ID. * * @return Returns an int representing the id of this TestEntity. * * @ejb ersistent-field * @ejb k-field **/ public abstract int getProductId();
/** * Set the Product's id. * * @param pId The id of this Product. Is set at creation time. **/ public abstract void setProductId( int pProductId );
/** * Retrieve the Product�s Name. * * @return Returns an int representing the Name of the Product. * * @ejb ersistent-field **/ public abstract String getProductName();
/** * Set the entity�s Products�s Name. * * @param pFirstName The name of the product. Is set at creation time. **/ public abstract void setProductName( String pProductName );
/** * Retrieve the Product�s Description. * * @return Returns an int representing the Description of the product. * * @ejb ersistent-field **/ public abstract String getDescription();
/** * Set the TestEntity's LastName. * * @param pLastName The description of the product. Is set at creation time. **/ public abstract void setDescription( String pDescription );
/** * Retrieve the Product�s Price * * @return Returns an int representing the Price of the product. * * @ejb ersistent-field **/ public abstract int getPrice();
/** * Set the Product�s's LastName. * * @param pLastName The priceof the product. **/ public abstract void setPrice( int pPrice );
/** * Create a TestEntity based on the supplied TestEntity Value Object. * * @param pTestEntity The data used to create the TestEntity. * * @throws InvalidValueException If one of the values are not correct, * this will not roll back the transaction * because the caller has the chance to * fix the problem and try again * @throws EJBException If no new unique ID could be retrieved this will * rollback the transaction because there is no * hope to try again * @throws CreateException Because we have to do so (EJB spec.) * * @ejb:create-method view-type="remote" **/ public ProductPK ejbCreate( ProductData pProduct ) throws InvalidValueException, EJBException, CreateException { // Clone the given Value Object to keep changed private ProductData lData = (ProductData) pProduct.clone(); // Save the new TestEntity setValueObject( lData ); save( true ); // Return the PK which is mandatory in BMPs return new ProductPK( getProductId() ); }