Running a war on Tomcat7 vs Grails run-app

I have a problem with a warls file created by Grails on tomcat7. If / when I run the same application using the grails run-app, all this is good and in good working condition. The exception that I get while tomcat7 is running and the war is launched:

2014-08-20 09:17:28,933 [http-bio-127.0.0.1-8080-exec-7] ERROR errors.GrailsExceptionResolver - ClassNotFoundException occurred when processing request: [GET] / jline.console.history.History. Stacktrace follows: java.lang.ClassNotFoundException: jline.console.history.History at org.codehaus.plugin.swagger.builder.SwaggerDocsBuilder.buildApiDeclarations(SwaggerDocsBuilder.groovy:71) at org.codehaus.plugin.swagger.builder.SwaggerDocsBuilder.rebuild(SwaggerDocsBuilder.groovy:48) at org.codehaus.plugin.swagger.builder.SwaggerDocsBuilder.build(SwaggerDocsBuilder.groovy:36) at org.codehaus.grails.plugins.swaggerapidocs.SwaggerApiDocsController.resources(SwaggerApiDocsController.groovy:21) at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:198) at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63) at com.brandseye.cors.CorsFilter.doFilter(CorsFilter.java:82) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 

Line 71 SwaggerDocsBuilder.groovy

 rules = new BuildPathMap().build(grailsApp) 

and BuildPathMap extends

 import org.codehaus.groovy.grails.web.mapping.reporting.AnsiConsoleUrlMappingsRenderer class BuildPathMap extends AnsiConsoleUrlMappingsRenderer { 

my hunch AnsiConsoleUrlMappingsRenderer somehow depends on jline.console.history.History , but then why is it missing in the war file? Is there something that can be done during the war to ensure that ll dependencies are properly packaged?

+5
source share
3 answers

His mistake is in the grails.

https://jira.grails.org/browse/GRAILS-8532

can fix this with a workaround by adding the following snippet to BuildConfig.groovy:

 grails.war.resources = { stagingDir, args -> copy(todir: "${stagingDir}/WEB-INF/lib", flatten: "true") { fileset(dir: "${grailsHome}/lib", includes: "**/jline-*.jar, **/jansi-*.jar") } } 
+3
source

Not sure if this is the best solution, but I managed to get around this problem by explicitly adding the jLine dependency to BuildConfig.groovy:

 runtime 'jline:jline:2.12' 

I did not see this error with Grails 2.5.1, but with Grails 2.5.4. Sounds like a mistake.

+2
source

Your Tomcat is set up to launch an unpacked or packaged war. Development starts as an unpacked war, so commands such as servlet.getRealPath () return a valid value at startup, that in a packaged war, the Tomcat servlet container returns null. In the server.xml file, find the unpackWARs attribute.

  <Host name="localhost" appBase="webapps" unpackWARs="false" autoDeploy="false"> 

Also, at startup, some dependencies are added to the development, and you need to specify them in BuildConfig.groovy, otherwise they may not be available in the war.

0
source

Source: https://habr.com/ru/post/1200755/


All Articles