Reputation: 31
i'm developing a web application with Grails. My environment specs are:
I start the application, and on the grails start page i choose this controller:
class UploadController {
def index() { }
def upload() {
forward(controller: "parser", action: "takeUploadedFiles")
}
}
With just this controller there would not happen anything. The corresponding .gsp is this upload form. I use it to upload multiple files at once.
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<meta name="layout" content="main"/>
<title>Inhalte einlesen</title>
</head>
<body>
<div class="body">
<g:uploadForm controller="upload" action="upload" autocomplete="off">
<label for="files">Bitte alle HTML-Dateien einer Kategorie auswählen:</label>
<input type="file" id="files" name="files" multiple="multiple" />
<input type="hidden" id="MAX_FILE_SIZE" name="MAX_FILE_SIZE" value="30000" />
<g:submitButton name="add" class="save button medium" value="Hochladen" />
</g:uploadForm>
</div>
</body>
</html>
The UploadController forwards to the ParserController. This is the ParserController:
import org.springframework.web.multipart.commons.CommonsMultipartFile
class ParserController {
def multipartToFileService
def parserService
def index() { }
def takeUploadedFiles() {
List fileList = request.getFiles('files') // 'files' is the name of the input
fileList.each { file -> multipartToFileService.convert(file) }
redirect(action: "parse")
}
def parse() {
parserService.parse()
}
}
So i upload one .html. At this point i get this exception:
2014-06-02 23:04:33,127 [tomcat-http--9] ERROR servlet.GrailsDispatcherServlet - HandlerInterceptor.afterCompletion threw exception
java.lang.IllegalStateException: No value for key [org.hibernate.internal.SessionFactoryImpl@6398813a] bound to thread [tomcat-http--9]
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:198)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
This exception doesn't stop the application, even the parsing is done perfectly. But i don't understand this exception, and i found out it might have something to do with the transactional Services i'm injecting in the PaserController. Whithout service injection, i don't get the exception (instead i get a MissingPropertyException, of course):
import org.springframework.web.multipart.commons.CommonsMultipartFile
class ParserController {
// def multipartToFileService
// def parserService
def index() { }
def takeUploadedFiles() {
List fileList = request.getFiles('files') // 'files' is the name of the input
fileList.each { file -> multipartToFileService.convert(file) }
redirect(action: "parse")
}
def parse() {
parserService.parse()
}
}
Any ideas how to avoid this IllegalStateException?
Upvotes: 1
Views: 1421
Reputation: 146
This seems to be the problem: https://github.com/grails/grails-core/issues/2105
Upvotes: 0