集成 ant - taskdef 类加载器问题
在 Weblogic 10.3 上,我的企业应用程序包含一个在内部运行 ant 脚本的 Web 服务。我的问题是,由于 java.lang.ClassNotFoundExceptions
,我无法运行自定义任务。
(所有这些在 Tomcat 5.5 上都运行良好)
我的任务实现可以在 4 个不同的位置找到:
- something.ear/APP-INF/lib/antaddon.jar!/foo/bar/MyTask.class
- Something.ear/Webservice.war/ WEB-INF/lib/antaddon.jar!/foo/bar/MyTask.class
- some.ear/Webservice.war/WEB-INF/classes/foo/bar/MyTask.class
- server/lib/antaddon.jar!/foo/bar/MyTask.class
我发现 Weblogic 10.3
集成 Ant 1.6.5
模块可能会导致问题 因为我捆绑了 Ant 1.8.0
,所以我添加
<prefer-application-packages>
<package-name>antlr.*</package-name>
<package-name>org.apache.ant.*</package-name>
<package-name>org.apache.zip.*</package-name>
</prefer-application-packages>
到我的 weblogic-application.xml 中来克服这个问题。 (这解决了一些NoSuchMethodErrors
..) 但是我的任务仍然没有找到:
java.lang.ClassNotFoundException: foo.bar.MyTask.class
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:457)
at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:183)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:142)
at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:91)
你能帮我解决这个问题吗?
On Weblogic 10.3 my enterprise application includes a webservice that runs ant scripts inside. My problem is that I cannot get my custom tasks running due to java.lang.ClassNotFoundExceptions
.
(All this works well on Tomcat 5.5)
My task implementation can be found in 4 different locations:
- something.ear/APP-INF/lib/antaddon.jar!/foo/bar/MyTask.class
- something.ear/Webservice.war/WEB-INF/lib/antaddon.jar!/foo/bar/MyTask.class
- something.ear/Webservice.war/WEB-INF/classes/foo/bar/MyTask.class
- server/lib/antaddon.jar!/foo/bar/MyTask.class
I see that the Weblogic 10.3
integrated Ant 1.6.5
module might cause problems
as I have an Ant 1.8.0
bundled, so I added
<prefer-application-packages>
<package-name>antlr.*</package-name>
<package-name>org.apache.ant.*</package-name>
<package-name>org.apache.zip.*</package-name>
</prefer-application-packages>
to my weblogic-application.xml to overcome this. (This solved some NoSuchMethodErrors
..)
However my Task is still not found:
java.lang.ClassNotFoundException: foo.bar.MyTask.class
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:457)
at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:183)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:142)
at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:91)
can you help me how to solve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是我的prefer-application-packages指令是错误的,ant类不在
org.apache.ant.*
中,而是在org.apache.tools.ant.*
中>。修复此问题后,我的自定义类已从 APP-INF/lib/antaddon.jar 加载并运行良好The problem was that my prefer-application-packages directive was wrong, ant classes are not in
org.apache.ant.*
but inorg.apache.tools.ant.*
. After repairing this my custom class gets loaded and works well fromAPP-INF/lib/antaddon.jar