EJB Bindings - Class Cast Exception

Joined
Sep 21, 2017
Messages
1
Reaction score
0
Hi,

i'm having an issue with EJB bindings which i can not resolve. To make it short, i have one project which is deployed several times (political manner), so i do have EJBs with the same name.
I found 2 solutions, 1) defining a custom property on the JVM (which is not allowed internally) for long-form names, and 2) defining a binding file "ibm-ejb-jar-bnd.xml".

I have tried to replicate what this file does, and "hard code" the bindings directly on the application instance. While accessing the context-root, i get a ClassCastException :

DefaultDispat E com.opensymphony.xwork2.util.logging.commons.CommonsLogger error Exception occurred during processing request: Cannot cast class my.project.ejb.service.EJSLocal0SLCartService_14538494 to interface my.project.ejb.service.ICartService
java.lang.ClassCastException: Cannot cast class my.project.ejb.service.EJSLocal0SLCartService_14538494 to interface my.project.ejb.service.ICartService
at java.lang.Class.cast(Class.java:2632)
...


To distinguish between the instances that will be installed, i set a variable during compiling with Maven. So, the bindings will be adapted.

Local:
@Local
public interface ICartService {


Implementation:
@Stateless
public class CartService implements ICartService{
@EJB
private IAuditTrailService auditTrailSvc; // Other EJB


I do EJB injection. Can not use InitialContext as the bindings will be different from instance to instance.

binding file "ibm-ejb-jar-bnd.xml":
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar-bnd
xmlns="http://websphere.ibm.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-ejb-jar-bnd_1_0.xsd"
version="1.0">

<session name="CartService" simple-binding-name="ejb/app1/ICartService"/>
</ejb-jar-bnd>


I'm using EJB 3.1, Java 7, WAS 8.5.

Can somebody help me out ?

(I can change the application like i want, but do not have the possibility to change any configuration on the production server.)

Thanks !
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top