Why getting error "The absolute uri: [http://tiles.apache.org/tags-tiles] cannot be resolved in either web.xml or the jar files deployed"

huangapple go评论76阅读模式
英文:

Why getting error "The absolute uri: [http://tiles.apache.org/tags-tiles] cannot be resolved in either web.xml or the jar files deployed"

问题

我有一个使用Spring MVC、JSP和Apache Tiles构建的Java Web应用程序。

相同的WAR文件在Windows 10和Mac上运行良好。

但是在Ubuntu上(Amazon AWS上的18.04版本),我遇到了一个错误:

org.apache.jasper.JasperException: 无法在web.xml或部署在此应用程序中的jar文件中解析绝对uri:[http://tiles.apache.org/tags-tiles]

我的pom.xml文件中有以下与Tiles相关的依赖项...

<dependency>
    <groupId>org.apache.tiles</groupId>
    <artifactId>tiles-jsp</artifactId>
    <version>3.0.7</version>
</dependency>

<dependency>
    <groupId>org.apache.tiles</groupId>
    <artifactId>tiles-autotag</artifactId>
    <version>1.2</version>
    <type>pom</type>
</dependency>

生成的WAR文件在WEB-INF/lib文件夹中有以下JAR文件...

tiles-api-3.0.7.jar
tiles-autotag-core-runtime-1.2.jar
tiles-core-3.0.7.jar
tiles-jsp-3.0.7.jar
tiles-request-api-1.0.6.jar
tiles-request-jsp-1.0.6.jar
tiles-request-servlet-1.0.6.jar
tiles-servlet-3.0.7.jar
tiles-template-3.0.7.jar

另外,请注意,/examples 应用程序似乎正常工作。我对Linux不太熟悉...这可能与Ubuntu相关的文件权限有关吗?

更多堆栈跟踪细节,如果有用的话...

org.springframework.web.util.NestedServletException:请求处理失败;嵌套异常是org.apache.tiles.request.render.CannotRenderException:包含路径'/WEB-INF/jsp/f_layout.jsp'。
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:986)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:870)

[...]

org.apache.tiles.request.render.CannotRenderException:包含路径'/WEB-INF/jsp/f_layout.jsp'的ServletException。
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:399)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:238)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:221)
org.apache.tiles.renderer.DefinitionRenderer.render(DefinitionRenderer.java:59)

[...]

org.apache.jasper.JasperException:无法在web.xml或部署在此应用程序中的jar文件中解析绝对uri:[http://tiles.apache.org/tags-tiles]
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:55)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:293)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:80)
org.apache.jasper.compiler.TagLibraryInfoImpl.generateTldResourcePath(TagLibraryInfoImpl.java:251)
org.apache.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:122)
org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:431)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:489)

英文:

I have a Java web application built with Spring MVC, JSPs, and Apache Tiles.

The same WAR file works fine on Windows 10 and Mac.

But on Ubuntu (18.04 on Amazon AWS) I get an error:

org.apache.jasper.JasperException: The absolute uri: [http://tiles.apache.org/tags-tiles] cannot be resolved in either web.xml or the jar files deployed with this application

My pom.xml file has these tiles-related dependencies ...

&lt;dependency&gt;
	&lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
	&lt;artifactId&gt;tiles-jsp&lt;/artifactId&gt;
	&lt;version&gt;3.0.7&lt;/version&gt;
&lt;/dependency&gt;

&lt;dependency&gt;
    &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
    &lt;artifactId&gt;tiles-autotag&lt;/artifactId&gt;
    &lt;version&gt;1.2&lt;/version&gt;
    &lt;type&gt;pom&lt;/type&gt;
&lt;/dependency&gt;

And the resulting WAR file has the following JAR files in the WEB-INF/lib folder ...

tiles-api-3.0.7.jar
tiles-autotag-core-runtime-1.2.jar
tiles-core-3.0.7.jar
tiles-jsp-3.0.7.jar
tiles-request-api-1.0.6.jar
tiles-request-jsp-1.0.6.jar
tiles-request-servlet-1.0.6.jar
tiles-servlet-3.0.7.jar
tiles-template-3.0.7.jar

Also note, the tomcat /examples application seems to work fine. I'm pretty new to linux ... could this be an Ubuntu-related file permissions thing?

More stack trace details, in case it's useful ...

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.apache.tiles.request.render.CannotRenderException: ServletException including path &#39;/WEB-INF/jsp/f_layout.jsp&#39;.
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:986)
	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:870)

[...]

org.apache.tiles.request.render.CannotRenderException: ServletException including path &#39;/WEB-INF/jsp/f_layout.jsp&#39;.
	org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:399)
	org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:238)
	org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:221)
	org.apache.tiles.renderer.DefinitionRenderer.render(DefinitionRenderer.java:59)

[...]

org.apache.jasper.JasperException: The absolute uri: [http://tiles.apache.org/tags-tiles] cannot be resolved in either web.xml or the jar files deployed with this application
	org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:55)
	org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:293)
	org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:80)
	org.apache.jasper.compiler.TagLibraryInfoImpl.generateTldResourcePath(TagLibraryInfoImpl.java:251)
	org.apache.jasper.compiler.TagLibraryInfoImpl.&lt;init&gt;(TagLibraryInfoImpl.java:122)
	org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:431)
	org.apache.jasper.compiler.Parser.parseDirective(Parser.java:489)

答案1

得分: 2

问题的根本原因是,由于某种原因,Tomcat不再在Tiles库的JAR文件内部寻找TLD文件。有一种方法可以关闭TLD扫描器(<Context processTlds="false" ... />),但我的并没有被关闭。

我不知道我做了什么导致这个问题开始发生 - 我对Tomcat配置进行了很少的更改。

一个解决办法是手动将TLD文件从Tiles JAR文件内复制出,并将其复制到/WEB-INF文件夹中。这样问题就停止了,但之后我将不得不为项目中的许多其他JAR文件执行此操作。(例如:在为Tiles执行此操作后,SpringSecurity也出现了相同的错误)。

最后,我创建了一个新的Ubuntu 18.04实例,并安装了全新的Java和Tomcat副本,一切正常。

更新:

在调整配置文件后,问题很可能是由/var/lib/tomcat8/conf/catalina.properties中的这行代码引起的...

tomcat.util.scan.StandardJarScanFilter.jarsToSkip=\
*.jar,\
[...]

... 这导致在扫描过程中跳过了所有的JAR文件。

英文:

The problem turned out to be that for some reason Tomcat was no longer looking for the Tiles library's TLD file inside the Tiles JAR file. There's a way to turn off TLD scanner (&lt;Context processTlds=&quot;false&quot; ... /&gt;) but mine wasn't turned off.

I don't know what I did to cause this to start happening -- I made very little changes to the tomcat configuration.

A workaround to stop the problem was to manually copy the TLD file from inside the Tiles JAR file and copy it to the /WEB-INF folder. That made the problem stop, but then I'd have to do this for many other JAR files in my project. (For Example: After doing it for Tiles, I got the same error for SpringSecurity).

In the end, I created a new Ubuntu 18.04 instance and installed fresh copies of Java and Tomcat, and everything worked.

UPDATE:

After fiddling with config files, it's likely the problem I had was caused by this line in /var/lib/tomcat8/conf/catalina.properties ...

tomcat.util.scan.StandardJarScanFilter.jarsToSkip=\
*.jar,\
[...]

... which caused all JAR files to get skipped during scanning.

答案2

得分: 1

相同的方法对我也起作用。我正在使用Spring Boot和Apache Tiles-JSP版本3.0.8进行教程。我使用以下命令提取了此jar文件的内容:

jar xf tiles-jsp-3.0.8.jar

这将jar文件的内容写入了我的目录。我在META-INF目录中找到了tld文件。我将它们复制到了我的WEB-INF目录中,重新部署后错误消失了。

英文:

The same thing worked for me. I'm doing a tutorial using spring boot and apache tiles-jsp version 3.0.8. I extracted the contents of this jar using the following:

jar xf tiles-jsp-3.0.8.jar

This wrote the contents of the jar into my directory. I found the tld files in the META-INF directory. I copied them to my WEB-INF directory, redeployed, and the error went away.

huangapple
  • 本文由 发表于 2020年9月16日 07:16:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/63911054.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定