0
votes

The task is to try to connect directly to a stateless EJB deployed on Glassfish. I have already done this via Web Service and I can also connect to the EJB by calling a remote java object which uses JNDI to find and load the bean. What I cannot do is directly connect to the EJB with Blazeds. I am using EBJ3Factory BY Ryan Norris (downloaded from adobe site) as follows;

My WEB-INF/flex/services-config.xml has;

<factories>
    <factory id="ejb3" class="com.adobe.ac.ejb.EJB3Factory" />
</factories>

My WEB-INF/flex/remoting-config.xml has;

<destination id="MyEJB">
    <properties>
        <factory>ejb3</factory>
        <source>java:global/Together/PSearch!ejb.PSearch</source>  
    </properties>
</destination>

I have a simple java class that can access the bean so I can use Blazeds to call the class which then calls the bean;

public void getBean() {

    PSearch search;

    InitialContext ctx;
    try {
        ctx = new InitialContext();         

        search = (PSearch) ctx.lookup("java:global/Together/PSearch!ejb.PSearch");
        System.out.println("jndi okay");

    } catch (NamingException e2) {
        // TODO Auto-generated catch block
        e2.printStackTrace();
    }
}

The asadmin command for the context in glassfish shows me;

./asadmin list-jndi-entries --context java:global/Together

PSearch__3_x_Internal_RemoteBusinessHome__: javax.naming.Reference
PSearch!ejb.PSearchRemote: javax.naming.Reference
PSearch!ejb.PSearch: com.sun.ejb.containers.JavaGlobalJndiNamingObjectProxy
PSearch!ejb.PSearchLocal: com.sun.ejb.containers.JavaGlobalJndiNamingObjectProxy

Yet when I use Eclipse / Flash Builder to try to Import a BlazeDS service I get an introspection error;

java:global/Together/PSearch/!ejb.PSearch is not available in the specified location

I have also tried changing the remoting-config.xml to point to local and remote interfaces but no joy!

Any pointers would be greatly appreciated.

1

1 Answers

0
votes

One workaround you could do would be to remove the factory XML element, replace the source JNDI name with the EJB fully qualified class name and create the service with Flash Builder using the BlazeDS RTS service as you tried to do.

<destination id="MyEJB">
    <properties>            
        <source>packagename.EJBClassName</source>  
    </properties>
</destination>

When you are done making the service client, service and the value objects(return type etc) in your Flex project then put everything back as they were:

<destination id="MyEJB">
    <properties>
        <factory>ejb3</factory>
        <source>java:global/Together/PSearch!ejb.PSearch</source>  
    </properties>
</destination>

What u r going to do actually is to treat the EJB 3.x as a normal POJO for the introspection in order to create the AS3 classes and when u r done change the destination to an EJB3 destination by using the factory.

I am working on a way to make this steps unnecessary. If I have time to finish it I will let you know.