开发者

Integrated ant - taskdef classloader issue

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 th开发者_运维知识库is 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?


The problem was that my prefer-application-packages directive was wrong, ant classes are not in org.apache.ant.* but in org.apache.tools.ant.*. After repairing this my custom class gets loaded and works well from APP-INF/lib/antaddon.jar

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜