Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.ClassCastException in Grails app

I am following the free online book "Getting Started with Grails" (http://www.infoq.com/minibooks/grails-getting-started) and I am getting a java.lang.ClassCastException when trying to list any domain class. Can anyone decipher this?

URI: /RaceTrack/runner/list
Class: java.lang.ClassCastException
Message: sun.proxy.$Proxy26 cannot be cast to org.springframework.orm.hibernate3.HibernateCallback

Stack trace:

    Line | Method
->>   15 | list      in RunnerController.groovy
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    186 | doFilter  in PageFragmentCachingFilter.java
|     63 | doFilter  in AbstractFilter.java
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run       in java.lang.Thread

Additional info (around line 186 of PageFragmentCachingFilter.java)

183:            if(method == null) {
184:                log.debug("No cacheable method found for {}:{} {}",
185:                        new Object[] { request.getMethod(), request.getRequestURI(), getContext() });
186:                chain.doFilter(request, response);
187:                return;
188:            }
189:            Collection<CacheOperation> cacheOperations = cacheOperationSource.getCacheOperations(

Additional info (around line 63 of AbstractFilter.java):

60:     try {
61:         // NO_FILTER set for RequestDispatcher forwards to avoid double gzipping
62:         if (filterNotDisabled(request)) {
63:             doFilter(request, response, chain);
64:         }
65:         else {
66:             chain.doFilter(req, res);
like image 609
grantmcconnaughey Avatar asked Mar 20 '13 20:03

grantmcconnaughey


3 Answers

I've had the same issue happening all of a sudden couple days back. Deleting ~/.grails/2.0.4/.slcache/ directory fixes it for me.

like image 181
AverageJoe Avatar answered Oct 14 '22 12:10

AverageJoe


Delete .slcache in both the top of the .grails subdirectory and also the .slcache, if it exists, for the particular version of grails being used. For example, ~/.grails/2.1.3/.slcache.

This worked when using IntelliJ IDEA to launch the app.

like image 3
Peter N. Steinmetz Avatar answered Oct 14 '22 11:10

Peter N. Steinmetz


Does the app start up with reloading (spring-loaded agent) disabled?

grails -noreloading run-app

A similar problem has been reported to Grails Jira as GRAILS-9952. It would help fixing the problem if you can provide an test app that reproduces the problem. Please attach that to the jira issue.

like image 1
Lari Hotari Avatar answered Oct 14 '22 11:10

Lari Hotari