2010-07-09 60 views
3

当我尝试在我的webapp中使用自定义taglibs时,它不能在OS X(或Windows)上使用Eclipse和Run Jetty Run运行。当我警告这些文件并在运行apache-tomcat-6.0.20的Linux服务器上运行它们时,没有任何问题。我在这两种环境中都使用第三方自定义taglib,没有问题。custom taglibs cause“PWC6033:Unable to compile class for JSP”

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) 
... 

自定义标签库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中无济于事。

+0

所以在windows现在我已经尝试运行的应用程序运行码头运行,这虽然给出了同样的问题。 – Tyler 2010-07-10 00:19:33

回答

1

SOOOOOOOOOOO恼人的!!!!我希望上帝保佑有人会发现这一点,并且无论何时我都试图找出解决方案,这一切都可以节省下来。我相信这是Jetty的问题。

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

0

我有点问题。 码头,但自定义标签文件(没有taglib)

由于泰勒的职位,我会放弃在这里(10年10月10日在0:45)。我可能会向码头人群陈述我的情况。我无法将自定义标签移动到另一个包,因为它是一个标签文件,并且不会声明包。

在Eclipse中,它工作正常。所有Junit测试运行绿色。 'mvn test'与PWC6033失败,但没有进一步的详细信息。我只能猜测标签文件在部署到服务器时显然运行正确。

如果jetty/maven没有正确解决导入问题,那么这听起来像是一个bug。

为了完整起见,这里是我TAGFILE /WEB-INF/tags/ognl.tag

<%@tag import="de.mypackage.WebUtils" 
%><%@tag body-content="empty" 
%><%@attribute name="value" required="true" 
%><%=WebUtils.ognl(request, value)%> 

凡WebUtils需要HttpServletRequest的,以获取一个属性值和不打印一些其他参数东西变成标准了。

1

得到了解决方案。虽然我的eclipse在编译时没有显示错误。 Jetty运行时没有找到我添加的新类属性。因为maven还没有生成它。

我跑了这两个命令,事情没有问题。与1.6 JDK(而不是默认的JRE) 1. MVN清洁 2. MVN安装-DskipTests

相关问题