hello, Alberto.
i see in your EJB that you keep Connection object in a
class field (con) instead of the DataSource object.
what i do in setEntityContext (and in ejbActivate) is
to look up the DataSource object and save that
DataSource in the class field. i only create the
Connection object when i make the actual SQL query,
update, or delete...
so in your case you must declare a DataSource field in
ItemEJB (for example, datasource) makeConnection()
should now be:
private void makeConnection() throws NamingException,
SQLException
{
InitialContext ic = new InitialContext();
datasource = (DataSource) ic.lookup(dbName);
}
you only create a Connection when you need to...for
example in deleteRow():
private void deleteRow(ItemKey pk) throws SQLException
{
Connection con = datasource.getConnection();
// do your thing here...
}
hope this helps.
dexter
--- Alberto Gil Alvarez <[EMAIL PROTECTED]> wrote:
> Well, I´m spanish and I´m sure that my english it´s
> no perfect, so be patient please.
>
> Let´s begin. This is my configuration :
>
> - JDK 1.3
> - JBoss 2.2.1(running in my PC)
> - Oracle 8.1.6 (running in other machine)
> - Oracle XA JDBC drivers
>
> I´m running JBoss under Windows 2K. I have installed
> the Oracle drivers following the documentation. In
> fact, my steps were exactly the same,
> and the same sentences. I modified these sentences
> in the "jboss.jcml" file :
>
> <!-- JDBC -->
> <mbean code="org.jboss.jdbc.JdbcProvider"
> name="DefaultDomain:service=JdbcProvider">
> <attribute
>
name="Drivers">org.hsql.jdbcDriver,org.enhydra.instantdb.jdbc.idbDriver,oracle.jdbc.driver.OracleDriver</attribute>
>
> </mbean>
>
> and I added these :
>
> <mbean code="org.jboss.jdbc.XADataSourceLoader"
>
name="DefaultDomain:service=XADataSource,name=OracleDS">
> <attribute
> name="PoolName">jdbc/OracleDS</attribute>
> <attribute
>
name="DataSourceClass">org.opentools.minerva.jdbc.xa.wrapper.XADataSourceImpl</attribute>
> <attribute
>
name="URL">jdbc:oracle:thin:@aifsrvpruebas:1521:sflw</attribute>
> <attribute name="JDBCUser">U605</attribute>
> <attribute name="Password">U605</attribute>
> </mbean>
>
>
> When I start JBoss , it prints this :
>
> [JDBC provider] Loaded
> JDBC-driver:oracle.jdbc.driver.OracleDriver
> [JDBC provider] Initialized
>
> and about the dataStore :
>
> [jdbc/OracleDS] Starting
> [jdbc/OracleDS] XA Connection pool jdbc/OracleDS
> bound to java:/jdbc/OracleDS
> [jdbc/OracleDS] Started
>
> So I suppose that all is correct.
>
> I have included the ejb and the client application
> I´m testing. The ejb (ItemEJB file) is a BMP entity
> bean that manage the item table. The client
> application
> ( ItemClient file ) inserts two rows in the table
> and get the price of the items. This is the code :
>
> "Item item1 = home.create("01", "00000000000127",
> "Puleva", 120.00);
> double price = item1.getPrice();
> System.out.println("price = " +
> String.valueOf(price));
> // item1.remove();
> Item item2 = home.create("01", "00000000000840",
> "Atun", 100.00);
> price = item2.getPrice();
> System.out.println("price = " +
> String.valueOf(price));"
>
> And here is the little problem. When I run the
> client program, and the rows exist in the table , I
> get the next error :
> "Caught an exception.
>
> java.rmi.ServerException: RemoteException occurred
> in server thread; nested exception is:
> javax.transaction.TransactionRolledbackException:
> ejbCreate: ORA-00001: restricción única
> (U604.I6198010) violada; nested exception is:
> javax.ejb.EJBException: ejbCreate: ORA-00001:
> restricción única (U604.I6198010)
>
violadajavax.transaction.TransactionRolledbackException:
> ejbCreate: ORA-00001: restricción única
> (U604.I6198010) violada; nested exception is:
> javax.ejb.EJBException: ejbCreate: ORA-00001:
> restricción única (U604.I6198010) violada
> javax.ejb.EJBException: ejbCreate: ORA-00001:
> restricción única (U604.I6198010) violadaat
>
sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:245)
> at
>
sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:220)
> at
>
sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)
> at
>
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker_Stub.invokeHome(Unknown
> Source) at
>
org.jboss.ejb.plugins.jrmp.interfaces.HomeProxy.invoke(HomeProxy.java:248)
> at $Proxy0.create(Unknown Source) at
>
com.web_tomorrow.item.ItemClient.main(ItemClient.java:35)
> "
>
> That´s Ok. I get the same result in the Sun EJB
> container and in JBoss. Well, if I repeat the
> execution of the program in the reference Sun EJB
> container , I always get the same result (above),
> but when I do the same in JBoss, the result is
> diferent :
>
> "java.rmi.ServerException: RemoteException occurred
> in server thread; nested exception is:
> javax.transaction.TransactionRolledbackException:
> ejbCreate: Connection has been closed!; nested
> exception is: javax.ejb.EJBException: ejbCreate:
> Connection has been closed!
> javax.transaction.TransactionRolledbackException:
> ejbCreate: Connection has been closed!; nested
> exception is: javax.ejb.EJBException: ejbCreate:
> Connection has been closed! javax.ejb.EJBException:
> ejbCreate: Connection has been closed! at
>
sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:245)
> at
>
sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:220)
> at
>
sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)
> at
>
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker_Stub.invokeHome(Unknown
> Source) at
>
org.jboss.ejb.plugins.jrmp.interfaces.HomeProxy.invoke(HomeProxy.java:248)
> at $Proxy0.create(Unknown Source) at
>
com.web_tomorrow.item.ItemClient.main(ItemClient.java:35)
> "
>
> I can´t understand what´s happend, but I think that
> JBoss has closed the connection. The behavior is
> diferent . From that moment It´s impossible to
> connect to Oracle from JBoss, I have to stop JBoss
> an start again. Perhaps It could be a configuration
> error, I don´t know.
>
>
>
> Please , I need help. Could anybody help me ?
>
> Thanks in advanced.
>
>
> ATTACHMENT part 2 application/x-javascript
name=ItemKey.java
> ATTACHMENT part 3 application/x-javascript
name=Item.java
> ATTACHMENT part 4 application/x-javascript
name=ItemClient.java
> ATTACHMENT part 5 application/x-javascript
name=ItemEJB.java
> ATTACHMENT part 6 application/x-javascript
name=ItemHome.java
> ATTACHMENT part 7 application/x-javascript
name=EJBLog.java
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year! http://personal.mail.yahoo.com/
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user