I am trying to create an EJB 3.0 Data Control on top of remote deployed EJB. Difficulty is that I have no control over the EJB, and all I've been given is a Client jar file containing the remote interface and the entities used in the interface. When looking up the EJB using JNDI this is enough, so I was assuming it would also be enough to create a EJB Data Control, but it seems not.
I've searched a lot of blogs and tutorials, but everyone seems to create the EJB's and entities from scratch.
So the question is: how to create an EJB 3.0 Data Control based on just a Remote Interface?
I tried the following:
1. Create a new Fusion Web Application
2. Add the EJB Client jar to the classpath. If you select "Show Libraries" in the Project Navigator, you can drill down to the Remote Interface class in the EJB Client jar. When you right-click the Remote Interface, there is an option to "Create Data Control", but that doesn't work for .class files. And even if you have the .java source file there, it will generate a POJO Data Control, which is obviously not what we want.
After some time I found the following workaround:
3. Create a Session Bean with exact same package and name in the Model project, and make sure its remote interface is the same as the given Remote EJB. Then generate a EJB 3.0 Data Control on top of that
4. Then via file system remove the Session Bean and interface from Model project, so the Data Control will use the one on the classpath
5. Update DataControls.dcx with jndi-name and provider-url from Remote EJB
6. Remove <ejb-ref> from web.xml to avoid deployment issues.
Problem is that in our project there are many of these Remote EJBs, and they are also work in progress. Means the remote interfaces are changing all the time, and then all of the above steps have to be performed. Isn't there an easier way, like the behaviour I was expecting in step 2?
Thanks for any suggestions.
ADF needs to be able to access the source of the facade to create the data control, so the recommended way is to have a project that contains the actual EJB and from it create the data control.
This shouldn't be a problem assuming that you and the people who provide the EJB all work in the same company.
You should be able to change the location of the EJB that you access at runtime by modifying the datacontrol definition after it has been created.
Note also that if your EJBs are constantly changing you'll also need to update your data controls to leverage changes you need.
Thanks for confirmation. I'll stick to my current approach then.
Actual source code isnt required because I can inspect and copy the signature of the Remote Interface of the given Client Jar and create a session bean with method stubs. I only hoped that JDeveloper would do that for me...
Well at least I still have a job now!