我在Tomcat的(7.0.55)的自定義WebappClassLoader這是在server.xml配置爲定製的ClassLoader JSP編譯錯誤
<Context allowCasualMultipartParsing="true">
<Loader loaderClass="org.project.system.core.classloader.DynamicClassLoader" />
</Context>
它的加載和一切都很好,但是當我打開它裝載了類org.test.User這不是WEB-INF/classes目錄下,但通過我的DynamicClassLoader中加載我得到這個錯誤JSP:
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 7 in the generated java file
Only a type can be imported. org.test.User resolves to a package
所以,我做了一些調試,並在每個loadClass的是檢查打電話,如果我的課被加載,是的:就在這個錯誤消息之前,我看到我的調試信息:
Trying to load org.test.User found!
Trying to load org.test NOT FOUND!!
Trying to load org.test NOT FOUND!!
Trying to load org.apache.el.ExpressionFactoryImpl found!
Trying to load com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl found!
Trying to load com.sun.org.apache.xerces.internal.impl.dv.dtd.DTDDVFactoryImpl found!
Trying to load org.apache.el.ExpressionFactoryImpl found!
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 7 in the generated java file
Only a type can be imported. org.test.User resolves to a package
所以看起來,jsp編譯器要求User類。但真正奇怪的是,如果我使用eclipse執行它,一切都正常!當然,輸出看起來與錯誤消息相同。我仔細檢查了eclipse和我的配置文件,但我沒有看到任何區別。
你知道什麼可能是錯的嗎?爲什麼它在eclipse中沒有任何錯誤,但不在「正常」的tomcat安裝中運行?請讓我知道,如果你需要任何進一步的信息!提前致謝!
這些名字就像在例子「org.test.User」中,所以應該不會有命名上的問題,應該如何? – user2084865 2014-09-23 17:22:46
你也有'org.test.user.OtherClass'嗎? – 2014-09-23 20:16:24
是的,這個包裏有多個類。 – user2084865 2014-09-23 21:00:04