java - 自定义标签库导致 "PWC6033: Unable to compile class for JSP"

标签 java jetty taglib

当我尝试在我的 web 应用程序中使用自定义标签库时,它无法在 OS X(或 Windows)上使用 Eclipse 和 Run Jetty Run。当我 WAR 文件并在运行 apache-tomcat-6.0.20 的 linux 服务器上运行它们时,没有问题。我在两种环境中都使用 3rd 方自定义标签库没有问题。

org.apache.jasper.JasperException: PWC6033: Unable to compile class for JSP

PWC6197: An error occurred at line: 6 in the jsp file: /temp.jsp
PWC6199: Generated servlet error:
com.test cannot be resolved to a type
 at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:107)
 at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:280)
 at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:350)
 at org.apache.jasper.compiler.Compiler.compile(Compiler.java:411)
 ...

自定义的 taglib tld 看起来像

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib PUBLIC 
 "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
 "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
 <tlib-version>1.0</tlib-version>
 <jsp-version>2.0</jsp-version>
 <short-name>test</short-name>
 <uri>http://test.com/test.tld</uri>
 <description>Test</description>

 <tag>
  <name>custom</name>
  <tag-class>com.test.CustomTag</tag-class>
  <body-content>empty</body-content>
  <description>Custom tag</description>
 </tag>
</taglib>

和标签处理程序

package com.test;

import javax.servlet.jsp.tagext.TagSupport;

public class CustomTag extends TagSupport {

 private static final long serialVersionUID = 1L;

}

最后是 temp.jsp

<%@ taglib uri="http://test.com/test.tld" prefix="test" %>
Hi
<test:custom/>

我认为我的 taglib 定义/配置是正确的,因为当部署到 tomcat 时整个东西都能正常工作,但我整天都在尝试使它在 Jetty 中工作但无济于事。

最佳答案

太烦人了!!!!我希望上帝能有人找到这个,它可以节省他们所有我浪费在寻找解决方案上的时间。我相信这是 Jetty 的问题。

我在 com 包中也有一个类 Test。因此,无论出于何种原因,Jetty 都会去寻找 com.test.CustomTag 并最终寻找一个可能位于 com.Test 内部的内部类?无论如何,将 CustomTag 移动到另一个包(或移动或重命名 com.Test)解决了这个问题。

关于java - 自定义标签库导致 "PWC6033: Unable to compile class for JSP",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3217159/

相关文章:

java - jetty 嵌入式: Using CORS + Basic authentication (ConstraintSecurityHandler)

websocket - 如何使用嵌入式 jetty 对 websocket 进行单元测试?

c++ - 在 C++ 中使用 TagLib 删除除 APIC 之外的所有标签

java - Spring 交易超时

java - 如何使用模运算符递增和递减整数

maven - 在 jetty :run startup 之后向用户显示启动消息

java - 如何在struts中使用url对参数进行编码?

eclipse - GWT/Eclipse/Jetty 问题 : Jasper can't resolve tag libraries

Java 和静态成员/函数访问(无需对象)

java - netbeans构建项目错误