开发者

How do I add the j2ee.jar to a Java2WSDL ant script programmatically?

开发者 https://www.devze.com 2022-12-28 03:41 出处:网络
I am using IBM\'s Rational Application Developer. I have an ant script that contains the Java2WSDL task. When I run it via IBM, it gives compiler errors unless I include the j2ee.jar file in the class

I am using IBM's Rational Application Developer. I have an ant script that contains the Java2WSDL task. When I run it via IBM, it gives compiler errors unless I include the j2ee.jar file in the classpath via the run tool (it does not pick up the jar files in the classpath in the script). However, I need to be able to call this script programmatically, and it is giving me this error: "java.lang.NoClassDefFoundError: org.eclipse.core.runtime.CoreException" I'm not sure which jars need to be added or where? Since a simple echo script runs, I assume that it is the j2ee.jar or another ant jar that needs to be added. I've added it to the project's buildpath, but that doesn't help. (I also have ant.jar, wsanttasks.jar, all the ant jars from the plugin, tools.jar, remoteAnt.jar, and the swt - all which are included in the buildpath when you run the script by itself.)


Script:

<?xml version="1.0" encoding="UTF-8"?>                     
<project default="build" basedir=".">

  <path id="lib.path">
    <fileset dir="C:\Program Files\IBM\WebSphere\AppServer\lib" includes="*.jar"/>
            <!-- 
        Adding these does not help.
        <fileset dir="C:\Program Files\IBM\SDP70Shared\plugins\org.apache.ant_1.6.5\lib" includes="*.jar"/>
        <fileset dir="C:\Program Files\IBM\SDP70\jdk\lib" includes="*.jar"/>
        <fileset dir="C:\Program Files\IBM\SDP70\configuration\org.eclipse.osgi\bundles\1139\1\.cp\lib" includes="*.jar"/>
        <fileset dir="C:\Program Files\IBM\S开发者_如何学运维DP70Shared\plugins" includes="*.jar"/>
        -->
  </path>           

  <taskdef name="java2wsdl"
           classname="com.ibm.websphere.ant.tasks.Java2WSDL">
    <classpath refid="lib.path"/>
  </taskdef>

  <target name="build">
      <echo message="Beginning build"/>
    <javac srcdir="C:\J2W_Test\Java2Wsdl_Example"
           destdir="C:\J2W_Test\Java2Wsdl_Example">
      <classpath refid="lib.path"/>
      <include name="WSExample.java"/>
    </javac> 
    <echo message="Set up javac"/>
    <echo message="Running java2wsdl"/>
    <java2wsdl output="C:\J2W_Test\Java2Wsdl_Example\example\META-INF\wsdl\WSExample.wsdl"
               classpath="C:\J2W_Test\Java2Wsdl_Example"
               className= "example.WSExample"
               namespace="http://example"
               namespaceImpl="http://example"
               location="http://localhost:9080/example/services/WSExample"
               style="document"
               use="literal">
      <mapping namespace="http://example" package="example"/>
    </java2wsdl>
    <echo message="Complete"/>
  </target>                

</project>

Code:

  File buildFile = new File("build.xml");
  Project p = new Project();
  p.setUserProperty("ant.file", buildFile.getAbsolutePath());

  DefaultLogger consoleLogger = new DefaultLogger();
  consoleLogger.setErrorPrintStream(System.err);
  consoleLogger.setOutputPrintStream(System.out);
  consoleLogger.setMessageOutputLevel(Project.MSG_INFO);
  p.addBuildListener(consoleLogger);

  try {
   p.fireBuildStarted();
   p.init();
   ProjectHelper helper = ProjectHelper.getProjectHelper();
   p.addReference("ant.projectHelper", helper);
   helper.parse(p, buildFile);
   p.executeTarget(p.getDefaultTarget());
   p.fireBuildFinished(null);
  } catch (BuildException e) {
   p.fireBuildFinished(e);
  }

Error:

[java2wsdl] java.lang.NoClassDefFoundError: org.eclipse.core.runtime.CoreException
[java2wsdl]     at java.lang.J9VMInternals.verifyImpl(Native Method)
[java2wsdl]     at java.lang.J9VMInternals.verify(J9VMInternals.java:68)
[java2wsdl]     at java.lang.J9VMInternals.initialize(J9VMInternals.java:129)
[java2wsdl]     at com.ibm.ws.webservices.multiprotocol.discovery.ServiceProviderManager.getDiscoveredServiceProviders(ServiceProviderManager.java:378)
[java2wsdl]     at com.ibm.ws.webservices.multiprotocol.discovery.ServiceProviderManager.getAllServiceProviders(ServiceProviderManager.java:214)
[java2wsdl]     at com.ibm.ws.webservices.wsdl.fromJava.Emitter.initPluggableBindings(Emitter.java:2704)
[java2wsdl]     at com.ibm.ws.webservices.wsdl.fromJava.Emitter.<init>(Emitter.java:389)
[java2wsdl]     at com.ibm.ws.webservices.tools.ant.Java2WSDL.execute(Java2WSDL.java:122)
[java2wsdl]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[java2wsdl]     at org.apache.tools.ant.Task.perform(Task.java:364)
[java2wsdl]     at org.apache.tools.ant.Target.execute(Target.java:341)
[java2wsdl]     at org.apache.tools.ant.Target.performTasks(Target.java:369)
[java2wsdl]     at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
[java2wsdl]     at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
[java2wsdl]     at att.ant.RunAnt.main(RunAnt.java:32)


A jarfinder search suggests that because you are running outside of the Rational environment, you need access to the Eclipse core jars (perhaps) where that file might be contained.

0

精彩评论

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