grails / grails-gsp

GSP (Grails Server Pages) - A server-side view rendering technology based on Groovy
Apache License 2.0
15 stars 35 forks source link

Can not find views from other plugins #11

Open jarekwas opened 7 years ago

jarekwas commented 7 years ago

Task List

Steps to Reproduce

  1. Create App and Plugin A and Plugin B with Grails Multi-Project Build
  2. Create view in Plugin A 'grails-app/views/templates/example.gsp'
  3. Create Controller in Plugin B.
  4. Render GSP from plugin A in controller in plugin B. render(view: 'templates/example', plugin: 'plugina')

    Expected Behaviour

Grails will find the view and as usual.

Actual Behaviour

Throw Exception

2017-08-21 02:07:38.989 ERROR --- [nio-8080-exec-1] .a.c.c.C.[.[.[.[grailsDispatcherServlet] : Servlet.service() for servlet [grailsDispatcherServlet] in context with path [] threw exception [Could not resolve view with name '/plugins/stuff-core-backend-2.0dev/vue/modules/stuff/BusinessTrip' in servlet with name 'grailsDispatcherServlet'] with root cause

javax.servlet.ServletException: Could not resolve view with name '/plugins/stuff-core-backend-2.0dev/vue/modules/stuff/BusinessTrip' in servlet with name 'grailsDispatcherServlet'
        at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1266)
        at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1041)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:984)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:317)
        at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
        at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
        at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114)
        at grails.plugin.springsecurity.web.UpdateRequestContextHolderExceptionTranslationFilter.doFilter(UpdateRequestContextHolderExceptionTranslationFilter.groovy:64)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
        at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.groovy:53)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
        at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:158)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
        at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
        at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
        at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.groovy:62)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
        at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
        at grails.plugin.springsecurity.web.SecurityRequestHolderFilter.doFilter(SecurityRequestHolderFilter.groovy:58)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
        at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)
        at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:77)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:67)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:96)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:745)

Environment Information

jarekwas commented 7 years ago

In version 3.2 below, the code included was able to find a view of any plug-in from the entire application. In version 3.3, the following code can find the view only contained in the same plugin as the controller.

class VueTemplateController {

    GroovyPageLocator groovyPageLocator

    def index(String id) {
       if(groovyPageLocator.findPage('/vue/'+id+'.gsp')){
            render(view: '/vue/'+id)
        }else{
            render(status: 404)
        }
    }
}
Chaguala commented 6 years ago

I just need your help! I try run app Grails app a i find this error! ---

"C:\Program Files\Java\jdk1.7.0_51\bin\java" -Dgrails.home=C:\CHAGUALA\Grails\grails-2.4.4 "-Dtools.jar=C:\Program Files\Java\jdk1.7.0_51\lib\tools.jar" -Dgroovy.starter.conf=C:\CHAGUALA\Grails\grails-2.4.4/conf/groovy-starter.conf -Xmx768M -Xms768M -XX:MaxPermSize=256m -XX:PermSize=256m -Djline.WindowsTerminal.directConsole=false -javaagent:C:\CHAGUALA\Grails\grails-2.4.4\lib\org.springframework\springloaded\jars\springloaded-1.2.1.RELEASE.jar -noverify -Dspringloaded=profile=grails;cacheDir=. -Dbase.dir=C:\Users\ccsadmin\SIGEM -Dgrails.project.fork.run.debugArgs= -Dfile.encoding=UTF-8 -classpath C:\CHAGUALA\Grails\grails-2.4.4\lib\org.codehaus.groovy\groovy-all\jars\groovy-all-2.3.7.jar;C:\CHAGUALA\Grails\grails-2.4.4\dist\grails-bootstrap-2.4.4.jar org.codehaus.groovy.grails.cli.support.GrailsStarter --main org.codehaus.groovy.grails.cli.GrailsScriptRunner --conf C:\CHAGUALA\Grails\grails-2.4.4/conf/groovy-starter.conf "run-app -plain-output" Loading Grails 2.4.4 Configuring classpath . Environment set to development ................................. Packaging Grails application ........... Compiling 1 source files ...................... Running Grails application Server running. Browse to http://localhost:8080/SIGEM ....Error
2017-12-10 19:30:50,919 [http-bio-8080-exec-1] ERROR errors.GrailsExceptionResolver - IllegalStateException occurred when processing request: [GET] /SIGEM/requerente/create Method on class [SIGEM.Requerente] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails correctly.. Stacktrace follows: Message: Error processing GroovyPageView: Error executing tag : Method on class [SIGEM.Requerente] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails correctly. Line Method ->> 527 runWorker in C:\Users\ccsadmin\SIGEM\grails-app\views\requerente\create.gsp
Caused by GrailsTagException: Error executing tag : Method on class [SIGEM.Requerente] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails correctly. ->> 35 doCall in C:/Users/ccsadmin/SIGEM/grails-app/views/requerente/create.gsp
Caused by IllegalStateException: Method on class [SIGEM.Requerente] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails correctly. ->> 78 doCall in C__Users_ccsadmin_SIGEM_grails_app_views_requerente_create_gsp$_run_closure2
81 run in C__Users_ccsadmin_SIGEM_grails_app_views_requerente_create_gsp
1145 runWorker in java.util.concurrent.ThreadPoolExecutor
615 run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 744 run . . . in java.lang.Thread

Process finished with exit code 1