[b]Periodic[/b] error using PortableRemoteObject.narrow

I am trying to access a session bean on an oracle9ias(903) running on a windows 2000 server.
Well I am actually accessing several beans, but on some of the beans the code works and on some it don't even though the code is alike. There is no execptions thrown but the LabelTypeDAOHome is null and I get a NPE when calling create on it.
public static Context getInitialContext() throws NamingException, MissingResourceException
Hashtable env = new Hashtable();
String init = getResourceBundle().getString("INITIAL_CONTEXT_FACTORY");
env.put(Context.INITIAL_CONTEXT_FACTORY,init);
String principle = getResourceBundle().getString("SECURITY_PRINCIPAL");
env.put(Context.SECURITY_PRINCIPAL,principle);
String credential = getResourceBundle().getString("SECURITY_CREDENTIALS");
env.put(Context.SECURITY_CREDENTIALS,credential);
String url = getResourceBundle().getString("PROVIDER_URL");
env.put(Context.PROVIDER_URL,url);
env.put("dedicated.rmicontext","true"); // vigtig ifm web access!
return new InitialContext(env);
private LabelTypeDAO getLabeltypeDAO() throws NamingException, RemoteException {
LabelTypeDAO labeltypeDAO = null;
if (context == null) {
context = getInitialContext();
if (labeltypeDAOHome == null) {
LabelTypeDAOHome labeltypeDAOHome = (LabelTypeDAOHome)PortableRemoteObject.narrow(context.lookup("LabelTypeDAO"), LabelTypeDAOHome.class);
try {
labeltypeDAO = labeltypeDAOHome.create();
} catch(Exception ce) {
throw new RemoteException("Could not create LabelTypeDAO.", ce);
return labeltypeDAO;
The funny part is that it doesn't happen on all the sessionbeans.
Could it have something to do with what happens on deployment (e.g internal wrapping).
There is no exception thrown untill I call labeltypeDAO = labeltypeDAOHome.create();
This code is in a java class instantiated in a jsp page.

Found it. It was my own stupid mistake. I had 2 references to the same variable name, one to an instance variable and one to a local variable and I ofcourse referenced the wrong one.
Bad lars
Bad lars
Bad lars

Similar Messages

  • Why use PortableRemoteObject.narrow() ?

    hi!
    I am new to RMI-IIOP. Can somebody explain why we need to use the narrow method to type cast object refs in RMI-IIOP while in RMI, we just need to use a casting operator?
    TIA,
    Mani

    See http://info.borland.com/devsupport/appserver/faq/45/ejb/portable_remote_object.html
    --Mark Johnson

  • Rich Client For EJB asking for  'ioser12.dll' when using PortableRemoteObject.narrow()

    Hi,
    When using narrow down the object to home interface after performing lookup(), it gives error for
    'ioser12.dll' not found. If doing 'SomeHome someHome = (SomeHome)obj;' it's working fine.
    Regards,
    Jitendra Kumar

    Remove the j2ee.jar from your classpath and narrow will work.
    The correct version is in weblogicaux.jar.
    -- Rob
    Jitendra Kumar wrote:
    >
    Hi,
    When using narrow down the object to home interface after performing lookup(), it gives error for
    'ioser12.dll' not found. If doing 'SomeHome someHome = (SomeHome)obj;' it's working fine.
    Regards,
    Jitendra Kumar

  • Obtain remote interface using PortableRemoteObject

    Hello,
    I have sample code from "Applying Enterprinse JavaBeans" book.
    Plan plan = (Plan)PortableRemoteObject.narrow(
    it.next(), Plan.class);
    ... plan.getPlanInfo() ...
    here:
    Plan is a remote interface of the entity bean (e.g.. MyPlanBean).
    getPlanInfo() is one of the business methods in Plan.
    In this case, the remote interface is obtained by using PortableRemoteObject.narrow(...). could anyone explane the creation using the concept of life cycle of an entity bean instance? That means if any ejbCreate() methods or any callback methods are involved in the creation or not?
    Thanks.

    I am not sure if you are doing the right thing.
    The home interface represents the life-cycle methods of the component (create, destroy, find) while the remote interface represents the business method of the bean.
    Clients use the bean's home interface to obtain references to the bean's remote interface. Following is the life-cycle of
    entity bean creation:
    1. Client invokes create() on home object
    2. Home object allocates a bean from the free pool
    3. Home object passes on the create args to the ejbCreate(..)
    in the bean
    4. the bean inserts a row into the database table
    5. the bean returns the primary key of the row to the home object
    6. The container creates an EJB object for the bean and populates
    it with the primary key
    7. The home object calls the ejbPostCreate() on the bean
    8. The home object returns the remote reference to the EJB
    object back to the client
    9. Client now makes business calls to the bean instance.
    No bean instance is associated with the EJB object
    10. EJB object communicates to the container that a bean
    instance is needed
    11. The container allocates a bean instance from the pool
    and associates it with the EJB object (ejbActivate() is called)
    12. home object invokes the ejbLoad method on the bean to
    tell it to load itself(BMP) or to tell it that it has just been
    loaded (CMP)
    13. the bean uses the primary key stored in the EJB object to load the approp row's data from the database
    14. EJB object dispatches the client's business method call to the
    bean
    Hope this helps.
    Regards,
    Sun-DTS

  • Confusion in PortableRemoteObject.narrow() method

    In EJB 1.0 reference of home object is obtained through external casting as HelloHome home = (HelloHome)ctx.lookup("HelloHome")
    My question is that since IIOP has not been designed for Java, but for generic languages, and this means that there are some limitations. Some languages, in fact, do not have the concept of casting.
    Still why we have to cast the Object if we use PortableRemoteObject.narrow method for obtaining the home interface reference in EJB2.0.
    HelloHome home = (HelloHome)javax.rmi.PortableRemoteObject.narrow(object, HelloHome.class)

    If the client is built using Java, you can not explicitly cast from the Naming.lookup() function. Instead, you must use lookup() to return a generic java.lang.Object, and then cast to the specific object type with the PortableRemoteObject.Narrow(objectReference, interfaceName) method.

  • ???  PortableRemoteObject.narrow()  ???  totally confusing

    Hi,
    I tried to execute the J2ee tutorial example (ConverterApplication) bean...
    I got succeed in doing that...
    But while writing the ApplicationClient code i used
    PortableRemoteObject.narrow() to get the HomeObject's reference... I know that there is some RMI-IIOP and CORBA stuff involved in that..
    But my client is a pure java client not a CORBA client ...so i tried removing this
    PortableRemoteObject.narrow() line and i directly typecated the HomeObject...
    It is also working ....
    So whats the whole purpose of writing PortableRemoteObject.narrow() for a java client ?? Becoz we know that our client is in Java and EJB is also written in java

    http://www.jguru.com/faq/view.jsp?EID=734137
    http://www.theserverside.com/discussions/thread.tss?thread_id=29200
    Richard.

  • PortableRemoteObject.narrow() method

    Hi,
    I usually use this method in case of looking for some remote home interface. But recently I found some EJB examples, where an author ommited the PortableRemoteObject.narrow method. Actually the source code was generated by Lomboz.
    This unusual procedure made me to prepare some tests. I made some EJB bean and its interfaces, after that I made a little change inside on one cpy of home interface, that this one was out of date. In the end I generated appropriate client in two ways:
    - using PortableRemoteObject.narrow method
    - unusing PortableRemoteObject.narrow method
    The results, when I used PortableRemoteObject.narrow method and when I unused it is similar, both resposed by java.lang.ClassCastException
    The small difference was, in order to use PortableRemoteObject.narrow method I got:
    at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(Unknown Source)
         at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
    Ommiting this method I got only;
    java.lang.ClassCastException: $Proxy0
    Well, in both ways I observed the same final exception:
    java.lang.ClassCastException, which good explains what happend wrong. What really is better to use PortableRemoteObject.narrow method based on my above experiences?
    Thank for some suggestions
    Krzysztof

    You need to do the .narrow() method on anything that comes across RMI. The reason is that you have no guarantee that the thing coming across RMI is a Java object. It's possible to send something other than a Java object.
    If your client is using a local interface instead of a remote interface, the narrow() is not required.

  • PortableRemoteObject.narrow(...) error , why?

    when I execute
    PortableRemoteObject.narrow(objred, SBeanHome.class);
    the system throw an exception
    java.lang.ClassCastException: $Proxy78
    Please help me!
    (my application server is weblogic 6.1)

    Object obj = (MyHomeInterface) ctx.lookup("Invoice.MyHomeInterface");
         MyHomeInterface home = (MyHomeInterface) PortableRemoteObject.narrow(obj, MyHomeInterface.class);
    use this code instead.
    i hope that this will solve your problem change the code according to your classes.

  • A error from javax.rmi.PortableRemoteObject.narrow

    --run envrionment: jdk1.4.2_01 / oc4j9.0.4
    --source code
    import java.util.*;
    import java.io.IOException;
    import java.rmi.RemoteException;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.ejb.*;
    import javax.naming.*;
    import javax.rmi.PortableRemoteObject;
    import java.sql.*;
    public class ProductServlet extends HttpServlet
    server.ProductHome myProductHome;
    public void init() throws ServletException {
    try {
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
    "com.evermind.server.rmi.RMIInitialContextFactory");
    env.put(Context.PROVIDER_URL, "ormi://localhost/JDBCEJB");
    env.put(Context.SECURITY_PRINCIPAL, "store_user");
    env.put(Context.SECURITY_CREDENTIALS, "store_password");
    Context myInitialContext = new InitialContext(env);
    Object homeObject = myInitialContext.lookup("ProductBean");
    myProductHome = (server.ProductHome)PortableRemoteObject.narrow(homeObject,server.ProductHome.class);
    } catch(NamingException e) {
    throw new ServletException("Error looking up home", e);
    public void doGet(
    HttpServletRequest request, HttpServletResponse response
    ) throws ServletException, IOException {
    response.setContentType("text/html;charset=BIG5");
    ServletOutputStream out = response.getOutputStream();
    out.println("<html>");
    out.println("<head><title>Product</title></head>");
    out.println("<body>");
    out.println("<table width=100% border=1>");
    out.println("<tr>");
    out.println("<th>Id</th>");
    out.println("<th>Name</th>");
    out.println("<th>Address</th>");
    out.println("<th>Bdate</th>");
    out.println("</tr>");
    try {
    server.ProductRemote myProductRemote = myProductHome.create();
    server.Product myProduct = myProductRemote.query(request.getParameter("guess"));
    if (myProduct != null) {
    out.println("<tr>");
    out.println("<td>" + myProduct.id + "</td>");
    out.println("<td>" + myProduct.name + "</td>");
    out.println("<td>" + myProduct.ads + "</td>");
    out.println("<td>" + myProduct.bdate + "</td>");
    out.println("</tr>");
    out.println("</table>");
    out.println("</body></html>");
    } catch(RemoteException e) {
    out.println("Error communicating with EJB-server: " +
    e.getMessage());
    } catch(CreateException e) {
    out.println("Error creating EJB: " + e.getMessage());
    } catch(SQLException e) {
    out.println("SQL Exception: " + e.getMessage());
    --My application client can run correctly, but my servlet code can't run.
    --If I start oc4j by follow statement:
    java -jar oc4j.jar
    --the error display:
    java.lang.ClassCastException
         at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:293)
         at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
         at ProductServlet.init(ProductServlet.java:39)
         at javax.servlet.GenericServlet.init(GenericServlet.java:258)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.HttpApplication.loadServlet(HttpApplication.java:2091)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.HttpApplication.findServlet(HttpApplication.java:4507)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.HttpApplication.getRequestDispatcher(HttpApplication.java:2410)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:629)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.HttpRequestHandler.run(HttpRequestHandler.java:264)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.HttpRequestHandler.run(HttpRequestHandler.java:107)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
         at java.lang.Thread.run(Thread.java:534)
    --If I start oc4j by follow statement:
    java -jar -Djavax.rmi.CORBA.PortableRemoteObjectClass=com.sun.corba.se.internal.javax.rmi.PortableRemoteObject -Djavax.rmi.CORBA.UtilClass=com.sum.corba.se.internal.POA.ShutdownUtilDelegate oc4j.jar
    --the error is:
    java.lang.ExceptionInInitializerError
         at javax.rmi.PortableRemoteObject.createDelegateIfSpecified(PortableRemoteObject.java:179)
         at javax.rmi.PortableRemoteObject.<clinit>(PortableRemoteObject.java:58)
         at ProductServlet.init(ProductServlet.java:39)
         at javax.servlet.GenericServlet.init(GenericServlet.java:258)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.HttpApplication.loadServlet(HttpApplication.java:2091)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.HttpApplication.findServlet(HttpApplication.java:4507)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.HttpApplication.getRequestDispatcher(HttpApplication.java:2410)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:629)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.HttpRequestHandler.run(HttpRequestHandler.java:264)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.HttpRequestHandler.run(HttpRequestHandler.java:107)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
         at java.lang.Thread.run(Thread.java:534)
    Caused by: org.omg.CORBA.INITIALIZE: cannot instantiate com.sum.corba.se.internal.POA.ShutdownUtilDelegate vmcid: 0x0 minor code: 0 completed: No
         at javax.rmi.CORBA.Util.createDelegateIfSpecified(Util.java:341)
         at javax.rmi.CORBA.Util.<clinit>(Util.java:51)
         ... 12 more

    --run envrionment: jdk1.4.2_01 / oc4j9.0.4
    --source code
    import java.util.*;
    import java.io.IOException;
    import java.rmi.RemoteException;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.ejb.*;
    import javax.naming.*;
    import javax.rmi.PortableRemoteObject;
    import java.sql.*;
    public class ProductServlet extends HttpServlet
    server.ProductHome myProductHome;
    public void init() throws ServletException {
    try {
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
    "com.evermind.server.rmi.RMIInitialContextFactory");
    env.put(Context.PROVIDER_URL, "ormi://localhost/JDBCEJB");
    env.put(Context.SECURITY_PRINCIPAL, "store_user");
    env.put(Context.SECURITY_CREDENTIALS, "store_password");
    Context myInitialContext = new InitialContext(env);
    Object homeObject = myInitialContext.lookup("ProductBean");
    myProductHome = (server.ProductHome)PortableRemoteObject.narrow(homeObject,server.ProductHome.class);
    } catch(NamingException e) {
    throw new ServletException("Error looking up home", e);
    public void doGet(
    HttpServletRequest request, HttpServletResponse response
    ) throws ServletException, IOException {
    response.setContentType("text/html;charset=BIG5");
    ServletOutputStream out = response.getOutputStream();
    out.println("<html>");
    out.println("<head><title>Product</title></head>");
    out.println("<body>");
    out.println("<table width=100% border=1>");
    out.println("<tr>");
    out.println("<th>Id</th>");
    out.println("<th>Name</th>");
    out.println("<th>Address</th>");
    out.println("<th>Bdate</th>");
    out.println("</tr>");
    try {
    server.ProductRemote myProductRemote = myProductHome.create();
    server.Product myProduct = myProductRemote.query(request.getParameter("guess"));
    if (myProduct != null) {
    out.println("<tr>");
    out.println("<td>" + myProduct.id + "</td>");
    out.println("<td>" + myProduct.name + "</td>");
    out.println("<td>" + myProduct.ads + "</td>");
    out.println("<td>" + myProduct.bdate + "</td>");
    out.println("</tr>");
    out.println("</table>");
    out.println("</body></html>");
    } catch(RemoteException e) {
    out.println("Error communicating with EJB-server: " +
    e.getMessage());
    } catch(CreateException e) {
    out.println("Error creating EJB: " + e.getMessage());
    } catch(SQLException e) {
    out.println("SQL Exception: " + e.getMessage());
    --My application client can run correctly, but my servlet code can't run.
    --If I start oc4j by follow statement:
    java -jar oc4j.jar
    --the error display:
    java.lang.ClassCastException
         at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:293)
         at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
         at ProductServlet.init(ProductServlet.java:39)
         at javax.servlet.GenericServlet.init(GenericServlet.java:258)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.HttpApplication.loadServlet(HttpApplication.java:2091)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.HttpApplication.findServlet(HttpApplication.java:4507)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.HttpApplication.getRequestDispatcher(HttpApplication.java:2410)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:629)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.HttpRequestHandler.run(HttpRequestHandler.java:264)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.HttpRequestHandler.run(HttpRequestHandler.java:107)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
         at java.lang.Thread.run(Thread.java:534)
    --If I start oc4j by follow statement:
    java -jar -Djavax.rmi.CORBA.PortableRemoteObjectClass=com.sun.corba.se.internal.javax.rmi.PortableRemoteObject -Djavax.rmi.CORBA.UtilClass=com.sum.corba.se.internal.POA.ShutdownUtilDelegate oc4j.jar
    --the error is:
    java.lang.ExceptionInInitializerError
         at javax.rmi.PortableRemoteObject.createDelegateIfSpecified(PortableRemoteObject.java:179)
         at javax.rmi.PortableRemoteObject.<clinit>(PortableRemoteObject.java:58)
         at ProductServlet.init(ProductServlet.java:39)
         at javax.servlet.GenericServlet.init(GenericServlet.java:258)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.HttpApplication.loadServlet(HttpApplication.java:2091)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.HttpApplication.findServlet(HttpApplication.java:4507)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.HttpApplication.getRequestDispatcher(HttpApplication.java:2410)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:629)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.HttpRequestHandler.run(HttpRequestHandler.java:264)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].server.http.HttpRequestHandler.run(HttpRequestHandler.java:107)
         at com.evermind[Oracle9iAS (9.0.4.0.0) Containers for J2EE].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
         at java.lang.Thread.run(Thread.java:534)
    Caused by: org.omg.CORBA.INITIALIZE: cannot instantiate com.sum.corba.se.internal.POA.ShutdownUtilDelegate vmcid: 0x0 minor code: 0 completed: No
         at javax.rmi.CORBA.Util.createDelegateIfSpecified(Util.java:341)
         at javax.rmi.CORBA.Util.<clinit>(Util.java:51)
         ... 12 more

  • ClassCastException with PortableRemoteObject.narrow call

    I want to call an ejb component located on a different machine and I can not get it to work. So I tried to deploy it under my version of jboss and try to invoke it. I was able to call it but when I added Context.PROVIDER_URL to my properties I get a classCastException.
    String host = "jnp://localhost:1099";
    props.setProperty(Context.PROVIDER_URL, host);
    I started getting the following exception
    2006-11-03 10:17:18,319 ERROR [STDERR] java.lang.ClassCastException
    2006-11-03 10:17:18,319 ERROR [STDERR]      at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narr
    ow(PortableRemoteObject.java:229)
    2006-11-03 10:17:18,319 ERROR [STDERR]      at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObjec
    t.java:137)
    As soon as I uncomment that props.setProperty(Context.PROVIDER_URL, host);
    line everything works fine.
    I have seen this type of exception before when I tried invoking the ejb on a different computer as well. When I inspect the object with reflection I see that it found the right interface.
    This is my code again:
    Properties props = new Properties();
    props.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.jboss.security.jndi.JndiLoginInitialContextFactory");
    props.setProperty(Context.SECURITY_PRINCIPAL, "admin");
    props.setProperty(Context.SECURITY_CREDENTIALS, "admin");
    props.put(javax.naming.Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
    String host = "jnp://localhost:1099";
    props.setProperty(Context.PROVIDER_URL, host);
    ctx = new InitialContext( props );
    Object object = ctx.lookup( "ejb/com/blah/Manager" );
    ManagerRemoteHome home = (ManagerRemoteHome)PortableRemoteObject.narrow ( object, ManagerRemoteHome.class);
    ManagerRemote manager = home.create();
    Thanks

    1099 is the RMI/JRMP Registry. You are using RMI/IIOP. Is this port number really correct?

  • Classcastexception on portableremoteobject narrow

    I was successfully connecting to an EJB on my WebLogic server from a Java
    IDL client using the iiop protocol, cosnaming initialcontextfactory. I'm at
    a loss as to what is different now that is causing this to fail. I'm sure
    it has something to do with how I'm generating the stubs and/or the
    client/server classpath, but can't see what I'm doing wrong now. My steps
    are as follows.
    1) Create the EJB jar (call it jar1) using weblogic.ejbc
    2) Run jar1 through weblogic.ejbc using -idl -iiop, creating jar2
    3) Deploy jar2 in the java client's classpath
    I get the initial context fine, but when I get to this line:
    _home = (myHome)(PortableRemoteObject.narrow(ctx, myHome.class));
    I get the following error:
    java.lang.ClassCastException
    at
    com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemo
    teObject.java:296)
    Can anyone give me some assistance?
    Thx!
    Sandy Barletta

    Ok, here's what's going on here. The problem happens when I use
    com.sun.jndi.cosnaming.CNCtxFactory as my initial context factory. After the
    lookup of the home interface, what I get back in my context object if I call
    getClass().getName() is the following:
    com.sun.jndi.cosnaming.CNCtx
    The class cast exception occurs when I try to narrow this to my home
    interface.
    If I use weblogic.jndi.WLInitialContextFactory instead of
    com.sun.jndi.cosnaming.CNCtxFactory, what I get back in my context object if
    I call getClass().getName() is
    com.sun.corba.se.internal.iiop.CDRInputStream$1 and the narrow succeeds.
    What gives? Do I have to use the weblogic context factory? I was hoping to
    avoid the need for weblogic packages on the client. Also, our whole reason
    for using IIOP was to avoid compatibility problems between weblogic servers
    running at different version levels. If I have to use the weblogic context
    factory, and we have a weblogic client running at a different version from
    the server, will there be problem?
    Sandy Barletta
    "Sandy Barletta" <[email protected]> wrote in message
    news:[email protected]...
    I was successfully connecting to an EJB on my WebLogic server from a Java
    IDL client using the iiop protocol, cosnaming initialcontextfactory. I'mat
    a loss as to what is different now that is causing this to fail. I'm sure
    it has something to do with how I'm generating the stubs and/or the
    client/server classpath, but can't see what I'm doing wrong now. My steps
    are as follows.
    1) Create the EJB jar (call it jar1) using weblogic.ejbc
    2) Run jar1 through weblogic.ejbc using -idl -iiop, creating jar2
    3) Deploy jar2 in the java client's classpath
    I get the initial context fine, but when I get to this line:
    _home = (myHome)(PortableRemoteObject.narrow(ctx, myHome.class));
    I get the following error:
    java.lang.ClassCastException
    at
    com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemo
    teObject.java:296)
    Can anyone give me some assistance?
    Thx!
    Sandy Barletta

  • PortableRemoteObject.narrow throws ClassCastException

    Hi Friends,
    I am trying to access home interface of a stateless session EJB from an Applet running in JRE 1.3.1 in IE. My EJB is running in WebLogic Server 6.1. I am getting a cast error while narrowing the remote home interface. My server and client are running on the same machine though they are in different JVMs. I was able to access this remote home interface in a simple test program running from command line.
    This session bean accesses other entity beans deployed in the same WebLogic server, if that has anything to do with it.
    Following is the error callstack:
    java.lang.ClassCastException
         at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:296)
         at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
    Any help in resolving this issue will be greatly appreciated.
    Thanks,
    Krishna.

    Hello
    I have same problem in Java Web Start.
    This Situation is same.
    I report the result of my investigation.
    I'm having a problem in lookup remote object when using JWS.
    My application runs normally in Java Application without JWS.
    I'm using BEA WebLogic Server 6.1.
    My application acts in EJB client application.
    But my application runs normally in WebLogic Server 6.0 and JWS.
    When I cast remote object to my interface, I encountered this kind of error.
    java.lang.ClassCastException
    at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow
    at javax.rmi.PortableRemoteObject.narrow
    While using WebLogic Server 6.0, I include stub classes in my jar file.
    But in WebLogic Server 6.1, ejbc does not generate stub classes.
    WebLogic uses Dynamic proxy technology in JDK 1.3 for this purpose.
    So, EJB client conflict with sand box security policy...
    When I add the following line to javaws.policy file,
    my application runs without problem.
    permission java.io.SerializablePermission "enableSubstitution";
    Is everyone suffering from this kind of problem?
    Is this problem improved in the future?
    I need more information about this problem.
    I am not sure, this is specification.
    Thanks in advance
    Hiroki

  • PortableRemoteObject.narrow Problem

    Hello, I have a jsp that is talking to a servlet that is suppose to connect to a stateless session bean in 9.0.3. The bean deploys fine. I continue to get the following error when the servlet tries to talk to the bean. The servlet works fine on JRun 4 talking to the same bean. Here is my code.
    Hashtable env = new Hashtable();
    env.put(Context.PROVIDER_URL, "ormi://141.254.22.145:23791/JRun2");
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
    env.put(Context.SECURITY_PRINCIPAL, "admin");
    env.put(Context.SECURITY_CREDENTIALS, "admin");
    env.put(Context.URL_PKG_PREFIXES, "com.evermind.naming");
    Context context = new InitialContext(env);
    System.out.println("context: " + context.getEnvironment().toString());
    Object o = (Object) context.lookup("SessionManagerLiteStateless");
    System.out.println("o: " + o.toString());
    sessionManagerLiteStatelessHome = (SessionManagerLiteStatelessHome)PortableRemoteObject.narrow(o, SessionManagerLiteStatelessHome.class);
    The context outputs the Home interface fine but it bombs on sessionManagerLiteStatelessHome = (SessionManagerLiteStatelessHome)PortableRemoteObject.narrow(o, SessionManagerLiteStatelessHome.class);
    Here is the error.
    java.lang.ClassCastException
    at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(Unkno
    wn Source)
    at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
    at JRun2.OracleServlet.init(OracleServlet.java:30)
    at com.evermind.server.http.HttpApplication.loadServlet(HttpApplication.
    java:1956)
    at com.evermind.server.http.HttpApplication.findServlet(HttpApplication.
    java:4355)
    at com.evermind.server.http.HttpApplication.getRequestDispatcher(HttpApp
    lication.java:2184)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpReques
    tHandler.java:617)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.ja
    va:259)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.ja
    va:106)
    at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExec
    utor.java:803)
    at java.lang.Thread.run(Unknown Source)

    Michael -
    That looks like a correct set of calls to me.
    Can I ask what environment are you running in? An OC4J standalone or a 9iAS environment?
    ** If this is a 9iAS environment, then the port number for the ORMI lookup will be different than 23791. The actual ORMI port number for a 9iAS instance is dynamically allocated when the OC4J processes are started. The defdault port ranges for ORMI are 3000-3100 by default. The process manager starts at the lower bound and works it's way sequentially along until a free port is found. So usually for the OC4J_Home instance, the ORMI port is 3000.
    I've never used the URL_PKG_PREFIXES myself, what happens if you remove that entry for the Hashtable?
    -steve-

  • PortableRemoteObject.narrow causes NoClassDefFoundError

    I exhaustively searched for this error in this, and other forums, and
    tried some suggested techniques, but none worked.
    /* Following causes NoClassDefFoundError */
    Entity1RemoteHome printHome = (Entity1RemoteHome)
         PortableRemoteObject.narrow( prrefHome, Entity1RemoteHome.class );
    RemoteClient1.java contains:
         package com.zbeans;
         import com.zbeans.Entity1Remote;
         import com.zbeans.Entity1RemoteHome;
         import javax.naming.InitialContext;
         Context prinitctx = new InitialContext();
         Context prenvctx = (Context) prinitctx.lookup("java:comp/env");
         /* 'ejb/Entity1 EJB ref1' is the Reference Name appearing under the JNDI
              Names tab under the application object, for the deployment tool. */
         Object prrefHome = prenvctx.lookup("ejb/Entity1 EJB ref1");
         /* Following causes NoClassDefFoundError */
         Entity1RemoteHome printHome = (Entity1RemoteHome)
              PortableRemoteObject.narrow( prrefHome, Entity1RemoteHome.class );
         Binding name:`java:comp/env/ejb/Entity1 EJB ref1`
         RemoteClient1.main(): NoClassDefFoundError has occurred!!
         getMessage(): com.zbeans.Entity1RemoteHome
         toString(): java.lang.NoClassDefFoundError: com.zbeans.Entity1RemoteHome
         I ran using C:\j2sdkee1.3.1\bin>runclient -client D:\zJava\zsamples\EJB\application1\application1.ear -name RemoteClient1 -textauth
         I ensured j2ee and cloudscape were running, and
         set APPCPATH=application1Client.jar     (application1Client.jar was generated by the deployment tool)
    Entity1RemoteHome.java contains:
         package com.zbeans;
         import java.rmi.RemoteException;
         import javax.ejb.*;
         public interface Entity1RemoteHome extends javax.ejb.EJBHome {
         public Entity1Remote create (Integer id)
              throws CreateException, RemoteException, EJBException;
    Remote1Client1, Entity1RemoteHome.java, etc. resides under
    C:\JRun4\servers\default\default-ear\default-war\WEB-INF\classes\com\zbeans
    I was thinking of moving RemoteClient1.java one level higher in the
    directory tree. But maybe this is not necessary since the sample
    Converter app. has the client in the same folder as the EJB interfaces?
    - should I move the .java, and .class files from c:\jrun4\...\classes\com\zbeans
         to D:\zJava\zsamples\EJB\application1\com\zbeans since this is where the
         .ear, .jar are generated?
    My environment settings are:
         java version "1.4.0_01"
         Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
         Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)
         WinNT 4.0 SP5
         CLASSESDIR=c:\j2sdkee1.3.1\lib\classes
         CLASSPATH=.;c:\j2sdkee1.3.1\lib\j2ee.jar;D:\jakarta-tomcat-3.3.1\lib\common\serv
         let.jar;C:\JRun4\servers\default\default-ear\default-war\WEB-INF\classes;D:\zJav
         a\zsamples\EJB\application1
         J2EEJARS=c:\j2sdkee1.3.1\lib\j2ee.jar
         J2EETOOL_CLASSES=c:\j2sdkee1.3.1\lib\toolclasses
         J2EETOOL_JAR=c:\j2sdkee1.3.1\lib\j2eetools.jar
         J2EE_HOME=c:\j2sdkee1.3.1
         JAVA_HOME=C:\j2sdk1.4.0_01
         etc.

    Refer to
    http://access1.sun.com/FAQSets/ejbfaq.html#17

  • Sun One EJB problem - PortableRemoteObject.narrow ClassCastException...

    Hi all,
    I'm using Sun One app server 7 for the first time and am having a bit of difficulty. I have deployed a very simple EAR containing one stateless session bean just to test it. The ear appears to have deployed correctly but PortableRemoteObject.narrow is throwing a ClassCastException when trying to do a remote lookup on the bean.
    I'm using the following env settings...
    initialContextFactory = com.sun.enterprise.naming.SerialInitContextFactory
    providerUrl = iiop://127.0.0.1:3700The lookup appears to work okay - this line of code executes successfully
    Object objref = initialContext.lookup(jndiHomeName);...objref appears to initalise succesfully (if I toString() it I get an iiop stream of some sort). However, it is the next line that is failing...
    Object obj = PortableRemoteObject.narrow(objref, homeClass);...this is the exception I get...
    java.lang.ClassCastException
         at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(Unknown Source)
         at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
         at com.scorlog.ServiceLocator.getRemoteHome(ServiceLocator.java:145)Furthermore, when PortableRemoteObject.narrow() executes, I get the following console exception on the server...
    com.sun.corba.ee.internal.core.DuplicateServiceContext
            at com.sun.corba.ee.internal.core.ServiceContexts.put(ServiceContexts.java:208)
            at com.sun.corba.ee.internal.iiop.ServerRequestImpl.getServiceContextsForReply(ServerRequestImpl.java:258)
            at com.sun.corba.ee.internal.iiop.ServerRequestImpl.createResponse(ServerRequestImpl.java:89)
            at com.sun.corba.ee.internal.POA.SubcontractResponseHandler.createReply(SubcontractResponseHandler.java:50)
            at org.omg.CosNaming.NamingContextExtPOA._invoke(NamingContextExtPOA.java:377)
            at com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatchToServant(GenericPOAServerSC.java:569)
            at com.sun.corba.ee.internal.POA.GenericPOAServerSC.internalDispatch(GenericPOAServerSC.java:211)
            at com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatch(GenericPOAServerSC.java:113)
            at com.sun.corba.ee.internal.iiop.ORB.process(ORB.java:275)
            at com.sun.corba.ee.internal.iiop.RequestProcessor.process(RequestProcessor.java:83)
            at com.iplanet.ias.corba.ee.internal.iiop.ServicableWrapper.service(ServicableWrapper.java:25)
            at com.iplanet.ias.util.threadpool.FastThreadPool$ThreadPoolThread.run(FastThreadPool.java:288)
            at java.lang.Thread.run(Thread.java:534)
    FINE: No SAS context element found in service context listI have seen the forum that other users have had similar problems and the suggestion was that the client can't see the ejb stubs. I don't think this is the problem in my case as I deployed the same ear on weblogic 7 (obviously substituting sun-ejb-jar.xml for a weblogic-ejb-jar.xml) and successfully executed the same client code for the remote lookup.
    My feeling is that the problem revolves around the JNDI binding. Could it be the case that even though the object is binding properly, the app server doesn't realise it is an ejb and not a jdbc/jms/mail object? The documentation gives details on looking up a JDBC, javamail, URL, JMS resource (http://docs.sun.com/source/817-2177/djjndi.html) but not ejb so I could be doing something simple wrong here...
    My sun-ejb-jar.xml is as follows....
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- Generated by XDoclet -->
    <sun-ejb-jar>
        <enterprise-beans>
            <ejb>
                <ejb-name>SBTest</ejb-name>
                <jndi-name>ejb/SBTestBean</jndi-name>
            </ejb>
        </enterprise-beans>
    </sun-ejb-jar>However, I noticed on another thread, a user had some additional elements under their <ejb> tag like this...
    <?xml version="1.0" encoding="UTF-8"?>
    <sun-ejb-jar>
      <enterprise-beans>
        <name>Ejb1</name>
        <ejb>
          <ejb-name>HelloBean</ejb-name>
          <jndi-name>HelloBean</jndi-name>
          <ejb-ref>
            <ejb-ref-name>ejb/helloBean</ejb-ref-name>
            <jndi-name>HelloBean</jndi-name>
          </ejb-ref>
        </ejb>
      </enterprise-beans>
    </sun-ejb-jar>However, when I tried to add and <ejb-ref> element to my xml doc the ear failed to deploy. This is the error I get in the admin console...
    Error
    Deployment Error -- Error while running ejbc -- Fatal Error from EJB Compiler -- --
    Failed to load deployment descriptor for: testApp cause: Error converting J2EE-
    specific ejb xml to object representation: testApp.jar app_testApp Generated by
    XDoclet This bean has no ejb reference by the name of [ejb/SBtest]
    ejb/SBTestSBTestThis problem is eating up my time and being made all the more frustrating by the fact that a) it deploys on weblogic and b) the documentation is terrible. Even the sample application that comes with sun one only provides the .class files for the code that does the ejb look up and not the .java so you can't see how they hell they do it!
    Unfortunately I am tied to using Sun One so I really need to solve this problem fast. If anyone can provide any help I'd greatly appreciate it.
    Cheers,
    John :)

    I am having the same problem after upgrading to Sun One from iplanet. Any clue?

Maybe you are looking for

  • My macbook pro's hard drive space is constantly shrinking...is it a virus?

    My hard drive space went from 20 GB remaining to 15.6 GB remaining in less than a day and it's constantly declining without adding any new files or programs. I don't know what's causing it! Please Help!

  • How to create folder on server.

    Hello, I want to make folder on remote server using sun.net.ftp. So how i can do that? I have api to create folder using issueCommand(newdir). But when i do this it gives null pointer error. In issueCommand() only pass directory name or path of remot

  • IPad as controller in Fifa 14 and Real Racing 3?

    I'm wondering if I can use the iPad as controller in Fifa 14 when Airplay is enable? I can do that with Ducati Challenge HD, but I couldn't do that with Fifa 14 and Real Racing 3. Use iPad as controller is the reason that i bought the Apple TV... I s

  • In CLIENT_RESULT_CACHE_STATS$  "Find count always shows 0"

    In CLIENT_RESULT_CACHE_STATS$ "Find count always shows 0" even client cache is enabled. I am not able to enable client side result cache . I use ODAC which uses ODP.net driver internaly i have attached code file. I have done following settings in dat

  • Bb Curve will not lock & backlight wont turn off

    Last night my backlight went off and my keyboard locked...today...nothin. PLEASE help!