dev@glassfish.java.net

Re: PortableRemoteObject.narrow() problem with MEJB

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Fri, 10 Apr 2009 17:04:35 -0700

LLoyd,

Are you using 2.x or 3.x EJBs? If it's the former, try looking up EJBHome, and
calling create() on it.

thanks,
-marina

Lloyd Chambers wrote:
> This is the V3 trunk, active development. I've been tasked with
> implementing MEJB, the JSR 77 Management EJB.
>
> I'm a newbie at EJB, any ideas are appreciated— I'm having a problem
> where PortableRemoteObject.narrow() returns null.
>
> The app is deployed fine:
>
> INFO: Deployment expansion took 10
> INFO: DOL Loading time64
> Apr 10, 2009 4:51:34 PM
> com.sun.enterprise.security.provider.PolicyConfigurationImpl
> generatePermissions
> WARNING: No Principals mapped to Role [admin-role].
> Apr 10, 2009 4:51:34 PM com.sun.ejb.containers.BaseContainer initializeHome
> INFO: Portable JNDI names for EJB MEJBBean : [java:global/MEJB/MEJBBean,
> java:global/MEJB/MEJBBean!org.glassfish.admin.mejb.MEJBHome]
> Apr 10, 2009 4:51:34 PM com.sun.ejb.containers.BaseContainer initializeHome
> INFO: Glassfish-specific (Non-portable) JNDI names for EJB MEJBBean :
> [org.glassfish.admin.mejb.MEJBHome]
> Apr 10, 2009 4:51:34 PM
> INFO: ==> Uses Timers? == false
> Apr 10, 2009 4:51:34 PM org.glassfish.deployment.admin.DeployCommand execute
> INFO: Deployment of MEJB done is 156 ms
>
> My test code is below. When I run it, an IOR exists, so I presume this
> means that the ejb can be seen and referenced.
>
> But I get null from PortableRemoteObject.narrow().
>
>
> Got ref:
> IOR:0000000000000037524d493a6f72672e676c617373666973682e61646d696e2e6d656a622e4d454a42486f6d653a303030303030303030303030303030300000000000010000000000000126000102000000000c3139322e3136382e312e35000e74000000000092afabcb00000000260000006400000009533141532d4f5242000000000000000300000008526f6f74504f41000000003023494e5445524e414c235265666572656e6365466163746f72794d616e616765724261736523494e5445524e414c2300000000192d3734333838353734345f52486f6d652d454a42486f6d65000000000000000dffffffffd3a9345000000001ff14000000000004000000010000002000000000000100010000000205010001000100200001010900000001000101000000002600000002000200000000000300000016000000000000000c3139322e3136382e312e35000eec00000000000300000016000000000000000c3139322e3136382e312e35000f50
> for java:global/MEJB/MEJBBean
> Got ManagementHome: null for java:global/MEJB/MEJBBean
> Caught an unexpected exception!
> java.lang.NullPointerException
> at org.glassfish.admin.mejb.test.MEJBTest.main(MEJBTest.java:48)
>
>
>
>
> public static void main(String[] args) {
> try {
> final Properties env = new Properties();
> env.put("java.naming.factory.initial",
> "com.sun.jndi.cosnaming.CNCtxFactory");
> env.put("java.naming.provider.url", "iiop://localhost:3700");
>
> final Context initial = new InitialContext(env);
>
> //final String mejbName = MEJBUtility.MEJB_DEFAULT_NAME;
> final String mejbName = "java:global/MEJB/MEJBBean";
> final Object objref = initial.lookup(mejbName);
> println("Got ref: " + objref + " for " + mejbName);
>
> final ManagementHome home =
> (ManagementHome)PortableRemoteObject.narrow(objref, ManagementHome.class);
> println("Got ManagementHome: " + home + " for " + mejbName);
>
> final Management mejb = home.create();
> println("Got the MEJB");
>
> test(mejb);
>
> mejb.remove();
>
>
> } catch (Exception ex) {
> System.err.println("Caught an unexpected exception!");
> ex.printStackTrace();
> }
> }
> }
>
>
> Lloyd Chambers
> lloyd.chambers_at_sun.com <mailto:lloyd.chambers_at_sun.com>
> GlassFish Team
>
>
>