I have 2xHome's and 2xInterfaces, but a single bean implementation.  How do the
interfaces know which methods to call on the Bean for remote versus local return
values?  I like that idea though! :)



-- 
-bk


Quoting Chris Chen <[EMAIL PROTECTED]>:

> I use XDoclet for code generation and what I normally do is separate the 
> local and remote interfaces into two separate home interfaces that I bind 
> to the JNDI.  Then, if I decide to have use Local Interface methods, I can 
> simply retrieve the local home.  The same applies to Remote Interface 
> methods.  This has the added benefit of allowing me to use the same method 
> name for the local and remote since it's the Home that I'm retrieving that 
> indicates to JBoss whether I want local or remote method calls.
> 
> Thanks,
> Chris
> 
> At 05:42 PM 06/11/2002, you wrote:
> >Okay, I figured it out!!  I was calling getPlaylists, which returns the
> Local
> >objects...naughty naughty! :)
> >
> >So I implemented a getRemotePlaylists method and that seems to work great!
> >WOOHOO! :)  Thanks for being patient with me! :)
> >
> >Anyhow, since I do intend to my EJBs in a Local model, I'm not worried 
> >about the
> >naming convention, but I cam curious as to what the standard practice is. 
> I
> >have the following in my code to cope with this, is this the right way to
> do
> >things??
> >
> >     public abstract Collection getPlaylists();
> >     public abstract void setPlaylists(Collection value);
> >
> >     public Collection getRemotePlaylists() {
> >         Vector rc=new Vector();
> >
> >         try {
> >             Properties p=new Properties();
> >             p.put("java.naming.factory.initial",
> >             "org.jnp.interfaces.NamingContextFactory");
> >             p.put("java.naming.provider.url", "jnp://localhost:1099");
> >             p.put("java.naming.factory.url.pkgs",
> >             "org.jboss.naming:org.jnp.interfaces");
> >             InitialContext iniCtx = new InitialContext(p);
> >             Context ejbCtx=(Context) iniCtx.lookup("comp/env/ejb");
> >             PlaylistHome home=(PlaylistHome)ejbCtx.lookup("Playlist");
> >
> >             Iterator it=getPlaylists().iterator();
> >             while(it.hasNext()) {
> >                 PlaylistLocal pll=(PlaylistLocal)it.next();
> >                 rc.add(home.findByPrimaryKey(pll.getPlaylistId()));
> >             }
> >         } catch (Exception ex) {
> >             throw new EJBException (ex);
> >         }
> >
> >         return(rc);
> >     }
> >
> >
> >Ignore the fact that I have all the naming stuff hardcoded and such!  Is
> this
> >the proper way to do things?
> >
> >Thanks in advance!!
> >
> >--
> >-bk
> >
> >
> >Quoting Brandon Knitter <[EMAIL PROTECTED]>:
> >
> > > Okay, I have a 1-to-many relationship set up, and I'm thinking I did it
> > > right! ;-)
> > >
> > > I have patched the server to supposedly "un hide" exceptions on the
> server,
> > > but
> > > I'm not actually getting any stacks in my server.log output.
> > >
> > > Patch:
> > >
>
>http://sourceforge.net/tracker/index.php?func=detail&aid=562036&group_id=22866&atid=376687
> > >
> > > My many-to-one relational call works great (my Playlist can ask for the
> > > User).
> > > I'm so excited! :)  I may have actually figured this out!! :-D :-D
> > >
> > > The problem now is in my one-to-many call (my User asking for a
> Collection
> > > of
> > > Playlists), that's failing.
> > >
> > > My client call (remote) looks like:
> > >
> > > 35            User user=home.findByPrimaryKey(id);
> > > 36            System.out.println("name :"+user.getUsername());
> > > 37            System.out.println("user id :"+user.getUserId());
> > > 38            System.out.println("email :"+user.getEmailAddress());
> > > 39            Collection col=user.getPlaylists();
> > >
> > > The user.getUsername() and other methods work fine.  My getPlaylists()
> > > fails
> > > with the following on the client side:
> > >
> > > name :knitterb
> > > user id :4
> > > email :[EMAIL PROTECTED]
> > > Exception in thread "main"
> java.lang.reflect.UndeclaredThrowableException
> > >         at $Proxy1.getPlaylists(Unknown Source)
> > >         at org.blandsite.music.user.UserClient.main(UserClient.java:39)
> > > Caused by: java.io.NotSerializableException:
> > > org.jboss.ejb.plugins.cmp.jdbc.bridge.RelationSet
> > >         at
> > > java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
> > >         at
> > > java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
> > >         at java.rmi.MarshalledObject.<init>(MarshalledObject.java:92)
> > >         at
> > >
> org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:367)
> > >         at sun.reflect.GeneratedMethodAccessor30.invoke(Unknown Source)
> > >         at
> > >
>
>sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.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:460)
> > >         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(StreamRemoteCall.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
> > > Source)
> > >         at
> > >
>
>org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:128)
> > >         at
> > >
> org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:108)
> > >         at
> > > 
> >
> org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:73)
> > >         at
> > > org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:76)
> > >         at
> > >
> org.jboss.proxy.ejb.EntityInterceptor.invoke(EntityInterceptor.java:116)
> > >         at
> org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)
> > >         ... 2 more
> > >
> > >
> > > I have implemented nothing special in the UserBean entity bean, except
> > > stated
> > > that the getPlaylists method is abstract, and described it as such in
> my
> > > cmr
> > > entries:
> > >
> > >     public abstract Collection getPlaylists();
> > >     public abstract void setPlaylists(Collection value);
> > >
> > > == ejb-jar.xml ==
> > > <relationships>
> > >     <ejb-relation>
> > >         <description>User-to-Playlist</description>
> > >         <ejb-relation-name>User-to-Playlist</ejb-relation-name>
> > >         <ejb-relationship-role>
> > >            
> <ejb-relationship-role-name>User</ejb-relationship-role-name>
> > >             <multiplicity>One</multiplicity>
> > >             <relationship-role-source>
> > >                 <ejb-name>UserBean</ejb-name>
> > >             </relationship-role-source>
> > >             <cmr-field>
> > >                 <cmr-field-name>playlists</cmr-field-name>
> > >                 <cmr-field-type>java.util.Collection</cmr-field-type>
> > >             </cmr-field>
> > >         </ejb-relationship-role>
> > >         <ejb-relationship-role>
> > >
> > > <ejb-relationship-role-name>Playlist</ejb-relationship-role-name>
> > >             <multiplicity>Many</multiplicity>
> > >             <relationship-role-source>
> > >                 <ejb-name>PlaylistBean</ejb-name>
> > >             </relationship-role-source>
> > >             <cmr-field>
> > >                 <cmr-field-name>user</cmr-field-name>
> > >             </cmr-field>
> > >         </ejb-relationship-role>
> > >     </ejb-relation>
> > > </relationships>
> > > == END ejb-jar.xml ==
> > >
> > > Am I maybe missing something in my jbosscmp-jdbc.xml?
> > >
> > > == jbosscmp-jdbc.xml ==
> > >     <relationships>
> > >         <ejb-relation>
> > >             <ejb-relation-name>User-to-Playlist</ejb-relation-name>
> > >             <foreign-key-mapping/>
> > >             <ejb-relationship-role>
> > >
> > > <ejb-relationship-role-name>User</ejb-relationship-role-name>
> > >                 <key-fields>
> > >                     <key-field>
> > >                         <field-name>userId</field-name>
> > >                         <column-name>user_id</column-name>
> > >                     </key-field>
> > >                 </key-fields>
> > >             </ejb-relationship-role>
> > >             <ejb-relationship-role>
> > >
> > > <ejb-relationship-role-name>Playlist</ejb-relationship-role-name
> > > >
> > >                 <key-fields/>
> > >             </ejb-relationship-role>
> > >         </ejb-relation>
> > >     </relationships>
> > > == END jbosscmp-jdbc.xml ==
> > >
> > >
> > > Here's the section of the server.log showing this call:
> > >
> > > == server.log ==
> > > 2002-06-11 16:06:05,905 TRACE [org.jboss.ejb.plugins.LogInterceptor]
> Start
> > > metho
> > > d=getPlaylists
> > > 2002-06-11 16:06:05,906 TRACE [org.jboss.ejb.plugins.TxInterceptorCMT]
> > > Current t
> > > ransaction in MI is null
> > > 2002-06-11 16:06:05,906 TRACE [org.jboss.ejb.plugins.TxInterceptorCMT]
> > > TX_REQUIR
> > > ED for getPlaylists
> > > 2002-06-11 16:06:05,907 TRACE [org.jboss.ejb.plugins.TxInterceptorCMT] 
> > Thread
> > > ca
> > > me in with tx null
> > > 2002-06-11 16:06:05,908 TRACE [org.jboss.ejb.plugins.TxInterceptorCMT]
> > > Starting
> > > new tx TransactionImpl:XidImpl [FormatId=257, GlobalId=zoot//51,
> > > BranchQual=]
> > > 2002-06-11 16:06:05,910 TRACE
> [org.jboss.ejb.plugins.EntityLockInterceptor]
> > > Begi
> > > n invoke, key=4
> > > 2002-06-11 16:06:05,912 TRACE
> > > [org.jboss.ejb.plugins.EntityInstanceInterceptor]
> > > Begin invoke, key=4
> > > 2002-06-11 16:06:05,913 TRACE
> > > [org.jboss.ejb.plugins.EntitySynchronizationInterc
> > > eptor] invoke called for ctx
> org.jboss.ejb.EntityEnterpriseContext@df4bfc,
> > > tx=Tr
> > > ansactionImpl:XidImpl [FormatId=257, GlobalId=zoot//51, BranchQual=]
> > > 2002-06-11 16:06:05,913 TRACE
> > > [org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.U
> > > serBean] RESET PERSISTENCE CONTEXT: id=4
> > > 2002-06-11 16:06:05,914 TRACE
> > > [org.jboss.ejb.plugins.cmp.jdbc.ReadAheadCache.Use
> > > rBean] load data: entity=UserBean pk=4
> > > 2002-06-11 16:06:05,914 TRACE
> > > [org.jboss.ejb.plugins.cmp.jdbc.ReadAheadCache.Use
> > > rBean] No preload data found: entity=UserBean pk=4
> > > 2002-06-11 16:06:05,914 TRACE
> > > [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityComm
> > > and.UserBean] Eager-load for entity: readahead=[JDBCReadAheadMetaData :
> > > strategy
> > > =on-load, pageSize=255, eagerLoadGroup=*]
> > > 2002-06-11 16:06:05,922 DEBUG
> > > [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityComm
> > > and.UserBean] Executing SQL: SELECT uid, pwd, fn, ln, email, bitrate,
> > > playlink F
> > > ROM users WHERE (user_id=?)
> > > 2002-06-11 16:06:05,923 TRACE
> > > [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFi
> > > eldBridge.UserBean.userId] Set parameter: index=1, jdbcType=INTEGER,
> > > value=4
> > > 2002-06-11 16:06:05,932 TRACE
> > > [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFi
> > > eldBridge.UserBean.username] Get result: index=1, 
> > javaType=java.lang.String,
> > > Sim
> > > ple, value=knitterb
> > > 2002-06-11 16:06:05,932 TRACE
> > > [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFi
> > > eldBridge.UserBean.password] Get result: index=2, 
> > javaType=java.lang.String,
> > > Sim
> > > ple, value=4d27eae655e7272b21c5b0a539656a8ae869d75f
> > > 2002-06-11 16:06:05,933 TRACE
> > > [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFi
> > > eldBridge.UserBean.firstname] Get result: index=3, 
> > javaType=java.lang.String,
> > > Si
> > > mple, value=Brandon
> > > 2002-06-11 16:06:05,934 TRACE
> > > [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFi
> > > eldBridge.UserBean.lastname] Get result: index=4, 
> > javaType=java.lang.String,
> > > Sim
> > > ple, value=Knitter
> > > 2002-06-11 16:06:05,934 TRACE
> > > [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFi
> > > eldBridge.UserBean.emailAddress] Get result: index=5,
> > > javaType=java.lang.String,
> > >  Simple, [EMAIL PROTECTED]
> > > 2002-06-11 16:06:05,935 TRACE
> > > [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFi
> > > eldBridge.UserBean.bitrate] Get result: index=6, javaType=int, Simple,
> > > value=0
> > > 2002-06-11 16:06:05,935 TRACE
> > > [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFi
> > > eldBridge.UserBean.playlink] Get result: index=7, javaType=int, Simple,
> > > value=1
> > > 2002-06-11 16:06:05,937 TRACE
> > > [org.jboss.ejb.plugins.EntitySynchronizationInterc
> > > eptor] register, ctx=org.jboss.ejb.EntityEnterpriseContext@df4bfc,
> > > tx=Transactio
> > > nImpl:XidImpl [FormatId=257, GlobalId=zoot//51, BranchQual=]
> > > 2002-06-11 16:06:05,938 TRACE
> > > [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFiel
> > > dBridge.UserBean.playlists] Read ahead cahce load: cmrField=playlists
> pk=4
> > > 2002-06-11 16:06:05,939 TRACE
> > > [org.jboss.ejb.plugins.cmp.jdbc.ReadAheadCache.Use
> > > rBean] load data: entity=UserBean pk=4
> > > 2002-06-11 16:06:05,939 TRACE
> > > [org.jboss.ejb.plugins.cmp.jdbc.ReadAheadCache.Use
> > > rBean] No preload data found: entity=UserBean pk=4
> > > 2002-06-11 16:06:05,940 DEBUG
> > > [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadRelationCo
> > > mmand.UserBean] Executing SQL: SELECT playlist_id FROM playlists WHERE
> > > (user_id=
> > > ?)
> > > 2002-06-11 16:06:05,941 TRACE
> > > [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFi
> > > eldBridge.PlaylistBean.userId] Set parameter: index=1,
> jdbcType=INTEGER,
> > > value=4
> > > 2002-06-11 16:06:05,947 TRACE
> > > [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFi
> > > eldBridge.PlaylistBean.playlistId] Get result: index=1,
> > > javaType=java.lang.Integ
> > > er, Simple, value=1000
> > > 2002-06-11 16:06:05,948 TRACE
> > > [org.jboss.ejb.plugins.cmp.jdbc.ReadAheadCache.Pla
> > > ylistBean] Add preload data: entity=PlaylistBean pk=1000 field=user
> > > 2002-06-11 16:06:05,949 TRACE
> > > [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFi
> > > eldBridge.PlaylistBean.playlistId] Get result: index=1,
> > > javaType=java.lang.Integ
> > > er, Simple, value=1001
> > > 2002-06-11 16:06:05,949 TRACE
> > > [org.jboss.ejb.plugins.cmp.jdbc.ReadAheadCache.Pla
> > > ylistBean] Add preload data: entity=PlaylistBean pk=1001 field=user
> > > 2002-06-11 16:06:05,949 TRACE
> > > [org.jboss.ejb.plugins.cmp.jdbc.ReadAheadCache.Pla
> > > ylistBean] Add preload data: entity=PlaylistBean pk=1001 field=user
> > > 2002-06-11 16:06:05,950 TRACE
> > > [org.jboss.ejb.plugins.cmp.jdbc.ReadAheadCache.Pla
> > > ylistBean] Add finder results: entity=PlaylistBean results=[1000, 1001]
> > > readahea
> > > d=[JDBCReadAheadMetaData : strategy=on-load, pageSize=1000,
> > > eagerLoadGroup=*]
> > > 2002-06-11 16:06:05,950 TRACE
> > > [org.jboss.ejb.plugins.EntityInstanceInterceptor]
> > > End invoke, key=4, ctx=org.jboss.ejb.EntityEnterpriseContext@df4bfc
> > > 2002-06-11 16:06:05,951 TRACE
> [org.jboss.ejb.plugins.EntityLockInterceptor]
> > > End
> > > invoke, key=4
> > > 2002-06-11 16:06:05,951 TRACE [org.jboss.ejb.plugins.TxInterceptorCMT]
> > > TxInterce
> > > ptorCMT: In finally
> > > 2002-06-11 16:06:05,952 TRACE [org.jboss.ejb.plugins.TxInterceptorCMT]
> > > TxInterce
> > > ptorCMT:before commit of TransactionImpl:XidImpl [FormatId=257,
> > > GlobalId=zoot//5
> > > 1, BranchQual=]
> > > 2002-06-11 16:06:05,953 TRACE
> > > [org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCom
> > > mand.UserBean] Store command NOT executed. Entity is not dirty: pk=4
> > > 2002-06-11 16:06:05,970 TRACE
> > > [org.jboss.ejb.plugins.EntitySynchronizationInterc
> > > eptor] afterCompletion, clear tx for
> > > ctx=org.jboss.ejb.EntityEnterpriseContext@d
> > > f4bfc, tx=TransactionImpl:XidImpl [FormatId=257, GlobalId=zoot//51,
> > > BranchQual=]
> > > 2002-06-11 16:06:05,970 TRACE
> > > [org.jboss.ejb.plugins.EntitySynchronizationInterc
> > > eptor] afterCompletion, sent notify on TxLock for
> > > ctx=org.jboss.ejb.EntityEnterp
> > > riseContext@df4bfc
> > > 2002-06-11 16:06:05,971 TRACE [org.jboss.ejb.plugins.TxInterceptorCMT]
> > > TxInterce
> > > ptorCMT:after commit of TransactionImpl:XidImpl [FormatId=257,
> > > GlobalId=zoot//51
> > > , BranchQual=]
> > > 2002-06-11 16:06:05,971 TRACE [org.jboss.ejb.plugins.LogInterceptor]
> End
> > > method=
> > > getPlaylists
> > > == END server.log ==
> > >
> > >
> > > I don't see anything else, do you?  Man it feels good to be close! :)
> > >
> > > --
> > > -bk
> > >
> > >
> > >
> > >
> > >
> > >
> > > _______________________________________________________________
> > >
> > > Multimillion Dollar Computer Inventory
> > > Live Webcast Auctions Thru Aug. 2002 -
> > > http://www.cowanalexander.com/calendar
> > >
> > >
> > >
> > > _______________________________________________
> > > JBoss-user mailing list
> > > [EMAIL PROTECTED]
> > > https://lists.sourceforge.net/lists/listinfo/jboss-user
> > >
> > >
> >
> >
> >
> >_______________________________________________________________
> >
> >Multimillion Dollar Computer Inventory
> >Live Webcast Auctions Thru Aug. 2002 -
> http://www.cowanalexander.com/calendar
> >
> >
> >
> >_______________________________________________
> >JBoss-user mailing list
> >[EMAIL PROTECTED]
> >https://lists.sourceforge.net/lists/listinfo/jboss-user
> 
> PGP at ldap://certserver.pgp.com/
> 
> 
> _______________________________________________________________
> 
> Multimillion Dollar Computer Inventory
> Live Webcast Auctions Thru Aug. 2002 -
> http://www.cowanalexander.com/calendar
> 
> 
> 
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-user
> 
> 



_______________________________________________________________

Multimillion Dollar Computer Inventory
Live Webcast Auctions Thru Aug. 2002 - http://www.cowanalexander.com/calendar



_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to