在jar中指定类路径时,Embedded Jetty无法加载JSP taglibs [英] Embedded Jetty fails to load JSP taglibs when classpath specified in jar

查看:133
本文介绍了在jar中指定类路径时,Embedded Jetty无法加载JSP taglibs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个类似的问题似乎无法解决的问题.

I'm running into a problem that doesn't seem to be addressed by the similar questions.

我有一个使用SpringMVC,JSP和taglib嵌入Jetty的应用程序.我使用maven插件生成一个jar,将所有相关的jar捆绑到一个目录中并创建一个清单.

I have an app that embeds Jetty, using SpringMVC, JSPs and taglibs. I use a maven plugin to generate a jar, bundle all the dependent jars into a directory and create a manifest.

当我使用jar(例如java -jar app.jar)运行应用程序时,一切正常,直到我尝试加载为此指定了<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>或任何其他taglib的JSP.

When I run the app using the jar (eg. java -jar app.jar) everything works fine until I try to load a JSP that specifies <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> or any other taglib for that matter.

如果我运行Java并在命令行上指定类路径并显式命名我的主类,则所有方法都可以使用.我已经验证了我的应用程序jar MANIFEST.MF中的Class-Path是正确的.

If I run java and specify the classpath on the command line and name my main class explicitly it all works. I've verified that the Class-Path inside my apps jar MANIFEST.MF is correct.

到目前为止,我已经提出了两个我宁愿避免的变通方法.让我的启动脚本生成类路径并将其放在命令行中.或者,从Jetty jsp-api软件包中拉出.tld文件,并将其作为常规文件使用,这使我可以将它们指定为taglibs.

So far I've come up with 2 work-arounds that I would rather avoid. Have my launch script generate the classpath and put it on the command line. Or, pull the .tld files out of the Jetty jsp-api package and make them available as regular files which allows me to specify them as taglibs.

我的理解是,Jasper应该遍历所有Jar的所有类路径以查找tld文件吗?当在命令行中将jars作为类路径的一部分指定时,它可以工作,但是当在我的应用程序的jar中指定了类路径时,它将失败.

My understanding is that Jasper is supposed to tear through all Jar's all the classpath looking for tld files? When specifying the jars on the command line as part of the classpath it works, but when the class path is specified in my app's jar it fails.

推荐答案

找到了解决方案.事实证明,在嵌入Jetty而不使用它加载Web应用程序时,某些事情由于其非标准约定而无法正常工作.将jar文件指定了类路径后,将tld文件提取到src/main/resources/META-INF/tld即可在运行时找到它们.

Found the solution. Turns out when embedding Jetty, and not using it to load a web application, some things just don't work as its not standard convention. Extracting the tld files into src/main/resources/META-INF/tld allowed them to be found at runtime when the class path is specified in the jar.

这篇关于在jar中指定类路径时,Embedded Jetty无法加载JSP taglibs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆