@EJB annotation

Hi!
I've been testing OC4J11g and I have some doubts about @EJB annotation. How can I get a session bean instance with @EJB annotation in backing bean? I've tried to do this in a servlet and it worked fine. But when I try to do this in a backing bean I get a NullPointerException because the instance of the session bean is null. Is it possible to use dependency injection in a backing bean? Do I have to configure any descriptor?
Thanks
Gleber

Gosh this one is old but just in case you check back :\).
EJB Annotation can be used in a managed class, such as a entity bean but I dont beleive you can do this from within a Java application, backing bean or non managed class.
The easiest way to get the code for connecting from a Java client or remote client is to right click on a bean and generate a test client and have a look at the main code. Basically the objects that are managed are all stored in JNDI tree on the app server. A lookup on the JNDI is all that is needed and you can use your bean.
Hope this helps, the part that bugs me is that the annotation just returns a null and the error you get doesnt indicate a naming failure or anything, in fact its no error until you go to access the null object.
Hope this helps.
John

Similar Messages

  • @EJB annotation for injection and lazy relations

    Hi,
    I develop a ejb3/jsf application.
    I have lazy relations in my entity beans.
    I remark that in my managed bean of my JSF, if I use @EJB annotation to inject session bean, I have no problem on lazy on entity beans returned by this session bean.
    Example
    JsfManageBean{
    @EJB
    Bean sessionBean ...
    public void doSomething(){
    Department d = sessionBean.findDepartmentBy...
    // relation lazy
    d.getEmployees()
    -> Load of employees -> NO LAZY PROBLEM !
    Someone can explain me why it works ?
    For me, after the find method, my session is closed !
    If I do a lookup to find my session bean (and so no injection @EJB here) -> I HAVE THE LAZY PROBLEM !
    public void doSomething(){
    SessionBean = ... context.lookup("blablabla")
    Department d = sessionBean.findDepartmentBy...
    // relation lazy
    d.getEmployee()
    -> LAZY EXCEPTION
    thanks for help !

    Nobody please ?

  • Why do we need the @EJB annotation at the class level?

    Why do we need the @EJB annotation at the class level?
    Eg: Why do we need the first piece of code, when the second code seems much simpler .
    *1.*
    @Stateful
    @EJB(name="ejb/TradeLocalNm",
    beanInterface=TradeLocal.class)
    public class TradeClientBean implements TradeClientRemote {
    *2.*
    @Stateful
    public class TradeClientBean implements TradeClientRemote {
    @EJB private TradeLocal trd;
    }

    I think it is possible to do it in an aggregated level however you need to define your distribution rules in order to get the desired result, you need also to consider that if distribution rules changes and the value after promotional planning returns the same value, it is possible that detailed level are not realigned to the new distribution rule (e.g. regarding another ratio).
    Maybe this is one of several causes.
    Regards,
    Carlos

  • @EJB annotation in JSF managed beans not working

    Hi all,
    I've been trying to get the @EJB annotation to work in a JSF manged bean without success.
    The EJB interface is extremely simple:
    package model;
    import javax.ejb.Local;
    @Local
    public interface myEJBLocal {
    String getHelloWorld();
    void setHelloWorld(String helloWorld);
    and the bean code is simply:
    package model;
    import javax.ejb.Stateless;
    @Stateless
    public class myEJBBean implements myEJBLocal {
    public String helloWorld;
    public myEJBBean() {
    setHelloWorld("Hello World from myEJBBean!");
    public String getHelloWorld() {
    return helloWorld;
    public void setHelloWorld(String helloWorld) {
    this.helloWorld = helloWorld;
    When I try to use the above EJB in a managed bean, I only get a NullPointerException when oc4j tries to instantiate my managed bean. The managed bean looks like:
    package view.backing;
    import javax.ejb.EJB;
    import model.myEJBLocal;
    import model.myEJBBean;
    public class Hello {
    @EJB
    private static myEJBLocal myBean;
    private String helloWorld;
    private String helloWorldFromBean;
    public Hello() {
    helloWorld = "Hello from view.backing.Hello!";
    helloWorldFromBean = myBean.getHelloWorld();
    public String getHelloWorld() {
    return helloWorld;
    public void setHelloWorld(String helloWorld) {
    this.helloWorld = helloWorld;
    public String getHelloWorldFromBean() {
    return helloWorldFromBean;
    Am I missing something fundamentally here? Aren't you supposed to be able to use an EJB from a JSF managed bean?
    Thanks,
    Erik

    Well, the more I research this issue, the more confused I get. There have been a couple of threads discussing this already, and in this one Debu Panda states that:
    "Support of injection in JSF managed bean is part of JSF 1.1 and OC4J 10.1.3.1 does not support JSF 1.1"
    10.1.3.1 Looking up a session EJB with DI from the Web tier
    But if you look in the release notes for Oracle Application Server 10g R3, it is explicitly stated that JSF 1.1. is supported. So I'm not sure what to believe.
    I've also tried changing the version in web.xml as described here:
    http://forums.java.net/jive/thread.jspa?threadID=2117
    but that didn't help either.
    I've filed a SR on Metalink for this, but haven't got any response yet.
    Regards,
    Erik

  • EJB annotation does not work but lookup does

    Hello, I am developing an application which has two modules: an EJB module and a WEB module. As I am using EJB 3 I would like to call the EJBs from the web module using the @EJB annotation.
    For example:
        @EJB(name = "GestioDeLlocsEJB")
        private GestioDeLlocsRemote gestioDeLlocs;
        public Collection<Lloc> getLlocs() {
            return gestioDeLlocs.findAllLlocs();
        }The problem is that the JEE container injects a null in the Remote interface ( gestioDeLlocs ) so it seems to fail when trying to match the name and the JNDI reference.
    I have added the following lines in sun-web.xml:
      <ejb-ref>
        <ejb-ref-name>GestioDeLlocsEJB</ejb-ref-name>
        <jndi-name>es.ajuntament.palma.drogues.servei.GestioDeLlocsRemote</jndi-name>
      </ejb-ref>And I have added some lines in web.xml too:
       <ejb-ref>
            <ejb-ref-name>GestioDeLlocsEJB</ejb-ref-name>
            <ejb-ref-type>Session</ejb-ref-type>
            <remote>es.ajuntament.palma.drogues.servei.GestioDeLlocsRemote</remote>
        </ejb-ref>I can test the EJBs by using the traditional lookup method:
    Context c = new InitialContext();
    return (GestioDeLlocsRemote) c.lookup("es.ajuntament.palma.drogues.servei.GestioDeLlocsRemote");But I would like to use the @EJB annotation which seems not to work.
    What am I doing wrong?

    What kind of class are you putting the annotation on? Only certain managed classes like servlet classes,
    JSF managed beans, etc. support Java EE environment annotations. If it's a plain POJO the annotations
    will be ignored.

  • Difference between com.sap.ejb.annotations.AppStartup and @PostConstruct

    Hi developers,
    In NW 7.3 we have two EJB annotations with identical meaning:
    javax.annotation.PostConstruct
    and
    com.sap.ejb.annotations.AppStartup
    A method annotated like this is invoked by the container right before the EJB is made available to clients.
    Can anyone explain the difference between the two annotations?
    Thanks, regards
    Vincenzo

    Hi
    PostConstruct = EJB standard, AppStartup = SAP proprietary.
    As far as I understand the descriptions, the AppStartup callback invocation occur for all EJBs immediately when the application is starting (no matter if the EJB is called or not) whereas "The PostConstruct callback invocations occur before the first business method invocation on the bean. This is at a point after which any dependency injection has been performed by the container." (see EJB spec).
    So the PostConstruct has nothing to do with application life cycle but with the lifecycle of a single bean instance. PostConstruct may be called later on first client invocation) and in AppStartup, you probably do not have dependency injection performed but have to lookup using java:comp/env.
    Regards
    Rolf

  • @EJB annotation doesn't work

    Hello all,
    I'm new to EJB3. I use the annotation @EJB for my private fields in my stateless beans.
    Could someone tell me in which cases this annotation wouldn't work?
    Actually I use it in many places, but in one place it doesn't work and the declared object is null... and I don't really understand why...
    many thanks.

    Hello, and thanks for your answer.
    ok,
    so here is where I try to call my EJB:
    package servicesFacades;
    import java.util.Collection;
    import javax.ejb.EJB;
    import javax.ejb.Stateless;
    import javax.naming.InitialContext;
    import services.cyberProcedureServices.CpaManifInterface;
    import util.exception.ManifException;
    import models.beans.File;
    import models.objects.CpaManifBean;
    @Stateless
    public class BdCitizenServicesImpl implements BdCitizenServices {
         // All the services this class provides pass through this cyber procedure manager.
         //@EJB
         private CpaManifInterface cpaEventManager;
         public Collection<CpaManifBean> getEventsCp(String userName)
              System.out.println("YOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO, on est dans citizenServices Man!");
              getEventManager();
              try{
              return cpaEventManager.getListeCpaManifParCitoyen(userName);
              }catch (Exception ex){
                   System.out.println("Exception saisie dans citizenService" + ex);
                   return null;
         }and here is my EJB declaration:
    package services.cyberProcedureServices;
    import java.util.*;
    import javax.ejb.EJB;
    import javax.ejb.Stateless;
    import javax.jms.*;
    import javax.jms.Queue;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
    import org.acegisecurity.context.SecurityContextHolder;
    import org.acegisecurity.userdetails.UserDetails;
    import dao.cyberProcedure.CyberProcedureDao;
    import dao.event.EventDao;
    import services.MnfSgdiInterface;
    import services.messageServices.MnfMessageCpaInterface;
    import services.payementServices.MnfPaymentInterface;
    import services.payementServices.MnfPaymentManager;
    import services.streetsClosingServices.MnfFermetureRueInterface;
    import services.streetsClosingServices.MnfFermetureRueManager;
    import services.eventServices.MnfManifestationInterface;
    import services.fireWorksServices.MnfFeuArtificeInterface;
    import services.fireWorksServices.MnfFeuArtificeManager;
    import services.personsServices.MnfPersonneInterface;
    import models.*;
    import models.beans.*;
    import models.objects.*;
    import util.exception.ManifException;
    @Stateless
    //@SecurityDomain("manif")
    public class CpaManifManager implements CpaManifInterface {
    //     @EJB
    //     private MnfPersonneManager personneMgr;
         @PersistenceContext
         protected EntityManager em;
         @EJB
         private CyberProcedureDao cpDao;
         // used to get the role
         //@EJB private SessionContext ctx;
    ....

  • Calling SessionBean through @EJB Annotation

    Hello All
    I was a fan of J2EE but now have just started working on JavaEE after hearing so much about it. I read a lot of tutorials and now i am using NetBeans IDE 5.5 and the application server is JBoss.
    My application scenario is:
    1. Stateless Session Bean
    2. Business Interface (Remote)
    3. Client
    Code for Stateless Session Bean
    package com.testing;
    import javax.ejb.*;
    import javax.annotation.*;
    @Remote({HelloRemote.class})
    @Stateless
    public class HelloBean implements com.testing.HelloRemote {
    public String helloWorld()
            String value = "hello there";
            return value;
    }Code for Remote Business Interface:
    package com.testing;
    import javax.ejb.Remote;
    * This is the business interface for Hello enterprise bean.
    @Remote
    public interface HelloRemote {
        public String helloWorld();
    }Finally code for Client:
    package enterpriseapplication3;
    import java.io.*;
    import java.util.*;
    import javax.ejb.EJB;
    import javax.ejb.*;
    import javax.naming.*;
    import java.rmi.*;
    import com.testing.*;
    public class Main {
        public Main()
         @EJB static private com.testing.HelloRemote hello;
        public void call()
            try
                 String value = hello.helloWorld();
                 System.out.println(value);
            catch(Exception e)
                e.printStackTrace();
         * @param args the command line arguments
        public static void main(String[] args) throws Exception
            Main main = new Main();
            main.call();
    }The problem is when i run my application i get:
    java.lang.NullPointerException
            at enterpriseapplication3.Main.call(Main.java:42)
            at enterpriseapplication3.Main.main(Main.java:57)Please help me out with this issue as I cannot resolve it even though I have tried so many different tutorials but no luck.
    best regards
    rabbia

    You'll need to check the JBoss documentation to see how to invoke the client application.
    This kind of client is referred to as an Application Client. In order for the injection to work
    there must be some special system code provided by your vendor that initializes the client
    app. In the Java EE SDK, it's called the "appclient" command.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • EJB annotations are not documented , versus Hibernate and JBoss seam do

    I have an application that contains EJB3 annotations, Hibernate Annotations and JBoss Seam annotations in the java code.
    When I generate the javadoc, the Hibernate and JBoss Seam annotations show by the side of the members and methods who has them, like, for example
    @Name(value="authenticator")
    @Scope(value=SESSION)
    @AutoCreate
    public class AuthenticatorImpl
    <dt>extends java.lang.Object </dt><dt>implements </dt>
    or, another example,
    h3. facesContext{noformat}@In(value="org.jboss.seam.faces.facesContext",
    create=true)
    private javax.faces.context.FacesContext facesContext{noformat}
    However, none of the EJB3 annotations included in the code are being dieplayed in the javadocs.
    Does someone knows if there is any reason why this should happen?
    This is my javadoc command:
    javadoc -version -d doc2 -sourcepath src\model;src\action -classpath "lib/core.jar;lib/jboss-embedded-api.jar;lib/jsr250-api.jar;classes/test;lib/hibernate.jar;lib/log4j.jar;lib/testng.jar;lib/ojdbc14.jar;lib/hibernate-commons-annotations.jar;lib/hibernate-search.jar;lib/hibernate-entitymanager.jar;lib/drools-compiler.jar;lib/richfaces-impl.jar;lib/jboss-cache.jar;lib/jboss-seam.jar;lib/janino.jar;lib/hibernate-annotations.jar;lib/richfaces-api.jar;lib/ejb-api.jar;lib/mvel14.jar;lib/jbosssx.jar;bootstrap;lib/jbpm-jpdl.jar;lib/commons-beanutils.jar;lib/lucene-core.jar;lib/jgroups.jar;lib/jsf-api.jar;lib/jboss-el.jar;lib/el-api.jar;lib/antlr-runtime.jar;lib/jstl.jar;classes/model;lib/antlr.jar;lib/persistence-api.jar;lib/jsf-facelets.jar;classes/action;lib/richfaces-ui.jar;lib/mail.jar;lib/drools-core.jar;lib/jboss-seam-debug.jar;lib/hibernate-validator.jar;lib/servlet-api.jar;lib/jta.jar" -private mil.navy.med.rota.model mil.navy.med.rota.security mil.navy.med.rota.action.util mil.navy.med.rota.action.util.mpd mil.navy.med.rota.action.mpd mil.navy.med.rota.action.referrals mil.navy.med.rota.model.referrals mil.navy.med.rota.action.trainman mil.navy.med.rota.model.trainman -use -version -author -splitindex
    The version of javadoc used is
    Standard Doclet 1.6.0.0_3
    Aticipated thanks!

    Nevermind, the issue was that my persistence.xml did not contain the following property:
    <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
    Therefore, the tables were not being created upon deployment.
    Still, I would expect to see entity beans listed in the WebLogic console.

  • @EJB annotation in entity bean does not work

    I just started with ejb3. I have created a couple of beans. One session bean that looks like this:
    @Stateless
    public class MySessionBean implements MySession
         @Resource(name="jdbc/mydb")
         private DataSource myDB;
    public void someMethod() {
    myDB.getConnection()
    This works great. The other bean is an entity bean, and there the resource injection doesn't work. It looks like this:
    @Entity
    public class MyEntityBean
    @Resource(name="jdbc/mydb")
         private DataSource myDB;
    public void someMethod() {
    myDB.getConnection()
    Is resource injection any different in an entity bean then in a session bean? Both beans belong to the same package and are in the same application, (ear). I have exactly the same problem with @EJB injection: it works fine in the session bean but not in the entity bean...
    Any help is appreciated...
    John

    <code>
    @Entity
    @Table(name = "assetfault")
    @NamedQueries( {@NamedQuery(name = ... )})
    public class Assetfault implements Serializable {
    @javax.ejb.EJB private com.novadent.data.assetmg.sessionbeans.AssetFacadeLocal aF;
    @javax.ejb.EJB private com.novadent.data.assetmg.sessionbeans.AssetfaultFacadeLocal afF;
    </code>
    importing javax.ejb.EJB ?

  • Calling BRM from UDF using JNDI lookup with @EJB annotation

    Hi Experts
    I am trying to implement a UDF to invoke my BRM Rules set via JNDI Lookup instead of a SOAP Channel lookup.
    I have had a look at the following links/docs:
    Calling BRM from UDF using Public API
    http://www.gleanster.com/system/resources/W1siZiIsIjIwMTIvMDgvMDcvMjAvNDcvNTAvNDMvVGhpbmdzX1lvdV9TaG91bGRfS25vd19hYm91dF9TQVBfTmV0V2VhdmVyX0JSTS5wZGYiXV0/Things%20You%20Should%20Know%20about%20SAP%20NetWeaver%20BRM.pdf
    For item 1 above, the example looks really good, but it doesnt explain how I get access to the following required imports from my UDF:
    import com.sap.brms.qrules.ejb.*;
    import com.sap.brms.qrules.engine.AbstractProject;
    import com.sap.brms.qrules.engine.RuleEngine;
    import com.sap.brms.qrules.engine.RulesetContext;
    import javax.ejb.EJB;
    The second document is really good as well, but I could not figure out how to get it to work from my UDF.
    So, can anyone help me to understand specifically what is required to get this to work?
    Is is possible to invoke the rule set from my UDF?
    How do I give my UDF access to all the required jars/imports?
    I have manage to create a new DC (Development Component) with a public part and this enables me to get my code to compile on my local PC but I am not able to activate it due to the server not having access to the same java packages as my local copy.
    Any help would be greatly appreciated.

    You resolve the dependency by importing the required jars with using the dependency tab for the mapping program.
    As stipulated before, I have managed to resolve the dependency issue but I have now getting the same error as in the forum: Calling BRM from UDF using Public API
    The specific error is:
    com.sap.engine.services.cross.PortableRemoteObjectContainer.narrow(PortableRemoteObjectContainer.java:238)
    Has anyome manage to get invoke a BRM Ruleset using JNDI?

  • @EJB annotation usage question.

    (excuse the repost, it was suggested I change the topic title)
    bear with me here. . . I am new!
    What I am trying to do is get a list of JDBC connection pools configured on an AppServer 9 installation.
    I created and successfully deployed a Session Bean (not even sure if this code will do what I want, but I will cross that bridge when I get there)
    ===============package com.ismsi.isms.ejb.login;
    import javax.ejb.*;
    import javax.naming.*;
    import java.util.Vector;
    @Stateless()
    public class LoginBean implements com.ismsi.isms.ejb.login.LoginRemote {
        public String[] getNamedConnection() throws NamingException {
            InitialContext ic =  new InitialContext();
            Vector<String> v = new Vector<String>();
            for(NamingEnumeration names = ic.list("java:comp/env/jdbc"); names.hasMore();)
                v.add( ((NameClassPair) names.next()).getName());
            return v.toArray(new String[v.size()]);
    ===============
    but I can't figure out how to connect to it.
    here is my client app:
    ===============package ismsClient;
    import com.ismsi.isms.ejb.login.LoginRemote;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.rmi.PortableRemoteObject;
    import java.util.*;
    import javax.ejb.EJB;
    public class LoginClient {
        public LoginClient() {
        @EJB
        private static LoginRemote login;
        public static void main(String[] args) {
           LoginClient client = new LoginClient();
           client.ListConnectionNames();
        public void ListConnectionNames(){
            try
      // *********** Here is the problem. . .  
              String[] s = login.getNamedConnection();
                for(int i = 0; i <s.length;i++ )
                    System.out.println(s);
    }catch (Exception ex) {
    System.err.println("Caught an unexpected exception!");
    ex.printStackTrace();
    }Why is login unassigned in LoginClient.ListConnectionNames?
    I thought the @EJB would do all the initialization/construction/InitialContext stuff for me.
    Please help a delphi/.netter come to the dark/light side :)
    cheers

    OK, now at this point you are either saying: "feck feck feck, that's
    obvious, I'll deploy the client to the app server and try again"
    OR "Yeah, I know that" That's a negatory on both counts, big bear.
    in which case you will want to have a look at
    a simple example and try building it yourself... Thanks for the link. I was googling on 'client +@EJB' and various other combinations, could only find stuff on previous version of EE. a cursory glance at your link appears it will clear some things up.
    So, the client app needs the full code jar that contains the session class as well???
    Forgive me for thinking .Net, but let me explain how I do things in .Net Remoting.
    In .Net, I compile a common assembly with an interface
    A server assembly is built with a class that provides implementation,
    A client assembly is built that activates from the remoting subsystem an object implementing the common interface.
    The client interface knows nothing about the internals of the server object, nor would I think it should have to. In .Net, i have an XML configuration file that specifies the URI from which to activate the object.
    So to answer your question - how is the app server to perform the injection? I don't know. . . thats what had me confused. . . I assumed that it would look for the interface implemenation on a local appserver if found. I also assumed that there would be an analogue to the Net configuration, in which I could specify a remote app server.
    On the other hand, I am getting more keywords to google on. . . 'injection' 'EAR'
    uh-oh. . . combining that with '+java +bean' will probably get me dozens of pediatric links dealing with toddlers putting coffee beans in their autic canals. . .
    thanks for the link!
    cheers
    bas

  • Annotations to replace ejb-jar.xml?

    Hi gurus,
      Seems that the newest NWDS7.1 does not create ejb-jar.xml for EJB project. And I was told that currently all what we can do in ejb-jar.xml can be done with annotations right now. But where can I find available annotation list? Particularly I need the annotation to get environment entry from JNDI, which can be done using ejb-jar.xml before. 
      Thanks in advance.
    B.R.

    Hi Lee,
    You can find all EJB annotations in the EJB 3.0 Simplified API spec and EJB 3.0 Persistence (JPA) spec.
    The NWDS also gives you tips as to the available annotations from the context menus of different nodes, e.g. in the Outline view, Java editor, etc.
    Last but not least, you can find pieces of annotation reference in the various subnodes of the [online help|http://help.sap.com/saphelp_nwce10/helpdata/en/44/e9af22b9dc03fde10000000a1553f6/frameset.htm].
    Particularly, you should be using @Resource for injecting env entry.
    HTH!
    \-- Vladimir

  • Calling EJB 3.0 Stateless Session Bean

    Dear all,
    I created a stateless session bean with a hello world method on it. Now i want to call the method from a BeanDecorator class, through a getter metod. When i use the jndi lookup in my getter, i can call the helloWorld method without a problem. However, when i dont use the jndi lookup, and only use the @EJB annotation, i always get a nullpointer.
    This is working:
    InitialContext ic = new InitialContext();
                   test = (TestLocal)ic.lookup("test.be/ear~bd/LOCAL/TestBean/"+TestLocal.class.getName());
                   test.helloWorld()
    This gives nullpointer:
    @EJB
    private TestLocal test;
    test.helloWorld();
    What is the correct way to consume session beans without having to explicitly code the jndi lookup?
    Kind regards.

    Hi,
    any annotation like this can be used only in "managed classes" like Session Beans, Servlets etc. Managed classes are those classes managed by the J2EE server. Managed here means, lifetime controlled by server.
    You can find this in J2EE specification.
    Frank

  • EJB 3.0 - Communicate an Applet with a Session Bean

    Hello
    I'm developing an EJB 3.0 app (eclipse and glassfish tools bundle), and I have an applet that has to use remote session beans.
    QUESTION: Is it possible for the applet to connect to EJB?
    QUESTION: By creating a J2EE application client project, can I use @EJB annotations to inject the session bean directly to the applet, avoiding the JNDI lookup?
    (since I imagine that the anwser to the second one is NO, I do the following consideration)
    Given an application client project, I imagine that this application can run remotely on a client machine/JRE. Then this application can use Annotations/injection facilities whenever it runs on a J2EE client container (which I assume consists of a set of libraries provided by the application server vendor, Glassfish in that case). Could this application be deployed using Java Web Start? If so, why can't it be deployed as an applet? (both options run in a client JRE, don't they?).
    QUESTION: In either case (applet or JWS), how do I have to package the JAR file (using Eclipse) so that it contains the needed libraries for accessing the EJB? Which are those libraries?
    At the time being, I'm trying to implement a sample application that follows the "Applet doing JNDI lookup" approach. I have:
    - an EAR project
    - an EJB project (containing an Entity Bean and a Stateless Session Bean with a @Remote interface)
    @Remote
    public interface HelloRemote {
         public String hello(String name);
    @Stateless
    public class Hello implements HelloRemote {
         @Override
         public String hello(String name) {
              return "Hello "+name+"!!";
    }- an Application Client project (containing the applet code):
    public class ClientApplet extends JApplet {
         public void init(){     
              try {
                   Context jndiContext = getInitialContext( );
                   HelloRemote server = (HelloRemote) jndiContext.lookup(HelloRemote.class.getName());
                   setContentPane(new JLabel(server.hello("Gerard")));
              } catch (NamingException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
         private Context getInitialContext() throws NamingException{
              Properties props = new Properties();
              props.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
              props.setProperty("org.omg.CORBA.ORBInitialHost", "myhost");
              props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
              return new InitialContext(props);
    }- a static web project (with a sample web page that contains the applet object the corresponding applet JAR file)
    I tried to export the Application Client project as an "application client JAR", in the hope that the java EE libraries bundled with glassfish (listed as libraries of this project) would be packaged too.
    No success, so now I'll try to copy all the JAR files (one by one) into the +\WebContent\+ folder of the Web Project, and add references to each of them in the archive="" attribute of the +<applet>+ HTML tag. Although this might work, I suspect that I am missing the good/easy way of doing it. Any suggestions?
    Thanks in advance,
    Gerard
    Edited by: gsoldevila on May 6, 2009 7:09 AM

    An Applet can communicate with an EJB via JNDI lookup but I would (personally) use an intermediate Servlet to handle this. Client to Servlet communication is http whereas to ejb is iiop - which might be blocked.
    Injection only works in managed classes (EJB, Servlet, Listeners..) and an Application Client main class. So yes you could use an app client for handling resource injection.
    m

Maybe you are looking for

  • Material usage change

    Hello everyone, I have to change a purchase order, the material usage is wrong, but this field is not able to change. This purchase order is released, is it because of that? If so, is there another way to change the material usage? Thanks in Advance

  • Sga_max_size & memory_max_target

    Hi All, Could you please tell me ... In oracle 11.1 If I want to set Memory Parameter alter system set memory_max_target=2000M scope=spfile; alter system set memory_target=2000M scope=spfile; Do I need to set sga_max_size value ? or it will set autom

  • NCHAR in Oracle 9i

    Hi, I'm using Oracle 9i and implementing internationalization for my application. On the oracle site, it says that Oracle 9i supports NCHAR which is an unicode datatype exclusively. But i found that VARCHAR2 also stores unicode characters perfectly.

  • Workstation Clients through a Firewall

    Does anyone out there know if there are any issues with workstation clients going through a firewall? Thanks! mervin

  • Best way to completely erase my SSD disk and make fresh install of MacOSX?

    I want a brand new OSX installatetion. What is the best way to completely erase my SSD (to make it brand new) and reinstall MAC OSX (i can use internet WPA secure Wi-Fi to reinstall MACOSX Lion). On macbook air late 2011.