使用GroovyPagesTemplateEngine时缺少taglib(Missing taglib when using GroovyPagesTemplateEngine)
我一直在通过我自己的taglib中的标签处理动态GSP内容,使用如下代码可以很好地工作:
def GroovyPagesTemplateEngine groovyPagesTemplateEngine ... def processGSPContent(model, name, out) { log.debug("model is $model") Template t = groovyPagesTemplateEngine.createTemplate(model.content, name + ".gsp") Writable w = t.make(model: model) w.writeTo(out) }
现在我不是100%确定如何找到像taglibs这样的各种资源,但是我所有的taglib都能像正常的grails库一样正常工作。
我
AcegiSecurity
的问题是AcegiSecurity
的标签在以这种方式处理的内容中找不到:例如,<g:isLoggedIn> You're logged in :-) </g:isLoggedIn>
那么如何让
GroovyPagesTemplateEngine
找到AcegiSecurity
标签? 我猜这可能与ApplicationContext
或ServletContext
。编辑---看起来像它可能是一个重载的命名空间问题:
Caused by: org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException: Tag [ifnotloggedin] does not exist. No tag library found for namespace: g at home_pmcneil_devel_Groupie_grails_app_views_display_page_gsp.run(home_pmcneil_devel_Groupie_grails_app_views_display_page_gsp:32)
I've been processing dynamic GSP content via tags in my own taglib which works just fine using code like:
def GroovyPagesTemplateEngine groovyPagesTemplateEngine ... def processGSPContent(model, name, out) { log.debug("model is $model") Template t = groovyPagesTemplateEngine.createTemplate(model.content, name + ".gsp") Writable w = t.make(model: model) w.writeTo(out) }
Now I'm not 100% sure on how various resources like taglibs are found, but all my taglibs work fine as do the normal grails libs.
The problem I have is that
AcegiSecurity
's tags aren't found in content processed this way: e.g.<g:isLoggedIn> You're logged in :-) </g:isLoggedIn>
so how do I get
GroovyPagesTemplateEngine
to find theAcegiSecurity
tags? I'm guessing it may be something to do withApplicationContext
orServletContext
.edit--- Looks like it might be an overloaded namespace problem:
Caused by: org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException: Tag [ifnotloggedin] does not exist. No tag library found for namespace: g at home_pmcneil_devel_Groupie_grails_app_views_display_page_gsp.run(home_pmcneil_devel_Groupie_grails_app_views_display_page_gsp:32)
原文:https://stackoverflow.com/questions/1616861
最满意答案
是的,这被认为是,或者可能*导致死锁。
该术语不是绑定到线程或进程 - 而是请求 。
假设您的锁(
mutex
) 不可重入,并假设您的资源在变异时被锁定,并且从多个源变更资源是错误的。 当/如果您的单线程进程尝试在突变中启动数据的新突变并且锁定的非重入锁被请求锁定时会发生什么? 僵局'可能',因为您没有准确指定您正在处理的互斥锁的类型。
yes, that is considered, or would potentially* result in deadlock.
the term is not bound to threads or processes - but requests.
suppose your lock (
mutex
) is not reentrant, and suppose your resource is locked when mutated, and that it is an error to mutate the resource from multiple sources. what happens when/if your single threaded process attempts to initiate a new mutation of the data within a mutation and the non-reentrant lock which is locked is requested to lock? deadlock'potentially', because you have not specified exactly what type of mutex you are dealing with.
相关问答
更多-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
预计像锁定SQL Server / Sybase的RDBMS偶尔发生死锁。 您可以在客户端上进行编码,以按照我的MSDN“处理死锁”的建议进行重试。 基本上,检查SQLException,也许半秒钟后,再试一次。 否则,您应该检查您的代码,以便对表格的所有访问都以相同的顺序进行。 或者你可以使用SET DEADLOCK_PRIORITY来控制谁成为受害者。 在SQL Server的MSDN上有“最小化死锁”启动 尽管无法完全避免死锁 这也提到了“使用较低的隔离级别”(我不喜欢它(与SO中的许多SQL类型相同 ...
-
Q1:事务执行所需的时间使相关进程更有可能被标记为死锁的受害者。 不,SELECT是受害者,因为它只读取数据,因此交易的成本与之相关,因此被选为受害者: 默认情况下,数据库引擎选择运行事务的会话的死锁受害者,回滚成本最低 。 或者,用户可以使用SET DEADLOCK_PRIORITY语句来指定死锁情况下的会话的优先级。 DEADLOCK_PRIORITY可以设置为LOW,NORMAL或HIGH,或者可以设置为范围(-10到10)中的任何整数值。 Q2。 如果我用NOLOCK提示执行选择,这会消除问题吗? ...
-
那么,基于以下定义: 一个僵局是两个或两个以上的竞争行为各等待另一个完成的情况。 我会说答案是肯定的 - 一个线程可以坐在那里等待无限期的东西,但除非两个竞争的动作正在等待对方,根据定义不是一个僵局。 除非有人向我解释一个线程如何同时等待两个动作完成? 更新:我可以想到的唯一可能的情况是某种消息泵,其中线程处理消息,要求其无限期地等待某事发生,其中事实上将由消息泵上的另一消息处理某事物 。 这个(令人难以置信的设计)场景在技术上可能被称为僵局。 The JVM only keeps track of the ...
-
我会在Param1上添加一个到FooTable的索引; 没有它,DELETE正在进行全表扫描,这会产生死锁问题。 编辑 根据您的活动详细信息,它看起来不像您有死锁,您有阻塞,许多删除正在排队,同时发生一次删除。 同样,对Param1进行索引可以缓解这个问题,如果没有它,每次删除都会进行全表扫描以找到要删除的记录,而当发生这种情况时,其他删除必须等待。 如果你有一个关于Param1的索引,它会更快地处理,你不会看到你现在的阻止。 如果你有死锁,系统将杀死其中一个涉及的进程,否则什么都不会处理; 如果表格很大, ...
-
还有Valgrind的Helgrind工具: Helgrind:线程错误检测器 Helgrind是一个Valgrind工具,用于检测使用POSIX pthreads线程原语的C,C ++和Fortran程序中的同步错误。 POSIX pthreads中的主要抽象是:共享公共地址空间的一组线程,线程创建,线程连接,线程退出,互斥(锁),条件变量(线程间事件通知),读写器锁,自旋锁,信号量和障碍。 Helgrind可以检测到三类错误,这些错误将在接下来的三个部分中详细讨论: 错误使用POSIX pthreads ...
-
在一个过程中死锁 - ?(deadlock in a single process -?)[2023-12-16]
是的,这被认为是,或者可能*导致死锁。 该术语不是绑定到线程或进程 - 而是请求 。 假设您的锁( mutex ) 不可重入,并假设您的资源在变异时被锁定,并且从多个源变更资源是错误的。 当/如果您的单线程进程尝试在突变中启动数据的新突变并且锁定的非重入锁被请求锁定时会发生什么? 僵局 '可能',因为您没有准确指定您正在处理的互斥锁的类型。 yes, that is considered, or would potentially* result in deadlock. the term is not b ... -
用信号量避免死锁?(Deadlock avoidance with semaphore?)[2023-09-03]
因为线程可以被阻塞,并且因为对象可以具有阻止线程访问该对象的同步方法等待另一个线程,所以一个线程可能会卡住等待另一个线程,而另一个线程又等待另一个线程等。 Because threads can become blocked and because objects can have synchronized methods that prevent threads from accessing that object util waiting for another thread, it is possib ... -
如果没有SSCCE ,很难知道代码中是否还有其他内容。 一种可能性是在获取锁之后抛出异常。 尝试在try / finally子句中包装每个锁定的部分。 例如。 try: shared_lock.acquire() shared_return_list.extend(acqBuffer) del acqBuffer[:] finally: shared_lock.release() 和: try: self.shared_result_lock.acquire() ...
-
更新存储过程中的死锁(Deadlock in Update Stored Procedure)[2023-02-04]
简短的回答 您可能在表上缺少索引。 首先,您必须检查您的更新是否正在生成表扫描,如果是,请在ID和CID上创建一个索引以查看是否可以解决您的问题。 答案很长 表上的Update语句可以引入表扫描。 这意味着,SQL Server会读取表中的每一行以检查是否需要更新行。 在该读取操作期间,SQL Server在行上发出(U)更新锁定。 如果需要更新行,它会将(U)锁定转换为(X)独占锁定并保持该锁定直到事务结束。 (U)锁与其他(U)或(X)锁不兼容。 在您的情况下,您有2个会话等待彼此。 每个会话将X锁定在 ...