• 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: java.lang.Integer cannot be cast to com.user

 
Greenhorn
Posts: 16
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I have a strange problem coming for some strange reason i don't know.
I am in a process of migrating from jboss4 to jboss5 and everything was workign perfectly fine in jboss4 and since i start to start my application in jboss5 i get this exception.

What i have been doing in the query was getting the results from two tables to show statistics and these results i get in the object array.
on index 0 always was coming user records and on index 1 it always came the integer value.
but in jboss5 now i get the results opposite and i get this castexception... for some reason at index 0 it is coming integer value and at index 1 it is coming user records.

I have checked the mysql query which is perfectly fine and working fine in jboss4 and in mysql editor also.

any idea what could be reason? hibernate?
l am using hibernate3 with jboss4 and with jboss5 also the same.

using ehcache as well for mapping classes which was working also fine in jboss4 but now in jboss5 i get the warning that can not find specific configuration... could it be the reason of the exception???


Please help!

thanks
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'll have to show us some code (including the part where you create and run the JPQL/HQL), the entire exception stacktrace and maybe even the generated SQL.
 
Sunny Diaz
Greenhorn
Posts: 16
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
java.lang.ClassCastException: java.lang.Integer cannot be cast to com.user
at com.data.StatisticsManager.executeTopRatingQuery(StatisticsManager.java:507)
at com.data.StatisticsManager.getStatWeekly(StatisticsManager.java:364)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at flex.messaging.services.remoting.adapters.JavaAdapter.invoke(JavaAdapter.java:421)
at flex.messaging.services.RemotingService.serviceMessage(RemotingService.java:183)
at flex.messaging.MessageBroker.routeMessageToService(MessageBroker.java:1495)
at flex.messaging.endpoints.AbstractEndpoint.serviceMessage(AbstractEndpoint.java:882)
at flex.messaging.endpoints.amf.MessageBrokerFilter.invoke(MessageBrokerFilter.java:121)
at flex.messaging.endpoints.amf.LegacyFilter.invoke(LegacyFilter.java:158)
at flex.messaging.endpoints.amf.SessionFilter.invoke(SessionFilter.java:44)
at flex.messaging.endpoints.amf.BatchProcessFilter.invoke(BatchProcessFilter.java:67)
at flex.messaging.endpoints.amf.SerializationFilter.invoke(SerializationFilter.java:146)
at flex.messaging.endpoints.BaseHTTPEndpoint.service(BaseHTTPEndpoint.java:278)
at flex.messaging.MessageBrokerServlet.service(MessageBrokerServlet.java:315)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at org.apache.catalina.core.StandardC

this is the part of the stack trace...

the function where i execute this query is


private List<TopEntry> executeTopRatingQuery(User user, Query query, int start, int max) {

List<TopEntry> result = new ArrayList<TopEntry>();


if (user == null) {
query.setFirstResult(start);
query.setMaxResults(max*2);
}

for (Object[] row : (List<Object[]>)query.getResultList()) {



TopEntry entry = new ToplistEntry(((User)row[0]).toPlayer(), getIntValue(row[1]), -1);

}

and the other function is

public List<TopEntry> getStatWeekly(int start, int max, User user) {
String TABLE = "weekly";
EntityTransaction tx = em.getTransaction();
try {
tx.begin();
Query query = em.createNativeQuery(NATIVE_QUERY_WEEKLY.replaceFirst("\\?1", TABLE), "UserMapOne");
return executeTopRatingQuery(user, query, start, max);
}
finally {
if (tx.isActive())
tx.rollback();
}
}

finally the query is

public static final String NATIVE_QUERY_WEEKLY =
"select us.*, in_week as val from ?1 v, user us " +
"where v.user_id = us.id and us.disabled = 0 " +
"order by in_week desc, us.username";
 
Sunny Diaz
Greenhorn
Posts: 16
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But still i feel there is not issue in the code.. as it is all working perfectly fine in the jboss4. i guess there could be problem with hibernate or cache? what do you think?
reply
    Bookmark Topic Watch Topic
  • New Topic