-
Notifications
You must be signed in to change notification settings - Fork 1
DevFaqCallEjbFromNbm
This How-To is based on GlassFish EJB Faq
Important: Application Client must be created as it is described in Java EE Application Client on top of the NetBeans Platform Tutorial otherwise this will not work
-
create lookup method in some class in your module
-
add entry to
application-client.xml
in application client module
-
for following lookup method in some class from your module:
protected mypkg.MySessionBeanRemote lookupMySessionBean() { try { javax.naming.Context c = new javax.naming.InitialContext(); return (mypkg.MySessionBeanRemote) c.lookup("java:comp/env/ejb/MySessionBean"); } catch(javax.naming.NamingException ne) { java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE,"exception caught" ,ne); throw new RuntimeException(ne); } }
-
there must be following entry in
application-client.xml
:
<ejb-ref> <ejb-ref-name>ejb/MySessionBean</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <remote>mypkg.MySessionBeanRemote</remote> </ejb-ref>
-
ensure that $GLASSFISH_HOME/lib/appserv-rt.jar, $GLASSFISH_HOME/lib/appserv-ext.jar, $GLASSFISH_HOME/lib/appserv-deployment-client.jar, $GLASSFISH_HOME/lib/javaee.jar, $GLASSFISH_HOME/lib/jmxremote_optional.jar are on NB platform based application’s classpath (startup classpath is not enough)
-
ensure that the same applies to jar with EJB interfaces and its helper classes
-
when using jars from GlassFish v1 or v1u1 - disable assertions (due to bug in GlassFish which should be fixed in GlassFish v2)
-
add org.omg.CORBA.ORBInitialHost and org.omg.CORBA.ORBInitialPort JVM options to application’s startup JVM options
-
use lookup
-
add:
run.args.extra=-J-da -J-Dorg.omg.CORBA.ORBInitialHost=localhost -J-Dorg.omg.CORBA.ORBInitialPort=3700 \ -cp:a $GLASSFISH_HOME/lib/appserv-rt.jar:$GLASSFISH_HOME/lib/appserv-ext.jar:\ $GLASSFISH_HOME/lib/appserv-deployment-client.jar:$GLASSFISH_HOME/lib/javaee.jar:\ $GLASSFISH_HOME/lib/jmxremote_optional.jar:someejb.jar
to module suite project.properties
-
add javaee.jar and jar with ejb interfaces to compile time dependencies for your module
-
create lookup method for your bean in some class in your module:
// for EJB 3.0 bean protected mypkg.MyBeanRemote lookupMyBeanRemote30 throws NamingException { javax.naming.Context ic = new javax.naming.InitialContext(); return (mypkg.MyBeanRemote) ic.lookup("mypkg.MyBeanRemote"); } // for EJB 2.1 and/or earlier protected mypkg.MyBeanRemote lookupMyBeanRemote21 throws NamingException { javax.naming.Context ic = new javax.naming.InitialContext(); Object remote = c.lookup("java:comp/env/ejb/MyBean"); mypkg.MyBeanRemoteHome rv = (mypkg.MyBeanRemoteHome) PortableRemoteObject.narrow(remote, mypkg.MyBeanRemoteHome.class); return rv.create(); }
Applies to: NetBeans 5.5, 6.0, 6.1
Platforms: all
The content in this page was kindly donated by Oracle Corp. to the Apache Software Foundation.
This page was exported from http://wiki.netbeans.org/DevFaqCallEjbFromNbm , that was last modified by NetBeans user Admin on 2009-11-06T15:37:04Z.
NOTE: This document was automatically converted to the AsciiDoc format on 2018-01-26, and needs to be reviewed.
Apache NetBeans is an effort undergoing incubation at The Apache Software Foundation (ASF).
Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects.
While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.
This wiki is an experiment pending Apache NetBeans Community approval.