无法即时导入JSP编译 [英] Failing import in on-the-fly JSP compilation

查看:82
本文介绍了无法即时导入JSP编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用Apache/Tomcat/Jasper和jboss安装了大型Web应用程序.在开发环境中,JSP是即时编译的.不幸的是,特别是有一个软件包似乎无法导入即时编译.对于某些类,使用完全限定的引用而不是导入是可行的,但并非对所有类都有效.所有有问题的类都放在一个jar中(nonEjb.jar).预编译JSP可以很好地工作,但是每次我们需要更改一个受影响的文件时,都必须这样做,这当然是很痛苦的.这个问题已经存在了很长时间,我真的很想解决这个问题,因为我准备在受灾地区做一些工作.

We have a large web app installation, using Apache/Tomcat/Jasper and jboss. In development environment, JSPs are compiled on the fly. Unfortunately, there is one package in particular that the on-the-fly compilation cannot seem to import. For some of the classes, using fully-qualified references rather than imports works, but not for all. All the classes in question are in a single jar (nonEjb.jar). Pre-compiling the JSPs works fine, but it's of course very painful to have to do that every time we need to change one of the affected files. This problem has existed for quite some time, and I'd really like to resolve it as I'm set to do some work in the affected area.

这是一个小的测试页.第一次导入失败.导入的两个类非常相似,唯一的区别是它们的包装位置. (是的,我已经验证了这两个类的包声明都是正确的.)

Here is a small test page. It fails for the first import. The two classes being imported are very similar, the only significant difference is their package placement. (And yes, I've verified that the package declarations are correct for both classes.)

<%@ page contentType="text/html; charset=utf-8" %>
<%@ page errorPage="/error.jsp" %>

<%@ page import="com.elementk.lms.product.otr.OtrProviderType" %>
<%@ page import="com.elementk.lms.product.course.CourseType" %>

<html>
<body>
<hr>
Displaying the page...
<br>
<%= OtrProviderType.B24x7_PROVIDER.getId() %> value
<br>
<%= CourseType.SELF_STUDY.getId() %> value
</hr>
</body>
<html>

结果:

09 Mar 2010 21:29:40,555 ERROR [K] [RequestTimingFilter.doFilter:65] Unable to compile class for JSP:

An error occurred at line: 6 in the generated java file
The import com.elementk.lms.product.otr cannot be resolved

如果删除导入并完全限定引用(如com.elementk.lms.product.org.OtrProviderType),则会出现相同的错误.

I get the same error if I remove the import and fully-qualify the reference (as com.elementk.lms.product.org.OtrProviderType).

什么可能导致JSP编译器找到其中一个类而不是另一个?

What might be causing the JSP compiler to locate one of the classes but not the other?

推荐答案

我们最终确定了为什么会这样.显然,即时编译器无法区分大小写,并且包com.elementk.lms.product包含一个名为Otr的类.编译器无法区分软件包"com.elementk.lms.product.otr"和类"com.elementk.lms.product.Otr"之间的区别.这解释了为什么即使原始导入为"com.elementk.lms.product.otr.OtrProviderType",错误消息也仅引用"com.elementk.lms.product.otr".

We finally determined why this was happening. Apparently, the on-the-fly compiler doesn't differentiate case, and the package com.elementk.lms.product contains a class named Otr. The compiler couldn't tell the difference between the package "com.elementk.lms.product.otr" and the class "com.elementk.lms.product.Otr". This explains why the error message only cites "com.elementk.lms.product.otr" even when the originating import was "com.elementk.lms.product.otr.OtrProviderType".

我们必须通过基本上避免问题的方式进行修复:我们将软件包重命名.

We had to repair by essentially avoiding the problem: we renamed the package.

这篇关于无法即时导入JSP编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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