Hi all,
I hope I'll get an answer this way.
My problem :
I want to lookup the entity bean B in the method of the entity bean A
(especially when I create the A bean in the test client).
These two beans are in the same application and physically packaged in the
same jar.
I use no session bean : maybe I did.
I search more informations about the transaction tag (tx-attribute).
Thanks in advance
Sylvain
------------------------------------------------------------------------
My config :
- JBOSS 2.0 running on my desktop (Windows2000)
- Database : mySQL (v 3.23.35a) on my desktop
My application (ejb-jar.xml):
<entity>
<ejb-name>A</ejb-name>
<home>direct1.direct2.AHome</home>
<remote>direct1.direct2.A</remote>
<ejb-class>direct1.direct2.ABean</ejb-class>
<table-name>IM_A</table-name>
<create-table>false</create-table>
<persistence-type>Container</persistence-type>
<prim-key-class>direct1.direct2.APK</prim-key-class>
<reentrant>False</reentrant>
<tx-attribute>TX_SUPPORTS</tx-attribute>
<primkey-field>id</primkey-field>
<cmp-field>
<field-name>id</field-name>
<column-name>id</column-name>
</cmp-field>
<ejb-ref>
<ejb-ref-name>A</ejb-ref-name>
<ejb-ref-type>entity</ejb-ref-type>
<home>direct1.direct2.BHome</home>
<remote>direct1.direct2.B</remote>
<ejb-link>B</ejb-link>
</ejb-ref>
</entity>
<entity>
<ejb-name>B</ejb-name>
<home>direct1.direct2.BHome</home>
<remote>direct1.direct2.B</remote>
<ejb-class>direct1.direct2.BBean</ejb-class>
<table-name>IM_B</table-name>
<create-table>false</create-table>
<prim-key-class>direct1.direct2.BPK</prim-key-class>
<persistence-type>Container</persistence-type>
<reentrant>True</reentrant>
<tx-attribute>TX_SUPPORTS</tx-attribute>
<primkey-field>id</primkey-field>
<cmp-field>
<field-name>id</field-name>
<column-name>id</column-name>
<jdbc-type>INTEGER</jdbc-type>
<sql-type>INTEGER</sql-type>
</cmp-field>
</entity>
No problem with JBOSS on the deployement.
I just want to run one client who create a Bean A's instance and want to
read all the associated B bean (the primary key Bean A is an external key
of the bean B).
Client :
InitialContext jndiContext = new InitialContext();
Object ref = jndiContext.lookup("A");
// Get a reference from this to the Bean's Home interface
AHome home = (AHome) PortableRemoteObject.narrow (ref, AHome.class);
// Create a Url Bean
A myA =
home.create(100,"www.yahoo.fr","toto","POST",0,1,"02/04/2001","02/04/2001",
StringToDate("20010402000000"),StringToDate("20010402000000"),"AA","BB",(byt
e)0,StringToDate("02/04/2001"));
// Recherche
....
}
Bean A :
public void setEntityContext(EntityContext ctx) throws RemoteException {
this.urlCtx = ctx; // Initialisation du contexte
try {
this.myBHome = (BHome) Naming.lookup("//localhost:1099/B");
}
catch (RemoteException ne) {
System.out.println("RemoteException dans
ABean.setEntityContext()");
throw new RemoteException();
}
}
I've catched an exception on the instruction lookup :
java.rmi.ServerException: RemoteException occurred in server thread; nested
exception is:
javax.transaction.TransactionRolledbackException: null; nested exception
is:
java.rmi.RemoteException
javax.transaction.TransactionRolledbackException: null; nested exception is:
java.rmi.RemoteException
java.rmi.RemoteException
at
sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteC
all.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(Unkno
wn Source)
at
org.jboss.ejb.plugins.jrmp.interfaces.HomeProxy.invoke(HomeProxy.java:248)
at org.jboss.proxy.ProxyCompiler$Runtime.invoke(ProxyCompiler.java:74)
at IMonitor.entity.UrlHome$Proxy.create(Unknown Source)
at TestBean.main(TestBean.java:43)
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user