插件安装后 Grails Apache 中断?
Posted
技术标签:
【中文标题】插件安装后 Grails Apache 中断?【英文标题】:Grails Apache breaks after plugin install? 【发布时间】:2013-02-23 22:50:40 【问题描述】:我目前正在处理一个 Grails 项目,并且我已经安装了以下插件:
Spring 安全核心
Spring 安全用户界面
邮件
等...
在我决定更改“Spring Security UI”并使用另一个名为“Mandrill”的邮件插件之前,该解决方案运行良好,一切都很好。所以我将插件中的RegisterController改为使用Mandrill而不是Mail,我添加到控制器的代码如下:
import org.grails.mandrill.MandrillRecipient;
import org.grails.mandrill.MandrillMessage;
import org.grails.mandrill.MandrillService;
def recpts = []
recpts.add(new MandrillRecipient(name:command.username, email:command.email))
def message = new MandrillMessage(
text:body.toString(),
subject:conf.ui.register.emailSubject,
from_email:conf.ui.register.emailFrom,
to:recpts)
message.tags.add("Test")
def ret = mandrillService.send(message)
现在,一旦我安装插件并添加此代码并运行应用程序,一切都开始正常,我没有收到任何错误,它告诉我转到本地主机,一旦我这样做,Apache 就会崩溃,我会收到以下错误:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error applying layout : main
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:679)
root cause
org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error processing GroovyPageView: Error executing tag <sec:ifAnyGranted>: null
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:679)
root cause
org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException: Error executing tag <sec:ifAnyGranted>: null
home_workspace_sm_V3_grails_app_views_layouts_main_gsp$_run_closure2.doCall(main.gsp:85)
home_workspace_sm_V3_grails_app_views_layouts_main_gsp.run(main.gsp:122)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:679)
root cause
java.lang.NullPointerException
grails.plugins.springsecurity.SecurityTagLib$_closure3.doCall(SecurityTagLib.groovy:89)
home_workspace_smV3_grails_app_views_layouts_main_gsp$_run_closure2.doCall(main.gsp:85)
home_workspace_sm_V3_grails_app_views_layouts_main_gsp.run(main.gsp:122)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:679)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.27 logs.
有人可以帮我解决这个问题,因为我的所有项目在此之后都不再工作,即使他们不使用 Mandrill:S
编辑....
下面是我的 main.gsp 页面,但我看不出这与问题有什么关系,因为我的所有项目都没有运行,即使它们在我安装该插件之前运行:S
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<title>SM</title>
<link rel="shortcut icon" href="$resource(dir:'images',file:'favicon.png')" type="image/x-icon" />
<link rel="stylesheet" href="$resource(dir:'bootstrap/css', file:'bootstrap.css')" />
<link rel="stylesheet" href="$resource(dir:'bootstrap/css', file:'bootstrap-responsive.css')" />
<link rel="stylesheet" href="$resource(dir:'kickstart/css', file:'docs.css')" />
<link rel="stylesheet" href="$resource(dir:'kickstart/css', file:'kickstart.css')" />
<link rel="stylesheet" href="$resource(dir:'datepicker/css',file:'datepicker.css')" />
<link rel="apple-touch-icon" href="assets/ico/apple-touch-icon.png">
<link rel="apple-touch-icon" sizes="72x72" href="assets/ico/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="114x114" href="assets/ico/apple-touch-icon-114x114.png">
<g:layoutHead />
<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="$resource(dir:'bootstrap/js', file:'bootstrap.js')"></script>
<script src="$resource(dir:'datepicker/js',file:'bootstrap-datepicker.js')"></script>
<script src="$resource(dir:'kickstart/js', file:'kickstart.js')"></script>
<script src="$resource(dir:'js', file:'application.js')"></script>
<r:layoutResources />
</head>
<body>
<div id="Navbar" class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="$createLink(uri: '/')">
<img class="logo" src="$resource(dir:'images',file:'sm_logo.png')" border="0" />
SM
<%-- <small> v$meta(name:'app.version')</small> --%>
</a>
<div class="nav-collapse">
<ul class="nav">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Menu <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a class="home" href="$createLink(uri: '/')"><g:message code="default.home.label"/></a></li>
<sec:ifNotLoggedIn>
<li><g:link class="login" controller="Login" action="auth"><g:message code="Login" args="[entityName]" /></g:link></li>
<li><a href="$createLink(uri: '/register/index')"><g:message code="Register"/></a></li>
</sec:ifNotLoggedIn>
<sec:ifLoggedIn>
<li><g:link class="logout" controller="Logout" action="index"><g:message code="Logout" args="[entityName]" /></g:link></li>
<li><g:link class="create" controller="Sm" action="create"><g:message code="Create" args="[entityName]" /></g:link></li>
<sec:ifAnyGranted roles="ROLE_ADMIN,ROLE_SUPER_ADMIN">
<li><g:link class="list" controller="Sm" action="list"><g:message code="SM Log" args="[entityName]" /></g:link></li>
</sec:ifAnyGranted>
</sec:ifLoggedIn>
</ul>
</li>
</ul>
<sec:ifAnyGranted roles="ROLE_ADMIN,ROLE_SUPER_ADMIN">
<ul class="nav">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Admin Menu <b class="caret"></b></a>
<ul class="dropdown-menu">
<sec:ifAnyGranted roles="ROLE_SUPER_ADMIN">
<li><a class="config" href="$createLink(uri: '/configProperty')"><g:message code="Config"/></a></li>
</sec:ifAnyGranted>
<li><a class="config" href="$createLink(uri: '/User')"><g:message code="Admin"/></a></li>
</ul>
</li>
</ul>
</sec:ifAnyGranted>
<div class="pull-right">
<!--<g:render template="/menu/language"/> -->
</div>
</div>
</div>
</div>
</div>
<g:if test="$ pageProperty(name:'page.header') ">
<g:pageProperty name="page.header" />
</g:if>
<g:else>
<header id="Header" class="jumbotron masthead">
<div class="inner">
<div class="container">
<h1 class="title"><g:layoutTitle default="$meta(name:'app.name')" /></h1>
</div>
</div>
</header>
</g:else>
<div id="Content" class="container">
<%-- Only show the "Pills" navigation menu if a controller exists (but not for home)
<g:if test="$ params.controller != null
&& params.controller != ''
&& params.controller != 'home'
">
<ul id="Menu" class="nav nav-pills">
<g:set var="entityName" value="$message(code: params.controller+'.label', default: params.controller.substring(0,1).toUpperCase() + params.controller.substring(1).toLowerCase())" />
<%-- Set which "pill" of the menu is active
<li class="$ params.action == "list" ? 'active' : '' ">
<g:link action="list"><g:message code="default.list.label" args="[entityName]"/></g:link>
</li>
<li class="$ params.action == "create" ? 'active' : '' ">
<g:link action="create"><g:message code="default.new.label" args="[entityName]"/></g:link>
</li>
</ul>
</g:if> --%>
<g:if test="$flash.message">
<div class="alert alert-info"><g:message code="$flash.message" args="$flash.args"
default="$flash.default"/></div>
</g:if>
<g:layoutBody />
<g:pageProperty name="page.body" />
</div>
<g:if test="$ pageProperty(name:'page.footer') ">
<g:pageProperty name="page.footer" />
</g:if>
<g:else>
<footer id="Footer">
</footer>
</g:else>
<r:layoutResources />
</body>
</html>
【问题讨论】:
发布你的 layout/main.gsp 代码 【参考方案1】:我刚刚遇到了同样的问题 - 几乎相同的堆栈跟踪。 grails clean 和 grails compile --refresh-dependencies 都不起作用。
经过数小时的努力,我终于采取了删除 .grails 缓存文件夹的步骤。重新启动时,我执行了刷新依赖项和清理。
这似乎成功了。
【讨论】:
以上是关于插件安装后 Grails Apache 中断?的主要内容,如果未能解决你的问题,请参考以下文章
创建和安装 grails 插件 - 在安装期间/安装后,我的插件如何从依赖的插件访问资源?