| 

.NET C# Java Javascript Exception

Controller Methode in anderem Controller aufrufen

Dies ist das Archiv des ehemaligen Forums zum Thema Groovy, Grails, Griffon und Bean Scripting Framework, welches unter groovy-forum.de existierte. Die neue Adresse des Groovy-Forums ist: http://codekicker.de/fragen/themen/groovy.


Controller Methode in anderem Controller aufrufen

schokole - 07.01.2010 11:42
Hi!

Leider habe ich mittlels Google und der Forensuche nichts gefunden, obwohl ich denke dass das Problem schnell und einfach gelöst sein sollte, naja...

Also zum Punkt:
Ich habe einen UserController, in diesem die Methode getPrincipalUser(), welche mir eine Userinstanz liefert.

Der zweite Controller ist der FAQ-Controller, dort möchte ich bevor ein FAQ gelöscht wird schauen ob der User ein Admin ist (Methode isAdmin funktioniert im User/UserController).
Jedoch findet er die Methode nicht...



So habe ich es mir gedacht:

Code des faqController.groovy
 
	def userInstance = UserController.getPrincipalUser()
        if (userInstance ==  null)
        {
        	flash.message = 'You are not logged in.'
        	redirect uri: '/'
        	return			
        }
	
	if (userInstance.isAdmin!= true)
	{
		redirect uri: '/'
		flash.message = "permission denied"
		return	
	}



Fehlermeldung:
 

Error 500: groovy.lang.MissingMethodException: No signature of method: static UserController.getPrincipalUser() is applicable for argument types: () values: []
Servlet: grails
URI: /studybuddies/grails/faq/delete.dispatch
Exception Message: No signature of method: static UserController.getPrincipalUser() is applicable for argument types: () values: []
Caused by: groovy.lang.MissingMethodException: No signature of method: static UserController.getPrincipalUser() is applicable for argument types: () values: []
Class: GrailsAuthenticationProcessingFilter
At Line: [56]
Code Snippet:


org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: static UserController.getPrincipalUser() is applicable for argument types: () values: []

	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:92)

	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:234)

	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1062)

	at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:926)

	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:893)

	at groovy.lang.Closure.call(Closure.java:279)

	at groovy.lang.Closure.call(Closure.java:274)

	at org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsControllerHelper.handleAction(SimpleGrailsControllerHelper.java:368)

	at org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsControllerHelper.executeAction(SimpleGrailsControllerHelper.java:243)

	at org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsControllerHelper.handleURI(SimpleGrailsControllerHelper.java:203)

	at org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsControllerHelper.handleURI(SimpleGrailsControllerHelper.java:138)

	at org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsController.handleRequest(SimpleGrailsController.java:88)

	at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)

	at org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet.doDispatch(GrailsDispatcherServlet.java:264)

	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)

	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)

	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)

	at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)

	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)

	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)

	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1124)

	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70)

	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1115)

	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70)

	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1115)

	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70)

	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1115)

	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:361)

	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)

	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)

	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)

	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417)

	at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:334)

	at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:126)

	at org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:293)

	at org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:269)

	at org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:261)

	at org.codehaus.groovy.grails.web.mapping.filter.UrlMappingsFilter.doFilterInternal(UrlMappingsFilter.java:181)

	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1115)

	at org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.obtainContent(GrailsPageFilter.java:221)

	at org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.doFilter(GrailsPageFilter.java:126)

	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1115)

	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)

	at org.springframework.security.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)

	at org.springframework.security.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)

	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)

	at org.springframework.security.ui.ExceptionTranslationFilter.doFilterHttp(ExceptionTranslationFilter.java:101)

	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)

	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)

	at org.springframework.security.providers.anonymous.AnonymousProcessingFilter.doFilterHttp(AnonymousProcessingFilter.java:105)

	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)

	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)

	at org.springframework.security.ui.rememberme.RememberMeProcessingFilter.doFilterHttp(RememberMeProcessingFilter.java:109)

	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)

	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)

	at org.springframework.security.wrapper.SecurityContextHolderAwareRequestFilter.doFilterHttp(SecurityContextHolderAwareRequestFilter.java:91)

	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)

	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)

	at org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(AbstractProcessingFilter.java:277)

	at org.codehaus.groovy.grails.plugins.springsecurity.GrailsAuthenticationProcessingFilter.super$3$doFilterHttp(GrailsAuthenticationProcessingFilter.groovy)

	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

	at java.lang.reflect.Method.invoke(Method.java:597)

	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)

	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:234)

	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1062)

	at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:926)

	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:127)

	at org.codehaus.groovy.grails.plugins.springsecurity.GrailsAuthenticationProcessingFilter.doFilterHttp(GrailsAuthenticationProcessingFilter.groovy:56)

	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)

	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)

	at org.springframework.security.ui.logout.LogoutFilter.doFilterHttp(LogoutFilter.java:89)

	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)

	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)

	at org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:235)

	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)

	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)

	at org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:175)

	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236)

	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)

	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1115)

	at org.codehaus.groovy.grails.web.servlet.filter.GrailsReloadServletFilter.doFilterInternal(GrailsReloadServletFilter.java:101)

	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1115)

	at org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:65)

	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1115)

	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)

	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236)

	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)

	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1115)

	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:361)

	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)

	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)

	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)

	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417)

	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)

	at org.mortbay.jetty.Server.handle(Server.java:324)

	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:534)

	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:879)

	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:741)

	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:213)

	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:403)

	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)

	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:522)

Caused by: groovy.lang.MissingMethodException: No signature of method: static UserController.getPrincipalUser() is applicable for argument types: () values: []

	at FaqController$_closure4.doCall(FaqController:27)

	at FaqController$_closure4.doCall(FaqController)


Denke das sollte irgendwie möglich sein die Funktion des einen Controllers im anderen zu nutzen, ich bin auch für Beispiele und Links sehr dankbar! :-)


Gruß
Schoko


Stelle deine Groovy-Frage jetzt!


Diese Seite zeigt den Thread "Controller Methode in anderem Controller aufrufen" der ehemaligen Webseite groovy-forum.de, welche durch einen Serverunfall zerstört wurde. codekicker.de hat viele Konversationen über die beliebte Programmiersprache Groovy und zugehörige Frameworks wie das Grails-Framework retten können.

Hast Du eine Frage zum Thema Groovy, Grails oder allgemein Java? Viele ehemalige groovy-forum.de Mitglieder beantworten dir auf codekicker.de deine Frage! Stelle jetzt eine Frage!

Viele weitere Diskussionen zu Grails und Groovy befinden sich auf der Threadübersicht des alten groovy-forum.de.