This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JBoss/WildFly and the fly likes java.lang.ClassCastException: java.lang.Integer cannot be cast to com.user Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "java.lang.ClassCastException: java.lang.Integer cannot be cast to com.user" Watch "java.lang.ClassCastException: java.lang.Integer cannot be cast to com.user" New topic
Author

java.lang.ClassCastException: java.lang.Integer cannot be cast to com.user

Sunny Diaz
Greenhorn

Joined: Mar 07, 2011
Posts: 16

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
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9930
    
159

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.

[My Blog] [JavaRanch Journal]
Sunny Diaz
Greenhorn

Joined: Mar 07, 2011
Posts: 16

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

Joined: Mar 07, 2011
Posts: 16

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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.ClassCastException: java.lang.Integer cannot be cast to com.user
 
Similar Threads
Page cannot be displayed on multiple request.
xml parser problem with jboss5
Problem with executeQuery
jboss 5 discards all character after @ character in cookie value
hibernate project configuration in eclipse3.5 and netbeans6.8