• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.lang.ClassCastException: $Proxy in EJB in weblogic??

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,
I have a BMP ejb with a findAll method returning a collection. I have put in a test code in this EJB which displays the object type in the collection.
---------------------------------------in EJB----------------------------------------------------------------
Collection result; //this is the return value from findAll
Iterator itr = result.iterator();
Vector v;
while (itr.hasNext() ) {
Object o = itr.next();
System.out.println("class is =" + o.getClass().getName()); //prints java.util.Vector
v = (Vector) o;
}
--------------------------------------------------------------------------------------------------------------------
The object type is Vector , so everything is fine in the ejb.
The client to this ejb is a session EJB which contains the following code snippet.
----------------------------------------client session EJB------------------------------------------------
ctx = new InitialContext();
exphome = (ExpenseHome) ctx.lookup("ejb/Expense");
Collection result = exphome.findByAll(........)
Iterator itr = result.iterator();
Vector v;
Object o;
while (itr.hasNext() ) {
o = itr.next();
System.out.println("class is =" + o.getClass().getName()); //prints $Proxy87 ???
v = (Vector) o;
}
----------------------------------------------------------------------------------------------------------------------------------------------
I don't have any clue why i get this proxy problem?..Can anyone help me out please..First I thought that there was mismatch of stubs, but the problem exists even after installing the application completely.
This is the complete stacktrace.
---------------------------------------------------------------------------------------------------------------------
java.lang.ClassCastException: $Proxy87
at project.expense.servlet.SearchExpResult.doGet(SearchExpResult.java:60
)
at project.expense.servlet.SearchExpResult.doPost(SearchExpResult.java:1
04)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:265)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:200)
at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispat
cherImpl.java:215)
at weblogic.servlet.jsp.PageContextImpl.forward(PageContextImpl.java:112
)
at jsp_servlet.__searchexpform._jspService(__searchexpform.java:193)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:265)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:200)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:2456)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:2039)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
-----------------------------------------------------------------------------------------------------------------------------
TIA
 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Clement,
You should give us more informations about the VM you use (Client & Server side of course), OS you are running on (Client & Server) ...
My first (and currently only) feeling is that you have some potential troubles with the VM versions !
Ar eyou sure you only have that problem in that case ?
(private : Very french name Cl�ment)
 
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your findAll() returns a Collection - which is fine since this will be the collection of entity beans that are found.
I'm not sure I understand why you are trying to cast to a Vector inside the while loop. What type are the beans that are returned? Aren't they of type Expense (or something like that)?
Simon
 
clement valentine
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks guys.. It slipped my mind that findAll() returns proxy to the bean implementation. Works fine now...
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yah Guys!!

The exception occurs due to not only the version incompatibility of java VM, but also due to the Lists(ArrayLists)(as in fewer version of java is incompatible),or there may be same version of the class in different application(This is not so true, but rare chances are there)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic