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!
Well I'm sorry you're having trouble too, but I'm glad to hear it's not just me :-)!
I did realize that I needed to create an EAR project and then I included both the Flex/Java war module and the EJB module in that project. I hoped that would solve the problem since the modules are then certainly operating within the same application, but it didn't.
I also saw another post that mentioned the EJB3 factory and it said that it only works with Flex2. I'm not sure why that would be, but I thought I would play around with the source code for that to see if I could figure anything out. Just haven't had a chance to do that yet.
If anyone has any pointers or suggestions as to what might be the problem, it would be most appreciated!
Ok, so I finally got this to work. Thought I would post in case it might help someone else.
I have an EAR project that includes both my Java/Flex project and the EJB module project.
In the sun-ejb-jar.xml of the EJB module project I have:
In the web.xml file of the Java/Flex project, I have:
I think one of the key issues for me was that by default, the version of web.xml that was created in the project didn't correspond to Servlet 2.5. I had to change the <web-app> reference to:
In the services-config.xml file I have:
<factory id="ejb3" class="com.adobe.ac.ejb.EJB3Factory" />
I ended up putting the source code for the EJB factory into another project and pulling that into the EAR project, but at this point, I think it would work even if I just included and referenced the given .jar file because I don't think I made any actual changes to the EJB factory code.
Then in remoting-config.xml, I have:
From there, I can reference myEJBDestination from my mxml files and access the methods of the bean. Finally!!! Hope this helps someone else.
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:
<!-- 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 -->
<!-- Qualified name of the local interface of the EJB -->
- 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"):
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.
I'm trying to user BlazeDS + EJB + Glassfish + Flex
But I'm getting the following error message:
INFO: [BlazeDS]Cannot create class of type
flex.messaging.MessageException: Cannot create class of type
'br.com.provas.dto.AlunoDTO'. Type 'br.com.provas.dto.AlunoDTO' not
Is there any problem to transfer send to backend a mapped object?
Europe, Middle East and Africa