Home : ClassCastException when Accessing an EJB Method from .NET Client
Q49760 - ERRMSG: ClassCastException when Accessing an EJB Method from .NET Client

ClassCastException when Accessing an EJB Method from .NET Client

 

Contents

  1. SYMPTOMS
  2. CAUSE
  3. RESOLUTION

SYMPTOMS

Following the Accessing EJBs from C# Using BEA Weblogic example, you've successfully deployed the EJB JAR file and servlet WAR file. When calling a method of the EJB that returns a Java object, a java.lang.ClassCastException is thrown, as shown below:

CAUSE

Calling a method from your .NET client on an EJB that returns a Java Object would require Ja.NET to do a cast. As such, there are two conflicting versions of the returned object, because different classloaders are being used. This is because the EJB JAR file is included with the WAR file, while the same JAR file is also deployed on the server.

RESOLUTION

When using the Janetor tool to create a WAR file, do not include the EJB JAR file in the "User Library" field. By doing this, you are ensuring that there is only one copy of the EJB JAR file existing on the server (the one that is deployed).

Note that the proper way of returning non-serializable objects from an EJB method call is to make the returned object an EJB also. Because JanetServlet is located on the same domain as the EJB, and consequently will be loaded in the same process, this is an exception to the rule. The returned object is not "remoted" and will not need to be a separate EJB.

Status

This issue does not require any fixes to J-Integra for .NET.

Related Articles
No Related Articles Available.

Article Attachments
No Attachments Available.

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?

poor 
1
2
3
4
5
6
7
8
9
10

 excellent
Tell us why you rated the content this way. (optional)
 
Approved Comments...
No user comments available for this article.
Created on 6/23/2006.
Last Modified on 7/10/2006.
Last Modified by No Author Name Available!.
Article has been viewed 7565 times.
Rated 6 out of 10 based on 2 votes.
Print Article
Email Article