Pls Help! Failed to access local Session bean in 7.0!

Hi all,
Heard that to deploy local bean in weblogic 7.0, I need to put my war
file and ejb jar files in the ear file. My client servlet contains the
following:
AccessControlLocalHome accessControlLocalHome =
(AccessControlLocalHome)ctx.lookup("AccessControlLocalHome");
But it failed miserably with the exception
javax.naming.LinkException: . Root exception is
javax.naming.NameNotFoundExcept
ion: Unable to resolve
'app/ejb/AccessControlBean.jar#AccessControlBean/local-ho
me' Resolved: 'app/ejb'
Unresolved:'AccessControlBean.jar#AccessControlBean' ; r
emaining name 'AccessControlBean.jar#AccessControlBean/local-home'
Just got an idea that it might be my web.xml file. So I include the
following in my web.xml file:
<ejb-local-ref>
     <ejb-ref-name>ejb/AccessControlLocalHome</ejb-ref-name>
     <ejb-ref-type>Session</ejb-ref-type>
<local-home>com.spear.ejb.simorder.VendorOrderSLBean.AccessControlLocalHome</local-home>
<local>com.spear.ejb.simorder.VendorOrderSLBean.AccessControlLocal</local>
<ejb-link>AccessControlBean.jar#AccessControlBean</ejb-link>
</ejb-local-ref>
But it gives the following error:
Module Name: projects, Error: weblogic.j2ee.DeploymentException: Could
not setup
environment - with nested exception:
[javax.naming.NameNotFoundException: Unable to resolve ejb-link.
AccessControlBe
an.jar#AccessControlBean is not in the context. The context includes
the followi
ng link bindings: {} Make sure the link reference is relative to the
URI of the
referencing module.]
Pls help!
Thanks!
Innovest

<ejb-link> should be
<ejb-link> ../AccessControlBean.jar#AccessControlBean</ejb-link>
innovest wrote:
Hi all,
Heard that to deploy local bean in weblogic 7.0, I need to put my war
file and ejb jar files in the ear file. My client servlet contains the
following:
AccessControlLocalHome accessControlLocalHome =
(AccessControlLocalHome)ctx.lookup("AccessControlLocalHome");
But it failed miserably with the exception
javax.naming.LinkException: . Root exception is
javax.naming.NameNotFoundExcept
ion: Unable to resolve
'app/ejb/AccessControlBean.jar#AccessControlBean/local-ho
me' Resolved: 'app/ejb'
Unresolved:'AccessControlBean.jar#AccessControlBean' ; r
emaining name 'AccessControlBean.jar#AccessControlBean/local-home'
Just got an idea that it might be my web.xml file. So I include the
following in my web.xml file:
<ejb-local-ref>
<ejb-ref-name>ejb/AccessControlLocalHome</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home>com.spear.ejb.simorder.VendorOrderSLBean.AccessControlLocalHome</local-home>
<local>com.spear.ejb.simorder.VendorOrderSLBean.AccessControlLocal</local>
<ejb-link>AccessControlBean.jar#AccessControlBean</ejb-link>
</ejb-local-ref>
But it gives the following error:
Module Name: projects, Error: weblogic.j2ee.DeploymentException: Could
not setup
environment - with nested exception:
[javax.naming.NameNotFoundException: Unable to resolve ejb-link.
AccessControlBe
an.jar#AccessControlBean is not in the context. The context includes
the followi
ng link bindings: {} Make sure the link reference is relative to the
URI of the
referencing module.]
Pls help!
Thanks!
Innovest

Similar Messages

  • Could not access Local Session Bean using JNDI lookup

    Hi EJB Guru,
    I am quite new to EJB 3.0 but have had a good deal of success including using JNDI to lookup Remote Stateless Session Bean in EJB 3.0. However, looking up local Stateless Session Bean prove more challenging with I had anticipated.
    Here is my code
    as follows:
    public interface Calculator {
        public int add(int x, int y);
        public int subtract(int x, int y);
    import javax.ejb.Remote;
    @Remote
    public interface CalculatorRemote extends Calculator {
    import javax.ejb.Local;
    @Local
    public interface CalculatorLocal extends Calculator {
    import javax.ejb.Local;
    import javax.ejb.Remote;
    import javax.ejb.Stateless;
    import bean.CalculatorLocal;
    import bean.CalculatorRemote;
    @Stateless
    public class CalculatorBean implements CalculatorRemote, CalculatorLocal {
        public int add(int x, int y) {
            return x + y;
        public int subtract(int x, int y) {
            return x - y;
    import bean.*;
    import bean.Calculator;
    import bean.CalculatorLocal;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    public class ClientAccessLocalCalculator {
        public static void main(String[] args) throws NamingException {
            InitialContext ctx = new InitialContext();
            CalculatorLocal calculator = (CalculatorLocal) ctx.lookup("CalculatorBean/local");
            System.out.println("1 + 1 = " + calculator.add(1, 1));
            System.out.println("1 - 1 = " + calculator.subtract(1, 1));    }
    import bean.Calculator;
    import bean.CalculatorRemote;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    public class ClientAccessRemoteCalculator {
        public static void main(String[] args) throws NamingException {
            InitialContext ctx = new InitialContext();
            CalculatorRemote calculator = (CalculatorRemote) ctx.lookup("CalculatorBean/remote");
            System.out.println("1 + 1 = " + calculator.add(1, 1));
            System.out.println("1 - 1 = " + calculator.subtract(1, 1));    }
    }Output when running ClientAccessRemoteCalculator gives
    1 + 1 = 2
    1 - 1 = 0
    Output when running ClientAccessLocalCalculator on JBoss AS 4.0.5 gives:
    Exception in thread "main" javax.ejb.EJBException: Invalid invocation of local interface (null container)
    at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:75)
    at $Proxy0.add(Unknown Source) at ClientAccessLocalCalculator.main(ClientAccessLocalCalculator.java:14)
    JNDIView in JMX-Console in JBoss:
    +- CalculatorBean (class: org.jnp.interfaces.NamingContext)
    | +- local (proxy: $Proxy84 implements interface bean.CalculatorLocal,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
    | +- remote (proxy: $Proxy83 implements interface bean.CalculatorRemote,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)
    Output when running ClientAccessLocalCalculator on SJSAS 9.0 gives:
    Exception in thread "main" javax.naming.NameNotFoundException: bean.CalculatorLocal not found
    C:\>asadmin
    Use "exit" to exit and "help" for online help.
    asadmin> list-jndi-entries
    Jndi Entries for server within root context:
    bean.CalculatorRemote: javax.naming.Reference
    jbi: com.sun.enterprise.naming.TransientContext
    jdbc: com.sun.enterprise.naming.TransientContext
    UserTransaction: com.sun.enterprise.distributedtx.UserTransactionImpl
    bean.CalculatorRemote__3_x_Internal_RemoteBusinessHome__: javax.naming.Reference
    bean.CalculatorRemote#bean.CalculatorRemote: javax.naming.Reference
    ejb: com.sun.enterprise.naming.TransientContext
    Command list-jndi-entries executed successfully.
    asadmin>I am using Application Client to lookup these Session Beans on Netbeans 5.5, JBoss AS 4.0.5 (EJB3 installer)/SJSAS
    9.0, SDK 1.5.0_11 on Windows XP platform.
    Any assistance would be much appreciated.
    Many thanks,
    Henry

    Hi Henry,
    Any direct global JNDI lookup is not portable. It works in some cases but not in others, which
    is why we recommend using the portable Java EE approach of declaring an ejb dependency
    and looking up that dependency via the bean's component environment (java:comp/env).
    This is true whether you're dealing with Remote or Local ejb dependencies.
    Local ejbs are not supported in the Application Client tier at all. In the server tier, there is no
    guarantee that a Local EJB even is assigned a global JNDI name since there's no requirement
    that it be available outside of the application in which the ejb is defined.
    You can find more information on these ejb access topics in our EJB FAQ :
    https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html

  • Local Session Bean calling another local Session Bean in EJB 3.0

    Hi,
    In EJB 3.0, I am trying to do JNDI lookup of a local sesion bean from another session bean's helper class.
    I am not using @EJB injection mechanism here, as call to the local session bean is made in a helper class. Helper classes do not support resource injection.
    Following are the EJB class definitions used in my project. Call to "EJB3Local" made from "EJB1" fails as the "EJB2" helper class is calling "EJB1Local"
    @Stateless
    @EJBs({@EJB(name="EJB2Local", beanInterface=EJB2Local.class),
    @EJB(name="EJB3Local", beanInterface=EJB3Local.class)})
    public class EJB1 implements EJB1Remote, EJB1Local{
    public void findEJB3Local(){
    //1. JNDI lookup for EJB3Local ----
    //2. EJB3Local.someFunction()
    @Stateless
    @EJB(name="EJB1Local", beanInterface=EJB1Local.class)
    public class EJB2 implements EJB2Remote, EJB2Local{
    public void findEJB1Local(){
    //1. JNDI lookup EJB1Local
    // 2. Call EJB1Local.findEJB1Local method
    @Stateless
    public class EJB3 implements EJB3Remote, EJB3Local{
    public void someFunction(){}
    A remote call to EJB2.findEJB1Local() will invoke EJb1Local.findEJB3Local method and the call fails with "java:comp/env/EJB3Local" not found in EJB1Local.
    Has anybody encountered an issue like this issue with local interface calling another local interface?
    Thanks,
    Mohan

    To refer a Ejb from another Ejb include <ejb-ref> element
    in ejb-jar.xml
    <session>
    <ejb-name>SessionBeanA</ejb-name>
    <ejb-ref>
    <ejb-ref-name>SessionBeanB</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <home>com.ejb.SessionBeanBHome</home>
    <remote>com.ejb.SessionBeanB</remote>
    </ejb-ref>
    </session>
    Include a <reference-descriptor> in weblogic-ejb-jar.xml
    <weblogic-enterprise-bean>
    <ejb-name>SessionBeanA</ejb-name>
    <reference-descriptor>
    <ejb-reference-description>
    <ejb-ref-name>SessionBeanB</ejb-ref-name>
    <jndi-name>com.ejb.SessionBeanBHome</jndi-name>
    </ejb-reference-description>
    </reference-descriptor>
    </weblogic-enterprise-bean>
    In SessionBeanA Bean class refer to SessionBeanB with
    a remote reference to SessionBeanB.
    InitialContext initialContext=new InitialContext();
    SessionBeanBHome sessionBeanBHome=(SessionBeanBHome)
    initialContext.lookup("com.ejb.SessionBeanBHome");
    SessionBeanB sessionBeanB=sessionBeanBHome.findByPrimaryKey(primarykey);
    sessionBeanB.update();
    sessionBeanB.getAll();
    thanks,
    Deepak

  • Local session bean lookup in another local session bean in EJB 3.0

    Hi,
    I am doing JNDI lookup of a local session bean in a session bean. ( I do not want to use EJB dependency injection).
    Lookup of local interface from session bean is successful. But, when the calling session bean is a local session in another session bean, the lookup fails.
    Here is an example:
    @Stateless
    @EJBs({@EJB(name="EJB2Local", beanInterface=EJB2Local.class),
    @EJB(name="EJB3Local", beanInterface=EJB3Local.class)})
    public class EJB1 implements EJB1Remote, EJB1Local{
    public void findEJB3Local(){
    //1. JNDI lookup for EJB3Local ----
    //2. EJB3Local.someFunction()
    @Stateless
    @EJB(name="EJB1Local", beanInterface=EJB1Local.class)
    public class EJB2 implements EJB2Remote, EJB2Local{
    public void findEJB1Local(){
    //1. JNDI lookup EJB1Local
    // 2. Call EJB1Local.findEJB1Local method
    //THIS METHOD CALL WILL FAIL.
    public void findEJB1Remote(){
    //1. JNDI lookup EJB1
    / 2. Call EJB1Local.findEJB1 method
    @Stateless
    public class EJB3 implements EJB3Remote, EJB3Local{
    public void someFunction(){}
    This setup was working in EJB 2.1, as we had clear ejb-local-ref definitions in our ejb-jar.xml file.
    I am suspecting that EJB 3.0 has special annotation to use when lookup is made from another local session bean.
    Any comments will be appreciated.
    Thanks,
    Mohan

    From a private component environment perspective, declaring @EJB in a bean class is equivalent
    to using ejb-ref or ejb-local-ref for that same bean in ejb-jar.xml. In each case, the EJB dependency
    is declared for that bean. Each EJB component has its own private component environment, so
    code running within invocations on different EJBs can not see the component environment of the
    components that made the invocations.
    What exact error are you getting? Please post the stack trace if possible.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Using local session bean interface from web container using EJB 3.0

    Hi,
    How can you use a local session bean interface from Java (rather than data controls) in a web container using EJB 3.0?
    I can use a remote interface by looking up InitialContext, but I can't find a local interface this way (even from another session EJB). I can use a local interface from an EJB using annotation "EJB", but as I understand, this is not available in the web container.
    If I try to add an ejb-jar.xml file, these seems to mess up by project...
    Hope you can help.
    Roger

    The portable way to retrieve an EJB reference in Java EE is to either inject it or look it up via the
    component's private naming environment. The simplest way is :
    @EJB
    private DocumentManager dm;
    The global JNDI name is only used as an implementation specific way to uniquely assign an
    identifier to a specific Remote EJB. It's best for this not to appear directly in the source code.
    There's more on global JNDI names in our EJB FAQ :
    https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html
    The alternative to annotations is to use an ejb-ref to declare the ejb dependency. The ejb-ref
    is declared in the standard deployment descriptor corresponding to the component doing the
    lookup. Each ejb-ref has an ejb-ref-name, e.g. <ejb-ref-name>DM_ref</ejb-ref-name>
    The code looks up the ejb-ref-name relative to the java:comp/env namespace to retrieve the
    EJB reference.
    DocumentManager dm = (DocumentManager)
    new InitialContext().lookup("java:comp/env/DM_ref");

  • Help!!! Stateful session bean clustering

              I posted this message on interest.clustering.in-memory-replication. But there is
              no answer at all. Could anyone give me
              some hints? Thanks a lot. I am a student and this work is part of my course project.
              It is due soon.
              =================================================================
              I have a big problem to get stateful session bean in-memory replication run on
              clustering. I have three server instances on three nodes and there is always errors
              from the server instance like this when I run the client to invoke the bean methods:
              <Jan 4, 2002 6:47:31 PM EST> <Error> <EJB> <Failed to update the secondary copy
              of a stateful session bean from home:stateful.ejb.AgentSTF>
              Besides, the load balancing can not work probably too. Below is what I get.
              Statistics for different servers:
              "myserver" processed 160 (12%) of 1311 invocations "ejbperf-3" processed 1151
              (88%) of 1311 invocations
              End Client...
              Load balancing works fine with stateless and entity bean.
              Any comments are greatly appreciated.
              Jenny
              

    Hi Jenny,
              Please could you open a case to the customer support ([email protected]) There is a Cr
              on this issue CR059046
              Description of the CR
              WLS 6.1SP1 - Accessing Stateful Session Bean from Stateless Session Bean in a
              cluster fails with errors
              <Oct 5, 2001 5:08:25 PM GMT+00:00> <Error> <EJB> <Failed to update the
              secondary copy of a stateful session bean from home:UserState>
              Regards
              Stephane
              Jenny Liu wrote:
              > I posted this message on interest.clustering.in-memory-replication. But there is
              > no answer at all. Could anyone give me
              > some hints? Thanks a lot. I am a student and this work is part of my course project.
              > It is due soon.
              >
              > =================================================================
              >
              > I have a big problem to get stateful session bean in-memory replication run on
              > clustering. I have three server instances on three nodes and there is always errors
              > from the server instance like this when I run the client to invoke the bean methods:
              >
              > <Jan 4, 2002 6:47:31 PM EST> <Error> <EJB> <Failed to update the secondary copy
              > of a stateful session bean from home:stateful.ejb.AgentSTF>
              >
              > Besides, the load balancing can not work probably too. Below is what I get.
              >
              > Statistics for different servers:
              > "myserver" processed 160 (12%) of 1311 invocations "ejbperf-3" processed 1151
              > (88%) of 1311 invocations
              > End Client...
              >
              > Load balancing works fine with stateless and entity bean.
              >
              > Any comments are greatly appreciated.
              >
              > Jenny
              >
              Regards,
              Stephane Kergozien
              BEA Support
              

  • Local Session Bean Call Exception in App Server

    I have been having trouble calling a Local Session bean in Glassfish.
    I set up an example to show the exception I am having:
    MainBeanLocal
        package com.test;
        import javax.ejb.Local;
        @Local
        public interface MainBeanLocal {
             void testCall();
    MainBean:
        package com.test;
        import javax.ejb.Stateless;
         * Session Bean implementation class MainBean
        @Stateless(mappedName = "ejb/MainBean")
        public class MainBean implements MainBeanLocal {
             @Override
             public void testCall() {
                  System.out.println("Test Call Succeeded");
    RemoteBeanRemote:
        package com.test;
        import javax.ejb.Remote;
        @Remote
        public interface RemoteBeanRemote {
             public void callMainBean();
    RemoteBean:
        package com.test;
        import javax.ejb.Stateless;
        import javax.naming.InitialContext;
        import javax.naming.NamingException;
         * Session Bean implementation class RemoteBean
        @Stateless(mappedName = "ejb/RemoteBean")
        public class RemoteBean implements RemoteBeanRemote {
             @Override
             public void callMainBean() {
                  try {
                       InitialContext ctx = new InitialContext();
                       MainBeanLocal mb = (MainBeanLocal) ctx.lookup("ejb/MainBean");
                       mb.testCall();
                  } catch (NamingException e) {
                       // TODO Auto-generated catch block
                       e.printStackTrace();
    Test Code:
        package com.test;
        import javax.naming.InitialContext;
        import javax.naming.NamingException;
        public class BeanTester {
             public static void main(String[] args){
                  try {
                       InitialContext ctx = new InitialContext();
                       RemoteBeanRemote remote = (RemoteBeanRemote) ctx.lookup("ejb/RemoteBean");
                       remote.callMainBean();
                  } catch (NamingException e) {
                       // TODO Auto-generated catch block
                       e.printStackTrace();
    Output Trace:
        INFO: deployed with moduleid = TestEJB
        INFO: **RemoteBusinessJndiName: ejb/RemoteBean; remoteBusIntf: com.test.RemoteBeanRemote
        INFO: LDR5010: All ejb(s) of [TestEJB] loaded successfully!
        WARNING: javax.naming.NameNotFoundException: MainBean not found
             at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:216)
             at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:188)
             at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:74)
             at com.sun.enterprise.naming.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:111)
             at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:409)
             at javax.naming.InitialContext.lookup(InitialContext.java:392)
             at com.test.RemoteBean.callMainBean(RemoteBean.java:19)
             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:597)
             at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1011)
             at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:175)
             at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2920)
             at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4011)
             at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:203)
             at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:117)
             at $Proxy71.callMainBean(Unknown Source)
    ...What am I doing wrong when calling **MainBeanLocal**? I would like to avoid dependency injection, as if the MainBeanLocal was being called from a POJO.
    Note: I have no trouble calling the RemoteBean.. I want to be able to call the local bean from the remote bean.

    Maik,
    If this is still a problem, could you please post the descriptors from the EAR?
    Are you using any annotations?
    - Tim

  • Accessing Managed Session Bean in Servlet Filter

    I wrote a Servlet Filter to handle user authentication. Now I'm trying to access my Managed Session Bean in the filter in order to save the current user. Unfortunately the Session Bean is created after the Filter executes for the first time.
    I'm trying to access the Session Bean in this way:
    (SessionBean) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("sessionBean");
    In this case getExternalContext() is equals null.
    Is there any way to create the Session bean before the filter executes or any other ideas how to handle this?
    I already searched around the internet but couldnt figure out something.
    Thanks guys,
    Paul

    Ok, fixed it like this. Works perfect. JSF finds and uses the handmade Session Bean as well.
    if(request.getSession().getAttribute(BeanNames.SESSION_SCOPE_BEAN) == null) {
         SessionBean sessionBean = new SessionBean();
         request.getSession().setAttribute(BeanNames.SESSION_SCOPE_BEAN, sessionBean);
    }Thanks,
    Paul

  • Help !! Client for session bean

    I need your help for this roblem :
    I have deployed a session bean in helloClient.jar and wrote TestHello class to test the session bean.
    My problem ist to do this test ;i have tried with this command
    java -cp HelloClient.jar TestHello ,but it works not .
    Thanks.

    Without source code or any description of exceptions, your problem definition is useless.

  • Database access from session bean

    Hello,
    I have a stateless session bean which performs some complex
    calculations, and also does some database access.
    For the database access the bean class has a datasource as
    follows:
    public class TestBean implements SessionBean {
    private DataSource ds_;
    public void ejbCreate() {
         getDataSources();
    private void getDataSources() {
         try {
         Context ictx = new InitialContext();
         ds_ = (DataSource)ictx.lookup("java:comp/env/jdbc/TestDB");
         } catch (Exception e) {
         e.printStackTrace();
         throw new EJBException(e);
    Now this class has a method (which is also in the remote interface)
    calculateSomething(). This method constructs a number of other
    objects that do the actual calculation, and one of these objects
    does the actual database access. How would another object be able to
    use the datasource that was constructed in the bean class?
    I could pass the datasource reference to that object, but that would
    break my encapsulation. This is because that object does not get
    created directly by the bean object, but rather the way the objects
    interact is something like A -> B -> C, where A is the TestBean, and
    C is the object that does the DB access. If I passed the datasource,
    I would need to make B aware of the datasource, which doesn't
    seem good design, because B doesn't do any database access.
    Alternatively I could do the lookup in class C, but that would
    degrade the performance, as an object C gets created and destroyed
    every time the calculateSomething() method is called.
    A third option I have thought of, is to add a public method to the
    bean that returns a connection. Whenever another object gets
    created, a reference to the bean object will be passed along. Then,
    if another object needs to do database access, it will call back
    the bean to get a connection. This seems just as bad (if not worse)
    than the first option.
    Does anyone have an elegant solution for this situation? What is
    the best practice of handling datasources when a bean class doesn't
    do the database access itself? In all the examples I've seen so far,
    all the functionality was in the session bean class, but again that
    doesn't seem good OO design, and would result in a single huge class.
    regards,
    Kostas

    Thanks again to both for the replies. Here are my responses:
    Yi Lin: Yes, I know that an entity bean would solve this problem, however it has been decided not to use entity beans so this is not my call (I think the reason entity beans are not allowed in this project is that they are considered risky: there are other applications that access the same database, so if the container caches entity bean data as you describe, then the users might get inconsistent results).
    Gerard: Actually object B is the one that has the business logic and C is a peer object that only does database access and no calculaitons. For example B can be Customer, and C CustomerDB. This is why object B does not have any knowledge of datasources or connections. So my design does not appear to be that bad!
    As far as the factory you propose is concerned, I cannot understand how this would solve my problem. In order to solve this situation the factory would need to be persistent, i.e. get created by the ejbCreate() method, and destroyed whenever the container decides to destroy the bean. There would be no point in object C creating the factory, as I would have the overhead of doing the JNDI lookup every time I create a C.
    So the question remains the same: how would I pass a reference to the factory from A to C without making B aware of it?

  • Exception while accessing deployed session bean

    Hi,
    I am new to IPlanet AS 6.0 . I wrote a simple stateless session bean in Forte EE v 3.0 environment. The compilation and deployment went fine. When I try to use my bean through a client program using IIOP then it throws the following exception in kjs:
    javax.naming.NameNotFoundException: EjbContext: exception on getHome(), com.netscape.server.eb.UncheckedException: unchecked exception thrown by impl com.kivasoft.eb.boot.EBBootstrapImpl@71dc3d; nested exception is:
    java.lang.NullPointerException
    at com.netscape.server.ejb.EjbContext.createHomeRef(Unknown Source)
    at com.netscape.server.ejb.EjbContext.getHomeRef(Unknown Source)
    at com.netscape.server.ejb.EjbContext.lookup(Unknown Source)
    at com.netscape.server.jndi.RootContext.lookup(Unknown Source)
    at com.netscape.server.jndi.RootContext.lookup(Unknown Source)
    at javax.naming.InitialContext.lookup(InitialContext. java:357)
    at com.netscape.ejb.CorbaHomeFactoryImpl.ConstructEJBHome(Unknown Source
    at com.netscape.CosNaming.NamingContextImpl.resolve(Unknown Source)
    at org.omg.CosNaming._NamingContextImplBase.invoke(_N amingContextImplBas
    e.java:233)
    at com.sun.corba.ee.internal.corba.ServerDelegate.dis patch(ServerDelegat
    e.java:236)
    at com.sun.corba.ee.internal.iiop.ORB.process(ORB.jav a:227)
    at com.sun.corba.ee.internal.iiop.CachedWorkerThread. doWork(IIOPConnecti
    on.java:262)
    at com.sun.corba.ee.internal.iiop.CachedWorkerThread. run(IIOPConnection.
    java:230)
    My client program is:
    import java.util.*;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.rmi.PortableRemoteObject;
    public class MybeanClient {
    public static void main(String[] args) {
    try {
    Properties env = new Properties();
    env.put("java.naming.factory.initial","com.sun.jndi.cosnaming.CNCtxFactory");
    env.put("java.naming.provider.url", "iiop://localhost:9010");
    Context initial = new InitialContext(env);
    Object objref = initial.lookup("ejb/Mybean");
    MybeanHome home =(MybeanHome)PortableRemoteObject.narrow(objref,My beanHome.class);
    Mybean bean = home.create();
    String result = bean.test();
    System.out.println(result);
    } catch (Exception ex) {
    System.err.println("Caught an unexpected exception!");
    ex.printStackTrace();
    The j2eeguide.converter sample bundled with IPlanet works fine with the above code.
    The only difference is that the converter sample was deployed by the IAS deployment tool.
    Mybean was deployed by the Forte.
    What is the problem?
    Any help would be highly appreciated.

    1. Check that iiop is enabled in ias-ejb-jar.xml
    2. Check your naming in the xml files
    3. Check what has been deployed (filesystem & kregedit)
    4. Try it with the full qualified name ejb/'ejbfilename'/<ejb-name>

  • Direct DB access from Session Bean w/o using Serialized Objects

    I am developing a system where I am receiving some messages (data ) inside session bean and I want to log that data into data base �.i.e inserting that data in to various tables. I am not showing that data to client ( that is taken care by another application).
    So I am directly calling insert methods on various tables instead of going for serialized classes for each of that tables and calling setter methods. Is this approach correct? Or this will create nightmares when millions of messages are to be logged? Do I have to make serialized objects? Please post the suggestions ..Thank you in advance.
    If session bean is making direct inserts in the DB using Helper classes as shown below �is there any problem of concurrency?? Means multiple session bean instances inserting data in the same table using the helper class will create any problems?? I am using MySql db presently. Or all will work fine coz I am using the data source and pool available in welogic app server?
    Is this a good approach if my application is doing inserts 90% of times? or I have to use entity beans or serialized objects encapsulating each class?
    public class Logger implements SessionBean
    DAO dao = getDAO();
    dao.insertXyzLog(�x�, �y�,�.);
    private DAO getDAO(){
    if(Dao == null) {
    oao = DAOFactory.getDAO();
    return Dao;
    //other std methods
    public interface DAO {
    // methods to directly insert data in to the tables
    //some methods to look for required value in another tables
    public abstract void insertXyzLog (String x, Stringy, ���.);
    public class DAOImpl implements DAO {
    // look up for JNDI data sourse
    //method to return connection
    public void insertXyzLog (String x, Stirng y�){
    //SQLs for inserting into Xyz table using connection obtained above.

    Hi,
    Nothing wrong in using Helper class to insert into table. It won't create problem as long as your database server able to handle that many request from client.
    If you use weblogic server and datasource, the server will take care of all connection pool management depending upon your configuration parameters.
    Moreover, insert won't lock the table. So you need not worry about those things.
    Best Luck,
    Senthil Babu
    Developer Technical Support
    SUN Microsystems
    http://www.sun.com/developers/support/

  • Beginner needs help in order to expose session bean as WS

    Hello,
    I have a session bean with over 120 methods and I would like to expose all of these methods as a web service. I don't want to have to maintain the wsdl and endpoint interface by hand and would like to find a way to generate the wsdl and the endpoint interface with a tool rather by doing by hand. Can anyone tell me if that is possible and how to do it please? I have the jwsdp installed on my machine.
    Thanks in advance,
    Julien Martin.

    Well,JBuilder X has tools to help you do this!Just following the steps below:
    1 create a new project
    2 add your ejb to the project
    3 create a new web services designer
    4 import your ejb to the web services designer
    5 rebuild the project
    6 deploy the .ear file to your web services server

  • Problem accessing a session bean running on a different port

    Hi,
    I am using weblogic7.0 as the application server. I craeted two EJB's and
    deployed them in two ports, port 7001 and 7378. I can access the beans when I
    deploy them in the same port. But, I am having problem when EJB1 'server1' accesses
    EJB2 'server2' deployed in port 7378. Below is the code I am using to lookup the
    bean.
    Properties prop = new Properties();
    prop.put(Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.jndi.WLInitialContextFactory");
    prop.put(Context.PROVIDER_URL, "t3://localhost:7378");
    Context ctx = new InitialContext(prop);
    Object objref = ctx.lookup("java:comp/env/server2");
    System.out.println("Inside the Object method "+objref);
    iHome = (server2.InsertHome) objref;
    System.out.println("Inside the iHome method "+iHome);
    mInsert=iHome.create();
    I am getting the following exception when I run the client. Can any one plaes
    help me with the problem I am facing.
    Thanks,
    Ramya.
    java.rmi.RemoteException: EJB Exception: ; nested exception is:
    java.lang.NullPointerException
    Start server side stack trace:
    java.rmi.RemoteException: EJB Exception: ; nested exception is:
    java.lang.NullPointerException
    java.lang.NullPointerException
    at server1.ConnectBean.insertName(ConnectBean.java:133)
    at server1.ConnectBean_wtb7ta_EOImpl.insertName(ConnectBean_wtb7ta_EOIm
    pl.java:45)
    at server1.ConnectBean_wtb7ta_EOImpl_WLSkel.invoke(Unknown Source)
    at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:362)
    at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServer
    Ref.java:114)
    at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:313)
    at weblogic.security.service.SecurityServiceManager.runAs(SecurityServi
    ceManager.java:785)
    at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.ja
    va:308)
    at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteReques
    t.java:30)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
    End server side stack trace
    ; nested exception is:
    java.lang.NullPointerException:
    Start server side stack trace:
    java.lang.NullPointerException
    at server1.ConnectBean.insertName(ConnectBean.java:133)
    at server1.ConnectBean_wtb7ta_EOImpl.insertName(ConnectBean_wtb7ta_EOIm
    pl.java:45)
    at server1.ConnectBean_wtb7ta_EOImpl_WLSkel.invoke(Unknown Source)
    at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:362)
    at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServer
    Ref.java:114)
    at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:313)
    at weblogic.security.service.SecurityServiceManager.runAs(SecurityServi
    ceManager.java:785)
    at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.ja
    va:308)
    at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteReques
    t.java:30)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
    End server side stack trace
    at weblogic.rmi.internal.BasicOutboundRequest.sendReceive(BasicOutbound
    Request.java:109)
    at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemote
    Ref.java:262)
    at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemote
    Ref.java:229)
    at server1.ConnectBean_wtb7ta_EOImpl_WLStub.insertName(Unknown Source)
    at server1.Client.example(Client.java:156)
    at server1.Client.main(Client.java:168)
    Caused by: java.lang.NullPointerException:
    Start server side stack trace:
    java.lang.NullPointerException
    at server1.ConnectBean.insertName(ConnectBean.java:133)
    at server1.ConnectBean_wtb7ta_EOImpl.insertName(ConnectBean_wtb7ta_EOIm
    pl.java:45)
    at server1.ConnectBean_wtb7ta_EOImpl_WLSkel.invoke(Unknown Source)
    at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:362)
    at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServer
    Ref.java:114)
    at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:313)
    at weblogic.security.service.SecurityServiceManager.runAs(SecurityServi
    ceManager.java:785)
    at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.ja
    va:308)
    at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteReques
    t.java:30)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
    End server side stack trace

    So it looks like mInsert is null causing the NPE. I think you'll have
    to debug this one.
    -- Rob
    Ramya wrote:
    Hi Rob,
    Thanks for your relpy. Below is the method which calls methods from the EJB2.
    public void insertName(String name) throws Exception {
    Connection con = null;
    String name2="raj";
    int num=30;
    PreparedStatement ps = null;
    CallableStatement cs=null;
    String fName=null;
    try {
    System.out.println("In the insertName() before calling this.lookup()");
    this.lookUp();
    System.out.println("In the insertName() after calling this.lookup()");
    con=mInsert.getConnection();
    System.out.println("Inside the InsertName() in connectbean the value
    of connect is"+con);
    ps = con.prepareStatement("Insert into My_info values (?,?,?) ");
    ps.setString(1, name);
    ps.setString(2, "RamyaRAJ");
    ps.setInt(3,30);
    if (!(ps.executeUpdate() > 0)) {
    String error = "insertName: MyInfoBean (" + fName + ") not updated";
    throw new NoSuchEntityException (error);
    else{
    System.out.println("After calling execute upadte");
    } catch(Exception e) {
    System.out.println("There is an SQL insert exception in insertName()
    method");
    e.printStackTrace();
    throw new EJBException (e);
    } finally {
    mInsert.cleanup(con, ps);//LINE NO 133
    Line 133 (mInsert.cleanup(con, ps);) is the call to close up the SQL connection
    that is from EJB2. mInsert is the member variable of the Remote class from EJB2.
    Thanks,
    Ramya.
    Rob Woollen <[email protected]> wrote:
    That looks like a NullPointerException in your code. You'd have to show
    us line 133 of ConnectBean if you need help debugging it.
    -- Rob
    Ramya wrote:
    Hi,
    I am using weblogic7.0 as the application server. I craeted twoEJB's and
    deployed them in two ports, port 7001 and 7378. I can access the beanswhen I
    deploy them in the same port. But, I am having problem when EJB1 'server1'accesses
    EJB2 'server2' deployed in port 7378. Below is the code I am usingto lookup the
    bean.
    Properties prop = new Properties();
    prop.put(Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.jndi.WLInitialContextFactory");
    prop.put(Context.PROVIDER_URL, "t3://localhost:7378");
    Context ctx = new InitialContext(prop);
    Object objref = ctx.lookup("java:comp/env/server2");
    System.out.println("Inside the Object method "+objref);
    iHome = (server2.InsertHome) objref;
    System.out.println("Inside the iHome method "+iHome);
    mInsert=iHome.create();
    I am getting the following exception when I run the client. Can anyone plaes
    help me with the problem I am facing.
    Thanks,
    Ramya.
    java.rmi.RemoteException: EJB Exception: ; nested exception is:
    java.lang.NullPointerException
    Start server side stack trace:
    java.rmi.RemoteException: EJB Exception: ; nested exception is:
    java.lang.NullPointerException
    java.lang.NullPointerException
    at server1.ConnectBean.insertName(ConnectBean.java:133)
    at server1.ConnectBean_wtb7ta_EOImpl.insertName(ConnectBean_wtb7ta_EOIm
    pl.java:45)
    at server1.ConnectBean_wtb7ta_EOImpl_WLSkel.invoke(UnknownSource)
    at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:362)
    at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServer
    Ref.java:114)
    at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:313)
    at weblogic.security.service.SecurityServiceManager.runAs(SecurityServi
    ceManager.java:785)
    at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.ja
    va:308)
    at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteReques
    t.java:30)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
    End server side stack trace
    ; nested exception is:
    java.lang.NullPointerException:
    Start server side stack trace:
    java.lang.NullPointerException
    at server1.ConnectBean.insertName(ConnectBean.java:133)
    at server1.ConnectBean_wtb7ta_EOImpl.insertName(ConnectBean_wtb7ta_EOIm
    pl.java:45)
    at server1.ConnectBean_wtb7ta_EOImpl_WLSkel.invoke(UnknownSource)
    at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:362)
    at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServer
    Ref.java:114)
    at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:313)
    at weblogic.security.service.SecurityServiceManager.runAs(SecurityServi
    ceManager.java:785)
    at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.ja
    va:308)
    at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteReques
    t.java:30)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
    End server side stack trace
    at weblogic.rmi.internal.BasicOutboundRequest.sendReceive(BasicOutbound
    Request.java:109)
    at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemote
    Ref.java:262)
    at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemote
    Ref.java:229)
    at server1.ConnectBean_wtb7ta_EOImpl_WLStub.insertName(UnknownSource)
    at server1.Client.example(Client.java:156)
    at server1.Client.main(Client.java:168)
    Caused by: java.lang.NullPointerException:
    Start server side stack trace:
    java.lang.NullPointerException
    at server1.ConnectBean.insertName(ConnectBean.java:133)
    at server1.ConnectBean_wtb7ta_EOImpl.insertName(ConnectBean_wtb7ta_EOIm
    pl.java:45)
    at server1.ConnectBean_wtb7ta_EOImpl_WLSkel.invoke(UnknownSource)
    at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:362)
    at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServer
    Ref.java:114)
    at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:313)
    at weblogic.security.service.SecurityServiceManager.runAs(SecurityServi
    ceManager.java:785)
    at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.ja
    va:308)
    at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteReques
    t.java:30)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
    End server side stack trace

  • Error while calling local session bean from session facade

    Hi Everybody,
    I was to execute example of session facade pattern. All the files compile properly, but when ejbc command is run, i get the following error:
    ERROR: Error from ejbc:
         In EJB *MANAGER, method create() exposes local interface types or local home interface types through the remote home interface of the bean. This is not allowed.
    ERROR: Error from ejbc:
         In EJB *MANAGER, method remove(java.lang.Object) on the home interface does not throw java.rmi.RemoteException. This is a required exception.
         In EJB *MANAGER, method create() on the home interface does not throw java.rmi.RemoteException. This is a required exception.
    ERROR: Error from ejbc: In EJB MANAGER, the home interface be.telenet.sso.servicelayer.ebiz.ManagerHome must extend the javax.ejb.EJBHome interface.
    ERROR: ejbc found errors
    Thanks
    Amit

    If you are looking a local interface up through JNDI, try using the "java:comp/env" namespace. Also, if you post these questions here about EJB, say what vendor you are using because this stuff is pretty new and there will be differences/bugs/etc.

Maybe you are looking for

  • Adobe Acrobat 8 - file updates not installing on Win 7 Professional

    How do I install MSP file updates to Adobe Acrobat after downloading them? I have just installed Acrobat 8.0 from the original installation CD on a new PC running Windows 7 Professional (64 bit) and have downloaded the update to 8.1.0 to begin with,

  • Resolution problems when connecting an LCD to macbook

    Hi all, I've just bought a BenQ 20" wide screen LCD monitor (G2000WAD) to connect to my MacBook 13" (late 2008). I connected it with a VGA cable, converted to mini displayport. I can't seem to set it to the optimal resolution, which for this screen i

  • Open wifi in hotels

    Hi I have 2 playbooks that we're trying to use in a hotel. the problem we seem to have is this - the wifi is open and gives you access when you enter the code on the first web page you see - which is pushed at you byt the hotel servers. Problem is th

  • Text / Titles Get Cut Off After 3 Lines?

    I did some searching but couldn't find a discussion on this. When I add a Title of any kind and try to fill it with more words that fit on the screen (in vertical space) it just cuts them off at the bottom. I've attached an image that shows the third

  • I need help with my itunes account

    this is my son's account. He is autistic and somehow figured out how to use my card and purchase itunes I am freaking out because  just found out he has spent over 700 dollars on itunes.  I just lost my job and cant pay my mortgage because I dont hav