I'm working on implementation of an external vendor API, which is in fact an EJB service and package into an .ear file.
the idea is first we call to API manager, and then use the method which return a list of object, the object is belong to API proprietary object (ie:Status object).
What have been done so far, i managed to get the API manager which is not null, and the manager return a list, however it seem return me a list in different object type, as mentioned below, we expecting "Status" object but it return StatusImpl.
the API manager which is local session bean give the correct result if using stateless bean to implement the method of it, but not the case if we use Spring to do it.
Appreciated anyone can shed some light on this, what is wrong and how can i handle it ? Thanks a lot!
Below is the exception:
servlet springDispatcherServlet threw exception
java.lang.ClassCastException: com.hp.api.schoolclass.StatusImpl cannot be cast to com.api.schoolclass.Status
Below code managed to get the API manager
Below is how my own manager to call the API method
I'm not sure what the structure of your project is, but what I meant is there should not be two versions of Status class. I guess your web application in which you are using Spring to get the session bean and the EJB application is part of the same EAR. What I'm trying to say is there should not be two separate Status.java files, one in your EJB project and one in your WAR (Web application) project. The WAR project should have a dependency on EJB project's JAR to refer to Status class...
Sound like making sense to me, we are using war project and we included the api jar file into our environment, we imported it in our client class, Let called this as "Local" Status.class, we then do a Context lookup to the ear file, we get the EJB manager and invoked it method and return result and finally assign back into "Local" Status.class.
I might be new to EJB, or what is the right approach i should go for? how my war project do the dependency to EAR project's jar ? appreciated if you have little snippet code to enlighten me if possible.
I'm still a little confused how everything is setup in your project. Let's take this one step at a time.
1. Are the EJB and WAR project are in the same EAR?
_I. If they are:
___a. You must have a compile time dependency on the EJB project.
___b. At runtime the Status.class would be available to the web application from the EJB application as it's running as part of the same EAR application.
_II. If the EJB and WAR are not part of the same EAR (I don't think that would be the case as you said your EJBs are local EJBs)
___a. In this case you'll have to package EJB project's JAR with your WAR project.
2. Are you using Maven? If yes maybe you can post your maven configuration how you've defined the dependencies...
Sorry for confusion, The EJB and WAR are not part of same EAR.
means in the EJB which call the API method are package into EAR named "api-ear", we have a WAR to call this "api-ear" to get the value.
But both EAR and WAR under the same jboss server. so i have to take the EJB JAR and package together with my WAR ? is there a better choice? caused the EAR is provided by vendor. we try not to modify what they given.