Problem Calling Remote Session Bean Method

Need help. I am trying to call a method in a remote stateless session bean in an EJB in my web application from a stateless session bean in a different EJB in the web application. I am getting a run-time error that says,
"java.lang.NoClassDefFoundError: dtpitb.common.sb.reports.CommonReportsHome"
ref = ctx.lookup( jndiName );
// Cast to Local Home Interface using RMI-IIOP
commonReportsHome = (CommonReportsHome)
PortableRemoteObject.narrow(ref, CommonReportsHome.class);
If while in a session bean of an EJB, I want to call a public method in the session bean of a totally different EJB, is there something in particular I am missing. I can make the call from the web application code. I can make a remote call from this session bean to itself in the exact same fashion. I just can't call a session bean in another EJB. All thoughts are welcome.
Thanks,
Pete

Thanks for replying. That could very well be the case I suppose. I'm using JBuilder and WebLogic, and JBuilder pretty much does all of the deployment descriptor code for me. However, maybe this is something I need to incorporate manually.
One EJB is in the same project as the web application code. The other EJB (common_ejb) is in another project. The calling session bean is in the project with the web app, and the remote session bean method that I'm targeting is in the common EJB session bean. Both EJBs are included in the web app's WEB-INF\lib dir and in the war file.
So theoretically, this isn't an unconventional practice I assume?
Thanks,
Pete

Similar Messages

  • NoSuchMethodException calling a session bean method from a web service

    I am running on NetWeaver 6.40 SP10 on Windows.
    I have a Java class (not a SessionBean) exposed as a web service where I invoke a session bean method with an argument that is another Java class (basically, just a JavaBean with some getters and setters).  I am getting a strange reflection-related error when I invoke a session bean method.  The exception I see is a 'java.lang.reflect.UndeclaredThrowableException', and if I unwrap it with 'ex.getCause()', I see 'java.lang.NoSuchMethodException: com.xx.ejb.PersistentObjectSBObjectImpl0.createR3Config(com.xx.common.R3Config)'
    I have spent several days trying to come up with a testcase for this, but to no avail.  The calling class is:
    --- snip R3UpdateTest.java ---
    package com.xx.server.webse;
    import com.xx.ejb.*;
    import com.xx.common.*;
    import java.util.*;
    import javax.ejb.*;
    import java.rmi.*;
    import javax.naming.*;
    * @author william_woodward
    * To change the template for this generated type comment go to
    * Window>Preferences>Java>Code Generation>Code and Comments
    public class R3UpdateTest {
         public String createR3Config(String a, String b, String c,
                   String d, String e, String f) {
              String retval = "success!";
              try {
                   PersistentObjectSB poSB = getPersistentObjectSB();
                   R3Config r3cfg = new R3Config();
                   r3cfg.setR3HostName(a);
                   r3cfg.setR3SystemNumber(b);
                   r3cfg.setRfcUserName(c);
                   r3cfg.setRfcPassword(d);
                   r3cfg.setRfcClient(e);
                   r3cfg.setRfcLanguage(f);
                   poSB.createR3Config(r3cfg);
              } catch (Exception ex) {
                   retval = "Exception: " + ex + ", Causing Exception : " + ex.getCause();
              return retval;
          * Private methods
         private PersistentObjectSB getPersistentObjectSB() throws RemoteException, CreateException, NamingException {
              Properties props = new Properties();
              props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");
              props.put(Context.PROVIDER_URL, "localhost:50004");
              InitialContext ctx;
              ctx = new InitialContext(props);
              PersistentObjectSBHome poSBHome =
                   (PersistentObjectSBHome) javax.rmi.PortableRemoteObject.narrow(
                        ctx.lookup("xx.com/CMPOBEAR/PersistentObjectSBBean"),
                        PersistentObjectSBHome.class);
              return poSBHome.create();
    --- end R3UpdateTest.java ---
    If I change the createR3Config() method to take an argument of class 'Object' instead of an argument of class 'R3Config', and then cast the object back into an R3Config in the method body, it all works fine.
    Any clues, anyone?
    Thanks,
    - Bill
    Message was edited by: Bill Woodward - Fixed some funky formatting

    Sure, I can show them to you.  They are very similar to a couple of non-DC classes/projects I put together to try and duplicate the problem.
    First, the interface, PersistentObjectSB.java:
    package com.xx.ejb;
    import javax.ejb.EJBObject;
    import com.xx.common.R3Config;
    import java.rmi.RemoteException;
    public interface PersistentObjectSB extends EJBObject {
          * Business Method.
         public void updateR3Config(R3Config r3Config) throws RemoteException;
          * Business Method.
         public void createR3Config(R3Config r3Config) throws RemoteException;
    And the implementation, PersistentObjectSBBean.java:
    package com.xx.ejb;
    import java.util.*;
    import javax.ejb.*;
    import javax.naming.*;
    import com.xx.common.*;
    import com.xx.interfaces.*;
    * @ejbHome <{com.xx.ejb.PersistentObjectSBHome}>
    * @ejbLocal <{com.xx.ejb.PersistentObjectSBLocal}>
    * @ejbLocalHome <{com.xx.ejb.PersistentObjectSBLocalHome}>
    * @ejbRemote <{com.xx.ejb.PersistentObjectSB}>
    * @stateless
    public class PersistentObjectSBBean implements SessionBean {
         private R3ConfigEJBLocalHome _r3ConfigEJBLocalHomeIf = null;
         public void ejbRemove() {
         public void ejbActivate() {
              try {
                   setEJBLocalHome();
              } catch (NamingException e) {
                   throw new EJBException(e);
         public void ejbPassivate() {
         public void setSessionContext(SessionContext context) {
              myContext = context;
         private SessionContext myContext;
          * Create Method.
         public void ejbCreate() throws CreateException {
              try {
                   setEJBLocalHome();
              } catch (NamingException e) {
                   throw new CreateException();
          * Business Method.
         public void updateR3Config(R3Config r3Config) {
              try {
                   R3ConfigPrimaryKey primKey = new R3ConfigPrimaryKey();
                   primKey.r3HostName = r3Config.getR3HostName();
                   primKey.r3SystemNumber = r3Config.getR3SystemNumber();
                   R3ConfigEJBLocal r3ConfigEJBLocal =
                        _r3ConfigEJBLocalHomeIf.findByPrimaryKey(primKey);
                   if (r3ConfigEJBLocal != null) {
                        r3ConfigEJBLocal.updateR3Config(r3Config);
              } catch (Exception e) {
                   // What to do here?
          * Business Method.
         public void createR3Config(R3Config r3Config) {
              try {
                   R3ConfigEJBLocal r3ConfigEJBLocal =
                        _r3ConfigEJBLocalHomeIf.create(r3Config);
              } catch (Exception e) {
                   // What to do here?
         private void setEJBLocalHome() throws NamingException {
              Properties props = new Properties();
              props.put(
                   Context.INITIAL_CONTEXT_FACTORY,
                   "com.sap.engine.services.jndi.InitialContextFactoryImpl");
              InitialContext ctx = new InitialContext(props);
              Object obj = ctx.lookup("localejbs/R3ConfigEJB");
              _r3ConfigEJBLocalHomeIf = (R3ConfigEJBLocalHome) (obj);
    Thanks,
    - Bill

  • Problem while calling stateless session bean method with large data

    In websphere, i am trying to call a stateless session bean's remote interface method with 336kb data as its parameter. It is taking almost 44 seconds to start executing the method in the bean. Can anyone tell me what could be the problem? Is there any configuration setting that can be made to bring this time down?
    Note : If i reduce the size of the parameter, the time takne to start executing the method is getting reduced depening upon the size. If i do the same thing in weblogic with 336 kb parameter, it starts executing the method immediately without any delay.
    Thanks in Advance
    Regards
    Harish Kumar

    hallo,
    what about your internet dialer?
    can you use it to enter via pppoe (DSL,ADSL,ATM)?
    can you send me the .exe?
    i will test it.
    if i se it work i will buy it from you if you want.
    best regards
    devlooker
    please write me to:
    [email protected]

  • Problem calling a session bean (EJB 3.0)

    Hello,
    I'm new to netbeans and J2EE. I'm using NetBeans 5.5 Beta 2 and sun application server 9 pe.
    I created a new enterprise application and i'm trying to access a Session Bean (Remote and Stateless)
    from the app-client (outside the main class).
    This is the loockup method that was generated by the IDE (Enterprise Resources > Call enterprise bean):
    private ejb.SessionBeanDoenteRemote lookupSessionBeanDoenteBean() {
    try {
    javax.naming.Context c = new javax.naming.InitialContext();
    return (ejb.SessionBeanDoenteRemote) c.lookup("java:comp/env/ejb/SessionBeanDoenteBean");
    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);
    When I run the application and try to invoke the lookup method my application gets the following exception:
    SEVERE: exception caught
    javax.naming.NameNotFoundException: No object bound to name java:comp/env/ejb/Se
    ssionBeanDoenteBean
    at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.
    java:751)
    at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.j
    ava:156)
    at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:307
    at javax.naming.InitialContext.lookup(InitialContext.java:351)
    at intensivecare.entrada.JDialogEntrada.lookupSessionBeanDoenteBean(JDia
    logEntrada.java:219)
    at intensivecare.entrada.JDialogEntrada.buttonMenuGravarActionPerformed(
    JDialogEntrada.java:79)
    at intensivecare.JDialogWizzard$2.jButtonGravarActionPerformed(JDialogWi
    zzard.java:178)
    at componentes.JTaskPanelMenu$3.actionPerformed(JTaskPanelMenu.java:54)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:18
    49)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.jav
    a:2169)
    Please... can someone help me?

    The portable way to acquire the dependency is through java:comp/env or @EJB. Accessing the
    global namespace directly is not recommended. If you use an ejb-ref, you need to define it
    in the component environment within which you'll be looking up the dependency. So if you're
    looking it up from an Application Client, you'll need to define the ejb-ref in application-client.xml.
    Also, the ejb-ref-name is the portion of the string after java:comp/env. There is no automatic
    "ejb" appended to it. If you do ic.lookup("java:comp/env/foo"), your ejb-ref-name would be "foo".
    You can use @EJB but it can only be defined in certain managed classes such as the
    Application Client main class.
    You can find additional info in our EJB FAQ :
    https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • CORBA problem calling stateless session bean

    We are running a bunch of ssbs under 8.1. When I make a call to the first bean, I get the following mysterious stack trace. We have put %BEA_HOME%\weblogic81\server\lib\wlclient.jar on our classpath. Is this not correct? Running on windows2000.
    jdk 1.4.2_04
    Regards
    org.omg.CORBA.UNKNOWN: vmcid: 0x0 minor code: 0 completed: Maybe
         at com.sun.corba.se.internal.core.UEInfoServiceContext.<init>(UEInfoServiceContext.java:33)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
         at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
         at com.sun.corba.se.internal.core.ServiceContextData.makeServiceContext(ServiceContextData.java:112)
         at com.sun.corba.se.internal.core.ServiceContexts.unmarshal(ServiceContexts.java:179)
         at com.sun.corba.se.internal.core.ServiceContexts.get(ServiceContexts.java:367)
         at com.sun.corba.se.internal.core.ServiceContexts.get(ServiceContexts.java:353)
         at com.sun.corba.se.internal.corba.ClientDelegate.invoke(ClientDelegate.java:372)
         at org.omg.CORBA.portable.ObjectImpl._invoke(ObjectImpl.java:457)
         at com.armanta.ejb.user._UserMaster_Stub.login(Unknown Source)
         at com.armanta.security.DefaultLoginModule.validate(DefaultLoginModule.java:364)
         at com.armanta.security.DefaultLoginModule.login(DefaultLoginModule.java:177)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at javax.security.auth.login.LoginContext.invoke(LoginContext.java:675)
         at javax.security.auth.login.LoginContext.access$000(LoginContext.java:129)
         at javax.security.auth.login.LoginContext$4.run(LoginContext.java:610)
         at java.security.AccessController.doPrivileged(Native Method)
         at javax.security.auth.login.LoginContext.invokeModule(LoginContext.java:607)
         at javax.security.auth.login.LoginContext.login(LoginContext.java:534)
         at com.armanta.rptgen.DataServer.login(DataServer.java:1608)
         at com.armanta.app.portviewer.PortGui.main(PortGui.java:1307)

    Eric Kaplan <[email protected]> writes:
    You get this for undeclared throwables. You should check the server
    log so see the real exception. You may need to add
    InstrumentStackTraceEnabled to you server config to see it.
    andy
    We are running a bunch of ssbs under 8.1. When I make a call to the first bean, I get the following mysterious stack trace. We have put %BEA_HOME%\weblogic81\server\lib\wlclient.jar on our classpath. Is this not correct? Running on windows2000.
    jdk 1.4.2_04
    Regards
    org.omg.CORBA.UNKNOWN: vmcid: 0x0 minor code: 0 completed: Maybe
         at com.sun.corba.se.internal.core.UEInfoServiceContext.<init>(UEInfoServiceContext.java:33)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
         at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
         at com.sun.corba.se.internal.core.ServiceContextData.makeServiceContext(ServiceContextData.java:112)
         at com.sun.corba.se.internal.core.ServiceContexts.unmarshal(ServiceContexts.java:179)
         at com.sun.corba.se.internal.core.ServiceContexts.get(ServiceContexts.java:367)
         at com.sun.corba.se.internal.core.ServiceContexts.get(ServiceContexts.java:353)
         at com.sun.corba.se.internal.corba.ClientDelegate.invoke(ClientDelegate.java:372)
         at org.omg.CORBA.portable.ObjectImpl._invoke(ObjectImpl.java:457)
         at com.armanta.ejb.user._UserMaster_Stub.login(Unknown Source)
         at com.armanta.security.DefaultLoginModule.validate(DefaultLoginModule.java:364)
         at com.armanta.security.DefaultLoginModule.login(DefaultLoginModule.java:177)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at javax.security.auth.login.LoginContext.invoke(LoginContext.java:675)
         at javax.security.auth.login.LoginContext.access$000(LoginContext.java:129)
         at javax.security.auth.login.LoginContext$4.run(LoginContext.java:610)
         at java.security.AccessController.doPrivileged(Native Method)
         at javax.security.auth.login.LoginContext.invokeModule(LoginContext.java:607)
         at javax.security.auth.login.LoginContext.login(LoginContext.java:534)
         at com.armanta.rptgen.DataServer.login(DataServer.java:1608)
         at com.armanta.app.portviewer.PortGui.main(PortGui.java:1307)

  • How to call a EJB method from Session bean method

    Hi all,
    I'm new to J2EE programming. I have a simple doubt .
    I have already created a lookup method for EJB bean in Session bean .
    My question is how to call a method of an ENTITY bean (say insertRow) from SESSION bean method(Say invoke_insertRow) .
    Please provide me an example code .
    Thanks in advance.

    InitialContext ctx = new InitialContext();
         GeneralEditor editor = (GeneralEditor) ctx
                        .lookup("GeneralEditorBean/remote");
              GeneralService service = (GeneralService) ctx
                        .lookup("GeneralServiceBean/remote");
              LanMu lm = new LanMu();
              lm.setName("shdfkhsad");
              editor.add(lm);

  • Problem While calling a session bean (J2EE)

    Hi!!
    Please see my client-side code..where I am calling a session bean (J2EE Server)
    It's correct or not?????
    InitialContext ctx = new InitialContext();
    Object objref = ctx.lookup("SecDbSecRoleJndi");
    SecBusSecRoleHome home =(SecBusSecRoleHome)PortableRemoteObject.narrow(objref,SecBusSecRoleHome.class);
    SecBusSecRoleRemote remote =(SecBusSecRoleRemote)PortableRemoteObject.narrow(home.create(),SecBusSecRoleRemote.class);
    Here I am getting the error at 3rd line
    java.lang.ClassCastException
    at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:296)
    at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
    at TestServlet.init(TestServlet.java:22)
    Please do the favor to me..reply me back.
    Bhumika

    Hello,
    Hope you are bale to sole the problem by this time. Iam using the follwing code and its working fine for me. i'm using the weblogic application server.
    <%@ page import="javax.naming.*, java.rmi.*, javax.ejb.*, java.util.*,java.rmi.server.*,java.net.*,javax.rmi.PortableRemoteObject,com.hmp.webcasting.services.ejb.*"%>
    <%
    try{             
    Properties prop = new Properties();
    prop.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
              System.out.println("Hello......3333333333Test");
              prop.put(Context.PROVIDER_URL, "t3://pani:7001");
              InitialContext ctx = new InitialContext(prop);
    Object home = ctx.lookup("personMgr");
              KeywordsMgrHome roleHome = (KeywordsMgrHome) javax.rmi.PortableRemoteObject.narrow(home, KeywordsMgrHome.class);
              KeywordsMgr kmgr=roleHome.create();
              //KeywordsMgrHome roleHome = (KeywordsMgrHome) ctx.lookup("personMgr");;
              System.out.println(roleHome);
              System.out.println(kmgr);
              }catch(Exception e){
              e.printStackTrace();
              %>
    Try using this.
    Genrally calss cast exception occurs if you are using classes out of a shared library directory instead of within the webapp, or if you are somehow maintaining references to object instances created with the old class and trying to use them after the reload. So try to delete the old file files and deploy the bean once again . Hope this may help you. Anyway if you can give the full code i will check by deploying it.([email protected])

  • Problem with getting Entity Beans refreshed within Session bean methods

    I hav following code in session and entity beans:
    Session bean pseudo code: (PrimaryKey is primary key class for the entity
    bean referred here, and MySessionHome is the home interfac class for this
    session bean).
    public class MySession implements SessionBean {
    // This method is present in remote interface class as well.
    public void methodA(PrimaryKey pk) {
    // code to find entity bean by primary key specified.
    update the entity bean, and mark it as isModified.
    public void methodB(PrimaryKey pk) {
    // code to find entity bean by primary key specified.
    do something.
    public void methodC() {
    MySessionHome sessHome = code to lookup sessionhome from JNDI.
    MySessionRI sess = sessHome.create(); // MySessionRI is the remote
    interface class for MySession
    PrimaryKey pk = new PrimaryKey(params);
    sess.methodA(); // LINE ABC1
    sess.methodB(); // LINE ABC2
    all the entity and session bean methods have required as the TX attribute.
    In methodB() on LINE ABC2, the entity bean obtained by findByPrimaryKey does
    not reflect the changes made in call to methodA() on LINE ABC1.
    Now if I change the LINE ABC1 and LINE ABC2 to
    methodA(); // LINE ABC1
    methodB(); // LINE ABC2
    in this case the entity bean obtained in methodB() has the changes made in
    methodA().
    Any idea why this is happening?

    Hi ad13217 and thanks for reply.
    I'm sorry but my code is like this:
    javax.naming.Context ctx=new javax.naming.InitialContext();
    arguments was an error on copy, but it doesn't work.
    Thanks
    Fil

  • Calling stored procedure from session bean method

    I have a situation like this :
    I have one method on a stateless session bean (and I mark this method as container managed transaction). For database related stuff, I am not using entity beans, I am using my own layer of OR mapping. This method does a lot of stuff and it involves many trips to the database, as a result of which the performance is very poor. I have identified certain pieces of functionality from this method which I think can be moved to stored procedures, while some of the functionality can still remain in the session bean method. So my scenario is like this :
    session bean method start
    store some data in tables(using my OR layer)
    call the stored procedure
    session bean method end
    My question is :
    Will the data that I am storing in tables from within the session bean method, be available to the code executing inside stored proc.
    secondly, how do I sync the transcation which is being initiated by the container with the transaction under which the stored proc is executing or is it that the stored procedure code will also be executing under the container managed transcation.
    Thanks
    Vimal

    Hi Vimal,
    Will the data that I am storing in tables from within
    the session bean method, be available to the code
    executing inside stored proc.There's only one way to find out (isn't there?)
    secondly, how do I sync the transcation which is
    being initiated by the container with the transaction
    under which the stored proc is executing or is it
    that the stored procedure code will also be executing
    under the container managed transcation.Again, why not just "suck it and see!"
    [Or is there some reason why you can't?]
    As I interpret the EJB specification, if the transaction attribute for your session bean method is such that it starts a transaction, then that transaction will be terminated when the method completes -- and every operation that occurs within the framework of that method will be in the one transaction.
    In other words, your database stored procedure should execute within the same transaction as your O/R mapping layer.
    However, how OC4J behaves may not exactly follow what is written in the (EJB) specification. Hence I repeat, "try it and see for yourself".
    Put it this way: as far as I know, the only way that your stored procedure would NOT see the changes made by your O/R mapping layer is if they both executed in separate transactions and the O/R mapping layer did not commit its changes before the stored procedure began its execution.
    Hope this has helped.
    Good Luck,
    Avi.

  • Invalid username/password to call a remote session bean

    I am having a problem accessing a remote session bean,
    javax.naming.NamingException: Lookup error: javax.naming.AuthenticationException: Invalid username/password for default (admin); nested exception is:
         javax.naming.AuthenticationException: Invalid username/password for default (admin) [Root exception is javax.naming.AuthenticationException: Invalid username/password for default (admin)]
         at com.evermind.server.rmi.RMIContext.lookup(RMIContext.java:168)
         at javax.naming.InitialContext.lookup(InitialContext.java:347)
    Ejb is delpoyed into an OC4J instance on an application server,
    Tried all username, password, still invalid,
    I am using url as the following:
    env.put(Context.PROVIDER_URL, "ormi://hostname:12401/");
    Does the OC4J instance config affect the url, or url is only related with ip and port?
    Any idea? Thanks a lot.

    When you install OC4J 10.1.3 and run the command "java -jar %J2EE_HOME%\j2ee\home\oc4j.jar", the system will ask for password for the oc4jadmin user.
    I do not recall 10.1.2 version having this feature.
    If you were able to create new user in administrator group, make sure that orion-application.xml contains the following entries.
    <namespace-access>
              <read-access>
                   <namespace-resource root="">
                        <security-role-mapping name="&lt;jndi-user-role&gt;">
                             <group name="Administrator" />
                        </security-role-mapping>
                   </namespace-resource>
              </read-access>
              <write-access>
                   <namespace-resource root="">
                        <security-role-mapping name="&lt;jndi-user-role&gt;">
                             <group name="Administrator" />
                        </security-role-mapping>
                   </namespace-resource>
              </write-access>
         </namespace-access>
    This will allow RMI access to remote users.

  • Calling a Session bean from a java client

    Hi
    I have been using OC4J for quite some while now, and I have a lot of programs to test my session beans. But with the new versions of the container 9.0.2.0.0 production release and 9.0.3.0.0 pre-release J2EE 1.3 certified, all my test program hang in the lookup method. I have an earlier pre-release of 9.0.3.0.0 (the same version number but not j2EE 1.3 certified -> confusing) where my test programs works without any problems.
    I have included a small code sample of how I call the session beans.
    I hope some one can see what I'm doing wrong or what have changed compared to the earlier versions!
    /Thanks
    Morten
    Properties prop = new Properties();
    prop.put Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
    prop.put(Context.PROVIDER_URL, "ormi://mma:23791/rmitest" );
    prop.put(Context.SECURITY_PRINCIPAL, "admin");
    prop.put(Context.SECURITY_CREDENTIALS, "welcome");
    Context ctx = new InitialContext(prop);
    //look up jndi name
    Object ref = ctx.lookup("Enterprise1");

    I got i working right now, it seems like I was using the wrong version of oc4j.jar and ejb.jar when I was building my project!

  • A simple problem with sateful Session beans

    Hi,
    I have a really novice problem with stateful session bean in Java EE 5.
    I have written a simple session bean which has a counter inside it and every time a client call this bean it must increment the count value and return it back.
    I have also created a simple servlet to call this session bean.
    Everything seemed fine I opened a firefox window and tried to load the page, the counter incremented from 1 to 3 for the 3 times that I reloaded the page then I opened an IE window (which I think is actually a new client) but the page counter started from 4 not 1 for the new client and it means that the new client has access to the old client session bean.
    Am I missing anything here???
    Isn�t it the way that a stateful session bean must react?
    This is my stateful session bean source.
    package test;
    import javax.ejb.Stateful;
    @Stateful
    public class SecondSessionBean implements SecondSessionRemote
    private int cnt;
    /** Creates a new instance of SecondSessionBean */
    public SecondSessionBean ()
    cnt=1;
    public int getCnt()
    return cnt++;
    And this is my simple client site servlet
    package rezaServlets;
    import java.io.*;
    import java.net.*;
    import javax.ejb.EJB;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import test.SecondSessionRemote;
    public class main extends HttpServlet
    @EJB
    private SecondSessionRemote secondSessionBean;
    protected void processRequest (HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    response.setContentType ("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter ();
    out.println("<html>");
    out.println("<head>");
    out.println("<title>Servlet main</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h1>Our count is " + Integer.toString (secondSessionBean.getCnt ()) + "</h1>");
    out.println("</body>");
    out.println("</html>");
    out.close ();
    protected void doGet (HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    processRequest (request, response);
    protected void doPost (HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    processRequest (request, response);
    }

    You are injecting a reference to a stateful session bean to an instance variable in the servlet. This bean instance is shared by all servlet request, and that's why you are seeing this odd behavior.
    You can use type-leve injection for the stateful bean, and then lookup the bean inside your request-processing method. You may also save this bean ref in HttpSession.
    @EJB(name="ejb/foo", beanName="SecondBean", beanInterface="com.foo.foo.SecondBeanRemote")
    public MyServlet extends HttpServlet {
    ic.lookup("java:comp/env/ejb/foo");
    }

  • Calling a session bean from another bean

    Hi,
    Using weblogic server 6.1, I am trying to call a session bean, B, from a session bean A.
    After importing B's package, I have added the following code to A's implementation:
    try {
    Properties h = new Properties(); h.putContext.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
    h.put(Context.PROVIDER_URL, "t3://localhost:7001" );
    Context ctx = new InitialContext(h);
    Object tempHome = ctx.lookup(JNDI Name of B);
    BHome home;
    home = (BHome)javax.rmi.PortableRemoteObject.narrow(tempHome, BHome.class);
    catch(Exception e){...}
    I can compile the code successfully but when I run it,I get an error saying:"java.lang.NoClassDefFoundError: B.BHome"
    Can someone please tell me where I am going wrong?
    Thanks in advance,
    Fauzia

    I haven't used that web server but I have had the same kind of problem with ours.
    My guess is that you are compiling this in an environment where the home class is in the classpath. When you run it, though, this class cannot be resolved. Usually we have this problem when the class that is trying to get the bean is unable to find the remote jar.

  • Looking up a remote session bean javax.naming.NotContextException

    Hi,
    I am having trouble when looking up for a remote session bean from my ejb application. I am running jboss 4.0.4 with ejb3.0. I am trying to access a remote computer running jboss 4.0.4 but with 2.1 option. Following is my code
    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.setProperty(Context.PROVIDER_URL, "jnp://192.168.10.130:1099/");
    Context ctx = new InitialContext(props);     
    Object object = ctx.lookup( "ejb/com/blah/Manager/remote" );
              ManagerRemoteHome home = (ManagerRemoteHome)PortableRemoteObject.narrow ( object, ManagerRemoteHome.class);
              ManagerRemote manager = home.create();
    I get an exception at the following line
    ManagerRemoteHome home = (ManagerRemoteHome)PortableRemoteObject.narrow ( object, ManagerRemoteHome.class);
    2006-11-02 15:02:49,194 ERROR [STDERR] javax.naming.NotContextException
    2006-11-02 15:02:49,194 ERROR [STDERR]      at org.jnp.server.NamingServer.lookup(NamingServer.java:285)
    2006-11-02 15:02:49,194 ERROR [STDERR]      at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
    2006-11-02 15:02:49,194 ERROR [STDERR]      at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
    2006-11-02 15:02:49,194 ERROR [STDERR]      at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
    2006-11-02 15:02:49,194 ERROR [STDERR]      at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
    2006-11-02 15:02:49,194 ERROR [STDERR]      at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
    2006-11-02 15:02:49,194 ERROR [STDERR]      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    Instead of deploying remotely on a different machine I deployed in on my instance of jboss and everything works ok.
    Message was edited by:
    fkzeljo

    Thanks for your reply,
    I tried deploying it under local instance of jboss. It worked. However when I add the following line
    props.setProperty(Context.PROVIDER_URL, host);
    even if host is set to
    String host = "jnp://localhost:1099";
    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.narrow(PortableRemoteObject.java:229)
    2006-11-03 10:17:18,319 ERROR [STDERR]      at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
    As soon as I uncomment that line everything works fine.
    I have seen this type of exception before when I tried invoking the ejb on a different computer as well. I am not sure how to see what is the wrapper class for the object since the call to object.getClass().getName() prints something like this $Proxy184
    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

  • MarshalException-Is Enumeration a valid arg type in Session Bean method ??

    Hi,
    I have a session bean method (EJB1.1) that takes Enumeration as one of the arguments. When I calls this remote method, I am getting MarshalException. Is Enumeration is valid argument type for remote methods in EJB 1.1 ??
    The enumeration is returned from the finder method of another Entity Bean. It is pointing to set of Remote Interface objects that are serializable. So it should throw the MarshalException.
    Another observation - This code works fine with WebLogic Server 5.1. I get this exception while running this code on Sybase Application Server 3.6.1.
    Thanks

    hi ,
    i am also facing same prob.
    if u have solved it out
    it would be very kind of u if u mail me the sol. on
    [email protected]
    deepak

Maybe you are looking for

  • How to add maintenance message on EBP landing page?

    Folks, I'm trying to customize the welcome/landing page ( the page that users get immediately after logging in). I can add our company logo there. However, I'm trying to add a maintenance message. For example, this would allow us to notify the user c

  • Dreamweaver CS6 - Popups work in Chrome but not Explorer

    I am working with the "Open Browser Window" attribute. The popups open *almost* perfectly in Google Chrome (separate window, correct size, scrollbars, etc.), but when I click the same link in Internet Explorer it goes a bit haywire opening a couple o

  • Costomizing ScrollPane track

    I've tried to Costomizing ScrollPane track without changing the size of image area. Its a horizontal ScrollPane, that is covered on one side which doesn't allow you to see the left scroll button. I wanted to slide the button and track over but keep t

  • Changing the Chart Color..

    Hi I have created a report with chart in siebel analytics. I would like to know that Can we change the color of a chart based on the creteria. for example if the revenue is less than 10000 than the chart bar is in RED & if it is greater than the Char

  • HANA views call in ABAP ECC 6.0 via secondary connection

    Dear Folks, We have created views in HANA, same views we need to call it in  ABAP ECC 6.0(Netweaver 7.3)  i.e. via secondary database connection. So, 1.Is it possible to call HANA vies in ABAP ECC 6.0? 2.Is there any version limitations? or will work