Local and remote interface apply to all kinds of EJBs, entity and session. Are
you using BMP or CMP for your entity beans? Under normal circumstances there
can be up to 5 classes defining your EJB : 2 home interfaces (defining create,
finders,...), 2 remote interfaces (containing your business methods) and the
bean implementation class. Both remote and home interfaces have a local variant
and a "remote" variant (see below).
The return type for your finder method should be Collection, Iterator or your
EJB itself and depends on the type of interface, the local accessable and the
remote accessable.
Typically the home interface (accessable outside the container) looks something
like
public interface TestEJBHome extends javax.ejb.EJBHome {
| public Test.TestEJB findByPrimaryKey(java.lang.String aKey)
| throws javax.ejb.FinderException, java.rmi.RemoteException;
|
| public TestEJB findById() throws java.rmi.RemoteException,
javax.ejb.FinderException;
| }
|
The local home interface (accessable only from within the container, other
EJBs, servlets,...) looks like
public interface LocalTestEJBHome extends javax.ejb.EJBLocalHome {
| public Test.LocalTestEJB findByPrimaryKey(java.lang.String Key) throws
javax.ejb.FinderException;
|
| public LocalTestEJB findById() throws javax.ejb.FinderException;
| }
|
Notice the difference in return type for the different interfaces !!
Local interfaces are preferred if you only want to access your EJB from within
the container (application server) and not from the outsite (swing client
application for example). In fact, local interface are more performant since
they don't have RMI overhead. So think well, before you start coding ;-)
Since you are accessing your entity beans from within session beans in your
project, local interfaces will be sufficient. What you get in your code is
typically something like
LocalTestEJBHome home = context.lookup("ejb/TestEJB");
| LocalTestEJB bean = home.create();
In your deployment descriptors, ejb/TestEJB must be linked to the LocalTestEJB
off course.
This is probably not much information, but if you like I could take a look at a
piece of code, specifically the part where you access your entity bean and the
entity bean itself.
The corresponding deployment descriptor looks like
<ejb-jar>
| <enterprise-beans>
| <entity>
| <display-name>TestEJB</display-name>
| <ejb-name>TestEJB</ejb-name>
| <home>Test.TestEJBHome</home>
| <remote>Test.TestEJB</remote>
| <local-home>Test.LocalTestEJBHome</local-home>
| <local>Test.LocalTestEJB</local>
| <ejb-class>Test.TestEJBBean</ejb-class>
| <persistence-type>Container</persistence-type>
| <prim-key-class>java.lang.String</prim-key-class>
| <reentrant>False</reentrant>
| <abstract-schema-name>TestEJB</abstract-schema-name>
| <cmp-field>
| <field-name>defaultField</field-name>
| </cmp-field>
| <primkey-field>defaultField</primkey-field>
| <query>
| <query-method>
| <method-name>findById</method-name>
| <method-params/>
| </query-method>
| <ejb-ql>SELECT Object(o) FROM TestEJB o</ejb-ql>
| </query>
| </entity>
| </enterprise-beans>
| </ejb-jar>
I don't have an example with me with multiple EARs, perhaps the J2EE tutorial
found at Sun might be something useful for you...
I myself also run/ran into ClassCastExceptions, but mostly they were caused by
JNDI reference errors in my descriptors.
Isn't it irritating to notice that the computer is always right ;-)
Cheers,
Kurt
Good luck in your search :-)
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3936514#3936514
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3936514
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user