I've got an issue with a CMP EJB I've written. It deploys OK on Weblogic 7.0, and the remote interface works as expected. If I try and create a local home interface, I dont seem to get an exception, and the code (a STRUTS action) seemingly executes OK.
This is my first CMP bean, and it also has relationships, so I'm sure I'm doing something wrong somewhere!
My client code is as follows:
...
Properties namingServiceProperties = new Properties ();
namingServiceProperties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
namingServiceProperties.setProperty(Context.PROVIDER_URL, "t3://localhost:7001");
Context ctx = new InitialContext(namingServiceProperties);
// get the local home interface
ContentLocalHome contentLocalHome = ctx.lookup("ContentLocalHome");
// the code doesn't seem to run the next few statements, and I can't see any exceptions thrown.
System.out.println("testing if we have our interface");
contentBean = contentHome.findByContentID(strId);
...
If I lookup "ContentHome" it does execute the next bits of code, I get a ClassCastException as you would expect, as it's returning the container implementation of the home interface.
The JNDI names are set to the shown values in the weblogic-ejb-jar.xml file, and if I use any other values, I get a finder exception, so I dont think that's the problem...
very confused, any help would be great!
thanks,
m.
-
Local Interface Lookup Problem with Weblogic (9 messages)
- Posted by: Matt Costain
- Posted on: April 24 2003 03:40 EDT
Threaded Messages (9)
- Local Interface Lookup Problem with Weblogic by Matt Costain on April 24 2003 03:46 EDT
- Local Interface Lookup Problem with Weblogic by Anshuman Purohit on April 24 2003 13:10 EDT
- Local Interface Lookup Problem with Weblogic by Aaron Robinson on April 24 2003 16:53 EDT
-
Local Interface Lookup Problem with Weblogic by Matt Costain on April 27 2003 08:57 EDT
- Local Interfaces and JVMS, also CMR and remote interfaces.. by Matt Costain on April 28 2003 01:10 EDT
-
Local Interface Lookup Problem with Weblogic by Matt Costain on April 27 2003 08:57 EDT
- Local Interface Lookup Problem with Weblogic by Aaron Robinson on April 24 2003 16:53 EDT
- Local Interface Lookup Problem with Weblogic by Lin Yang on April 24 2003 21:42 EDT
- hi by Padmanabh murthy on April 25 2003 01:35 EDT
- solved by Matt Costain on April 28 2003 21:35 EDT
- Different JVM by aditya mishra on November 11 2003 01:32 EST
- solved by Matt Costain on April 28 2003 21:35 EDT
-
Local Interface Lookup Problem with Weblogic[ Go to top ]
- Posted by: Matt Costain
- Posted on: April 24 2003 03:46 EDT
- in response to Matt Costain
Sorry, this line does read:
ContentLocalHome contentHome = (ContentLocalHome)ctx.lookup("ContentLocalHome"); -
Local Interface Lookup Problem with Weblogic[ Go to top ]
- Posted by: Anshuman Purohit
- Posted on: April 24 2003 13:10 EDT
- in response to Matt Costain
Matt:
Since you are using "new InitialContext(namingServiceProperties)" get the initial context, I am assuming this client is not a EJB/Servlet in the WL server instance. So, I am curious how come you are using local home interface? -
Local Interface Lookup Problem with Weblogic[ Go to top ]
- Posted by: Aaron Robinson
- Posted on: April 24 2003 16:53 EDT
- in response to Anshuman Purohit
this is a common mistake, a lot of people don't realise that you can default the context stuff and just do
Context ctx = new InitialContext();
As for your problem, it's difficult to see what the problem is without seeing the DD's and the full method -
Local Interface Lookup Problem with Weblogic[ Go to top ]
- Posted by: Matt Costain
- Posted on: April 27 2003 20:57 EDT
- in response to Aaron Robinson
Being used to working entirely with remote interfaces and BMP, I'm still feeling my way around here... I do understand the notion of default context in this situation.
I've assumed that 'running in the same JVM' is having an EJB deployed and having the Struts controller servlet running on the same server, in the same application, thus Local Interfaces could be used. I could be quite wrong here!
The other reason I've used local interfaces here, is that when builing my CMP ejb with weblogic.ejbc, it dictated that the CMR field is to return the local implementation of the bean, if the bean has local interfaces, which I'm hoping it will.
This has confounded me somewhat, as you obviously cannot expose the local interfaces in the remote bean, thus the two signatures of this method are incompatible. I've had to comment out the remote bean CMR field getter and setter to get this bean to build with weblogic.ejbc. This just doesn't seem right to me, as it means that the EJB Object remote interface will be incomplete.
[remote EJBObject]
/*public Template getTemplate() throws RemoteException;
public void setTemplate(Template template) throws RemoteException; */
[local EJBObject]
public TemplateLocal getTemplate();
public void setTemplate(TemplateLocal template);
Thanks for all the useful replies. Anymore feedback welcome!!
m. -
Local Interfaces and JVMS, also CMR and remote interfaces..[ Go to top ]
- Posted by: Matt Costain
- Posted on: April 28 2003 01:10 EDT
- in response to Matt Costain
After a lot of reading and playing around, I've now got my head around the method signature issue for the local and remote interfaces, and the restrictions of the local interfaces there. No huge dramas there, but I still need to resolve these two questions:
- Does Struts run in the same JVM as the EJBs? I think my definition of what constitutes 'the same JVM' is unclear. In my case, Weblogic is running in 'development mode' with an exploded directory. The EJBs are in separate jar files, and my struts action classes are deployed to an exploded directory. Could this be the problem? Would bundling the package into an .ear or similar fix the local interface lookup problem?
- also, is it a bad thing to use CMR with purely remote interfaces? This seemingly works fine for me in this case.
thanks!
m. -
Local Interface Lookup Problem with Weblogic[ Go to top ]
- Posted by: Lin Yang
- Posted on: April 24 2003 21:42 EDT
- in response to Matt Costain
If your client is not a web application component that assembled with you EJB in tha same EAR file or a EJB, that cannot access the local interface. In other words, a local client is a client that is collocated in the same JVM with the Enterprise JavaBean that provides the local client view. Please see EJB specification 2.0 and 2.1 for some details. -
hi[ Go to top ]
- Posted by: Padmanabh murthy
- Posted on: April 25 2003 01:35 EDT
- in response to Matt Costain
hey hi<br>
i think you can't access a local bean from a struts Action directly.<br>
what you have to do create a Remote session bean and write a method for the session bean which look ups for the local Entity bean .<br>
and you look up for the remote bean and just call the method.<br>
but make sure that your EJB's are in the same EARor jar.<br>
Regards
PM -
solved[ Go to top ]
- Posted by: Matt Costain
- Posted on: April 28 2003 21:35 EDT
- in response to Padmanabh murthy
I'm gonna answer my own questions here.
- I bundled the whole thing into the one .ear and it works fine
- using remote interfaces for CMR is a bad thing
I'm now debating on whether to implement a session facade, or whether to continue on this way. hmm... -
Different JVM[ Go to top ]
- Posted by: aditya mishra
- Posted on: November 11 2003 01:32 EST
- in response to Matt Costain
I am also trying to access(locally) CMP Entity bean via simple java application. But java client is not able to get the local interface. What I understood that Client is running on differnet JVM and our jar(entity beans) is using other jvm. Is it correct. I am using weblogic7.0 with Eclipse IDE.
Please answer at adityamishraa at rediffmail dot com.