Skip navigation
Currently Being Moderated

Access local EJB3 on Glassfish

May 12, 2009 2:27 PM

I'm using Eclipse and have a combined Java/Flex project using WTP that uses BlazeDS and is deployed to a Glassfish server (v2ur2).  I was able to configure everything correctly to access simple routines with the remote access, but now I would like to access an EJB3 using the local interface.  I have another project in Eclipse that is an EJB Module and the Java/Flex project specifies that as a dependency. I can access an EJB from that project using a remote interface, but am having trouble figuring out how to access one with a local interface.

 

I saw another thread on the forum that referenced the EJB3 Factory available through the Adobe exchange so I downloaded that and added it to my project.  I defined the factory in services-config.xml and added a new destination in remoting-config.xml, but when I try to access the EJB, it gives me an "error accessing local resource..."

 

Is there something else I need to do?  Any pointers as to what might be going wrong?  I'm assuming that specifying the Java EE Module dependency for the EJB module should pull it in and make the local interface accessible.  Is that right?  If not, what else do I need to do?  I'm fairly new to all of this and still don't completely understand how everything in the Java/Flex project is being deployed.

 

Any help would be greatly appreciated!  Thanks!

 

Renee

 
Replies
  • Currently Being Moderated
    May 15, 2009 5:10 AM   in reply to drrevis

    I get the th same trouble, too. Is there anyone can give help? Any advice will be ok !

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 4, 2009 5:12 AM   in reply to drrevis

    Renee,

     

    I spend about 3 full days to figure out how to make this work. I eventually come to your solution, which is very nice. I would just like to add a detail: you do not need to publish the JNDI name of your EJB in the sun-ejb-jar.xml, neither in the EJB annotations. The only thing you have to make sure is to use the exact EJB class name in the web.xml file -- and both modules have to be deployed in the same enterprise application (ear).

     

    So, to make a quick summary of the specific things to do (this is not a complete procedure) :

         1. Create the Flex+BlazeDS combined app (or, if you want a cleaner project structure, make two separate apps : one Flex and one web app, and configure them correctly -- but this doesn't change anything to the following).

              - Add the EJB3 Factory library (.jar) from Adobe in the WebContent/WEB-INF/lib folder

              - Configure the services-config.xml to declare this factory (see help)

         2. Create the EJB module

              - Create your bean class and its local interface

              - In the bean class, do only use a basic "@Stateless" annotation, do not specify attribute in this annotation (e.g. the name of the bean or its JNDI address)

         3. Configure the remoting-config.xml file to map a destination to your EJB through its local interface (and not the remote one)

              - First, create a local reference from the web app to the EJB class:

                   <ejb-local-ref>

                        <!-- Exact name of the EJB class, or the name specified in @Stateless(name="xxx") - by default, the name attribute of the tag is the name of the EJB class -->

                        <ejb-ref-name>HelloServiceBean</ejb-ref-name>

                        <!-- Qualified name of the local interface of the EJB -->

                        <local>org.sandbox.IHelloServiceLocal</local>

                   </ejb-local-ref>

              - In the remotings-config.xml of the Flex/Web app, use the GlassFish local JNDI reference to this ref-name (e.g. prefix its name with "java:comp/env"):

                   <destination id="HelloService">

                        <properties>

                             <factory>ejb3</factory>

                             <source>java:comp/env/HelloServiceBean</source>

                        </properties>

                   </destination>

         4. Create the enterprise application containing both apps (flex/blazeds + ejb module)

     

    And that's all ! Deploy all this stuff to your server, and browse to your Flex app and call the EJB through a RemoteObject.

     

     

    Hope this helps. If interested, I may post on my (old) blog a full procedure to configure this example in Eclipse.

     

    Fred.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 30, 2010 6:52 AM   in reply to Avangel

    Can you post the details on your blog ?

    Thanks

     
    |
    Mark as:
  • Currently Being Moderated
    May 3, 2010 7:16 PM   in reply to drrevis

    Hi,

     

    I'm trying to user BlazeDS + EJB + Glassfish + Flex

     

    But I'm getting the following error message:

     

    INFO: [BlazeDS]Cannot create class of type
    'br.com.provas.dto.AlunoDTO'.
    flex.messaging.MessageException: Cannot create class of type
    'br.com.provas.dto.AlunoDTO'. Type 'br.com.provas.dto.AlunoDTO' not
    found.
            at flex.messaging.util.ClassUtil.createClass(ClassUtil.java:
    66)

     

    Is there any problem to transfer send to backend a mapped object?

     

    Regards,

     

    Waldir

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points