Using Weblogic JWSC Ant task with Maven

This post has been moved to here.

About these ads

34 Responses to Using Weblogic JWSC Ant task with Maven

  1. Vish says:

    Hello,

    Thanks for posting information on “Weblogic JWSC Ant task with Maven”. I was trying to implement exactly as described, but obviously I might be missing something; like classpath setting on my system.

    I’ve been getting following error when I ran project with the command “mvn clean install”.

    [ERROR] BUILD ERROR
    [INFO] ————————————————————————
    [INFO] An Ant BuildException has occured: The following error occurred while executing this line:
    C:\..\workspace\project\src\com\app\webservices-build.xml:103: java.lang.NoClassDefFoundError: com/sun/jav
    adoc/Type

    com.sun.javadoc.Type

    Any insight on resolving the issue will be appreciated.

    Thanks
    Vish

  2. ricardoekm says:

    Hi Vish,
    This class is usually in located in tools.jar. There’s a line that tries to load it:

    classloader classpath="lib/tools.jar" loader="project

    So it’s necessary to copy tools.jar from your JDK (preferably 1.5) to a relative path lib/tools.jar.

    Please let me know if this helps.

    Ricardo

    • Patrick says:

      Sorry, the xml I pasted got trashed…

      Add a dependency after the antrun executions section:

      groupId=com.sun
      artifactId=tools
      version=1.5
      scope=system
      systemPath=${java.home}/../lib/tools.jar

  3. Ark says:

    Hi Ricardo,

    Thanks for your post.

    I’m compiling with JDK 1.6.05 (supplied with WLS 10.3) but I continuing having a problem. Before adding a piece with ant-classloader I was plainly getting an odd NoClassDefNotFoundError for com/sun/javadoc/Type. After – something’s changed. Now I’m getting even a full explanatory why *thing* fails:

    Reason: Error executing ant tasks

    The following error occurred while executing this line:
    ..\build.xml:45: com.bea.util.jam.internal.javadoc.JavadocClassloadingException: An error has occurred while invoking javadoc to inspect your source
    files. This may be due to the fact that $JAVA_HOME/lib/tools.jar does
    not seem to be in your system classloader. One common case in which
    this happens is when using the ‘ant’ tool, which uses a special
    context classloader to load classes from tools.jar.

    This situation elicits what is believed to a javadoc bug in the initial
    release of JDK 1.6. Javadoc attempts to use its own context classloader
    tools.jar but ignores one that may have already been set, which leads
    to some classes being loaded into two different classloaders. The
    telltale sign of this problem is a javadoc error message saying that
    ‘languageVersion() must return LanguageVersion – you might see this
    message in your process’ output.

    This will hopefully be fixed in a later release of JDK 1.6; if a new
    version of 1.6 has become available, you might be able to solve this
    by simply upgrading to the latest JDK.

    Alternatively, you can work around it by simply including
    $JAVA_HOME/lib/tools.jar in the java -classpath
    parameter. If you are running ant, you will need to modify the standard
    ant script to include tools.jar in the -classpath.

    at org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:539)
    at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:384)
    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)…

    etc.

    Maybe something more is still missing here?

    With best regards,
    Arkady

  4. Vishnu Koya says:

    Hi,

    Thanks for the reply Recardo.

    I was using jdk that came with wl10.3, ant version 1.7.1 and maven version 2.0.10.

    I’ve tried setting up the classpath using classloader, but for some reason ant is complaining about the “loader” attribute.

    classloader classpath="C:\bea\jdk160_05\lib\tools.jar;" loader="project"

    Error that I got with above line in Ant:


    [ERROR] BUILD ERROR
    [INFO] ------------------------------------------------------------------------
    [INFO] An Ant BuildException has occured: The following error occurred while executing this line:
    C:\..\build\build.xml:30: classloader doesn't support the "loader" attribute

    The type doesn't support the "loader" attribute.

    We fixed that issue by modifying the file “mvn.bat” located at “MAVEN_HOME\bin”.
    Search for “runm2″ in that file and add “tools.jar” location to the classpath under line “runm2″.

    It look like as follows on my machine.


    @REM Start MAVEN2
    :runm2
    %MAVEN_JAVA_EXE% %MAVEN_OPTS% -classpath C:\bea\jdk160_05\lib\tools.jar;%CLASSWORLDS_JAR% "-Dclassworlds.conf=%M2_HOME%\bin\m2.conf" "-Dmaven.home=%M2_HOME%" org.codehaus.classworlds.Launcher %MAVEN_CMD_LINE_ARGS%
    if ERRORLEVEL 1 goto error
    goto end

    Though this solution doesn’t sound great, but it fixed the problem.

    Can anyone suggest how to fix “loader” attribute problem, so I don’t need to modify Maven files?

    Thanks
    Vishnu Koya

  5. ricardoekm says:

    Hi Ark,
    I think I solved this problem using tools.jar from JDK 1.5.
    As soon as possible I will update with the link where you can get the same file I’m using for my builds.

  6. ricardoekm says:

    Hi Vishnu,
    Could you please post your ant build xml?

  7. Vishnu Koya says:
    
    <project name="focalexposure.webservices.jaxws.java2wsdl" default="all" basedir=".">
    
      <!-- Web Service WLS Ant task definitions -->
      <taskdef name="jwsc"
    	            classpath="${wl.class.path}"
    	            classname="weblogic.wsee.tools.anttasks.JwscTask"
    	            onerror="report" />
    	
      <taskdef name="wldeploy"
      				classpath="${wl.class.path}"
      				classname="weblogic.ant.taskdefs.management.WLDeploy"
      	  			onerror="report" />
    	
      <target name="all" depends="build, deploy"/>
      <target name="build" depends="clean,init,build.ws.server"/> 
    
      <target name="clean">
        <delete dir="${focalexposure.build.dir}/${server.service.ear}" failonerror="false"/>
      </target>
    
      <!-- Target that builds the target Web Service -->
      <target name="init">
        <mkdir dir="${server.service.dir}"/>
      </target>
    
      <!-- Target that builds the target Web Service -->
    
      <target name="build.ws.server" description="Target that builds the target Web Service">
      	<!-- classloader classpath="C:\bea\jdk160_05\lib\tools.jar" loader="project" / -->
      	<javac
      		classpath="${wl.class.path};${focal.class.path};"
      		srcdir="${focalexposure.src.dir}" destdir="${server.service.dir}"
      		includes="FocalWebContext.java"
      	/>
        <jwsc
            srcdir="${focalexposure.src.dir}"
            destdir="${server.service.dir}"
            classpath="${wl.class.path};${focal.class.path};${server.service.dir}"
            fork="true"
            keepGenerated="true"
            deprecation="${deprecation}"
            keepTempFiles="true"
            listfiles="true"
            debug="${debug}">
          <jws file="FocalWebServiceImpl.java" type="JAXRPC" explode="true"/>	
          <jws file="FocalWebServiceImpl.java" type="JAXRPC" wsdlOnly="true" explode="true"/>
        </jwsc>
    	<!-- Y - network drive is mapped to eComm1 -->
    	<copy todir="${server.service.dir}/FocalWebServiceImpl/WEB-INF/lib" overwrite="true">
            <fileset dir="Y:\backup\contractors\FocalExposure\lib" includes="**/*"/>
        </copy>
        <!-- copy *.jsp, *.js to war dir -->
        <copy todir="${server.service.dir}/FocalWebServiceImpl">
            <fileset dir="${focalexposure.ui.dir}/jsps" includes="**/*"/>
            <fileset dir="${focalexposure.ui.dir}/js" includes="**/*"/>
        </copy>
      </target>
    
      <!-- Target that deploys the target Web Services -->
      <target name="deploy.server" description="Target that deploys the target Web Service">
      	<wldeploy
      	        action="deploy"
      	        source="${server.service.dir}"
      	        user="${wls.username}"
      	        password="${wls.password}"
      	        verbose="true"
      	        adminurl="t3://${wls.hostname}:${wls.port}"
      	        targets="${wls.server.name}"
      	        failonerror="${failondeploy}"/>
      </target>
    
      <!-- Target that deploys the all Web Services -->
      <target name="deploy" depends="deploy.server"
              description="Target that deploys the all Web Services">
      </target>
    
      <!-- Target that undeploys the target Web Service -->
      <target name="undeploy.server" description="Target that undeploys the target Web Service">
        <antcall target="common_undeploy">
          <param name="name" value="${focalexposure.service.ear}"/>
        </antcall>
      </target>
    
      <!-- Target that undeploys all Web Service within these sample -->
      <target name="undeploy" depends="undeploy.server"
              description="Target that undeploys all Web Service within these sample">
      </target>
    
      <target name="common_undeploy">
        <wldeploy
            action="undeploy"
            name="${name}"
            user="${wls.username}"
            password="${wls.password}"
            verbose="true"
            adminurl="t3://${wls.hostname}:${wls.port}"
            targets="${wls.server.name}"
            failonerror="false"/>
      </target>
    
    </project>
    
    
    

  8. shikha says:

    Hi ..I am not sure if you were able to solve the issue but I was running into the same issue using weblogic 10.3 with with maven to build ant task, and this is what I ended up doing

    So I am saying -noclasspath i.e. dont use the system classpath at all..
    I dont know if this is the clean way but atleast it works..I was trying to use the clasloader approach stated above..but it doesnot work for me

  9. shikha says:

    I am not sure how to post code here but what I did was =invoking ant using <java tag

  10. ricardoekm says:

    Vishnu,
    Lets try the reverse way. Here is a simple ant build that loads tools.jar using classloader task.
    Please let me know if it works for you.

    Ark,
    You may try to use the tools.jar attached to check if it solves your problem.

  11. Vishnu Koya says:

    Hi Ricardo,

    The simple ant build that you have provided works for just fine. If I use the ant-classloader.jar, tools.jar that you provided in my project, it works. If I replace the tools.jar that you gave with the one that come with Bea WebLogic10.3, my build fails.

    Can you please let me know where you got that tools.jar?

    Thanks
    Vishnu Koya

  12. ricardoekm says:

    Hi Vishnu,
    This tools.jar I got from JDK 1.5, downloaded from SUN website.

  13. Ark says:

    Hi Ricardo,

    I’m sorry for delay: tools.jar from jdk 1.5 does solve the problem of infinite classloader issues and the build finishes well. The tools.jar that comes with jdk 1.6 has a known bug in javadoc class loading, that can be solved only by adding tools.jar to a *system classpath*, adding it to ant classpath doesn’t help.

    Thank you again.
    =Ark

  14. ricardoekm says:

    Great Ark!

  15. Vishnu Koya says:

    Thank you all!

  16. John Fjellstad says:

    Hi,

    I tried to use your example, but keep getting a nullpointerexception. I was wondering if you can see what the problem might be:

    My pom entry:

    org.apache.maven.plugins
    maven-antrun-plugin

    compile

    run

  17. ricardoekm says:

    Hi John,
    Could you please send your pom entry to ricardo.ekm at gmail?

  18. Anandhu says:

    Hi
    I have scenario similar to this.

    Maven version 2.2.1 (needs java 1.5)
    Ant Version 1.6.5 (needs java 1.4)

    Now I need to call my ant build script from maven.
    How should I do that?

  19. Ricardo Mayerhofer says:

    Hi, have you tried maven ant run task? http://maven.apache.org/plugins/maven-antrun-plugin/
    What error shows up?

  20. Dennis H says:

    Thank you for article. It was very helpful. I too had issues with tools.jar with WebLogic 10.3. I wanted to use Maven’s dependency management instead of putting the jdk 1.5 tools.jar in the classpath. So this is the example that worked for me that I wanted to share with others:

    
      org.apache.maven.plugins
      maven-antrun-plugin
      1.4
      
        
          compile
          
            
              
                
                
              
              
                
                  
                
              
              
              
                
                  
                    
                  
                
              
            
          
          
            run
          
        
      
      
    
        
          sun.jdk
          tools
          jdk150_11
          provided
        
      
    
    
  21. Dennis H says:

    Here is the code formatted correctly (I hope):

     
    <plugin>
    	<groupId>org.apache.maven.plugins</groupId>
    	<artifactId>maven-antrun-plugin</artifactId>
    	<version>1.4</version>
    	<executions>
    		<execution>
    			<phase>compile</phase>
    			<configuration>
    				<tasks>
    					<path id="weblogic.jar.classpath">
    						<path location="${BEA103_HOME}/patch_wls1030/profiles/default/sys_manifest_classpath/weblogic_patch.jar"/>
    						<path location="${BEA103_HOME}/wlserver_10.3/server/lib/weblogic.jar"/>
    					</path>
    					<!--
    					<taskdef resource="net/jtools/classloadertask/antlib.xml" classpath="${maven.dependency.jtools.ant-classloadertask.jar.path}"/>
    					-->
    					<taskdef name="jwsc" classname="weblogic.wsee.tools.anttasks.JwscTask" classpathref="weblogic.jar.classpath">
    						<classpath>
    							<path refid="weblogic.jar.classpath"/>
    						</classpath>
    					</taskdef>
    					<property name="maven.compile.classpath" refid="maven.compile.classpath"/>
    					<jwsc destdir="target" classpathref="weblogic.jar.classpath" classpath="${maven.compile.classpath}" verbose="true" debug="true">
    						<module name="${project.artifactId}-${project.version}" explode="true" contextPath="pearsonaccess">
    							<jwsFileSet srcdir="src/main/java/">
    								<include name="**/*.java"/>
    							</jwsFileSet>
    						</module>
    					</jwsc>
    				</tasks>
    			</configuration>
    			<goals>
    				<goal>run</goal>
    			</goals>
    		</execution>
    	</executions>
    	<dependencies>
    		<!-- bea uses jdk tools 1.5  in jwsc causing this error when compiling with jdk tools 1.6: java.lang.NoClassDefFoundError: com/sun/javadoc/Type -->
    		<dependency>
    			<groupId>sun.jdk</groupId>
    			<artifactId>tools</artifactId>
    			<version>jdk150_11</version>
    			<scope>provided</scope>
    		</dependency>
    		<!--
    		<dependency>
    			<groupId>jtools</groupId>
    			<artifactId>ant-classloadertask</artifactId>
    			<version>1.0-RC2</version>
    			<scope>provided</scope>
    		</dependency>
    		-->
    	</dependencies>
    </plugin>
    
  22. ricardoekm says:

    Great Dennis, thank you for this plus.

  23. ms shekar says:

    Need urgent help…
    I am running a jwsc ant task to generate a war file.
    It is working fine for me if I add the weblogic.jar to classpath before running the ant script ( CLASSPATH=/opt/bea/weblogic91/server/lib/weblogic.jar export CLASSPATH)

    But is is not working if i add this in my build.xml as follows

    I am getting the following error.

    [AntUtil.deleteDir] Deleting directory /var/tmp/_927vxb

    BUILD FAILED
    /wls_domains/CIT/cruisecontrol-bin-2.8.3/util/Ivy/build.xml:231: Deployment descriptor: /var/tmp/_927vxb/web.xml does not exist.
    at weblogic.wsee.tools.anttasks.JwscTask.execute(JwscTask.java:184)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:357)
    at org.apache.tools.ant.Target.performTasks(Target.java:385)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
    at org.apache.tools.ant.Main.runBuild(Main.java:698)
    at org.apache.tools.ant.Main.startAnt(Main.java:199)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
    Caused by: Deployment descriptor: /var/tmp/_927vxb/web.xml does not exist.
    at org.apache.tools.ant.taskdefs.War.setWebxml(War.java:95)
    at weblogic.wsee.tools.anttasks.JwscTask.jar(JwscTask.java:397)
    at weblogic.wsee.tools.anttasks.JwscTask.pkg(JwscTask.java:331)
    at weblogic.wsee.tools.anttasks.JwscTask.execute(JwscTask.java:166)
    … 17 more
    — Nested Exception —
    Deployment descriptor: /var/tmp/_927vxb/web.xml does not exist.
    at org.apache.tools.ant.taskdefs.War.setWebxml(War.java:95)
    at weblogic.wsee.tools.anttasks.JwscTask.jar(JwscTask.java:397)
    at weblogic.wsee.tools.anttasks.JwscTask.pkg(JwscTask.java:331)
    at weblogic.wsee.tools.anttasks.JwscTask.execute(JwscTask.java:166)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:357)
    at org.apache.tools.ant.Target.performTasks(Target.java:385)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
    at org.apache.tools.ant.Main.runBuild(Main.java:698)
    at org.apache.tools.ant.Main.startAnt(Main.java:199)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)

    Total time: 1 minute 3 seconds

    I am running weblogic91 in solaries system…….

  24. JmacWay says:

    Hi, I’d be very grateful for an extra pair of eyes to take a look at my problem. I tried many things but I keep getting the notorious error:
    webservices-build.xml:23: com.bea.util.jam.internal.javadoc.JavadocClassloadingException: An error has occurred while invoking javadoc to inspect your source files. This may be due to the fact that $JAVA_HOME/lib/tools.jar

    Here’s the webservices-build.xml:

    And the maven snippet:

    org.apache.maven.plugins
    maven-antrun-plugin

    generate-sources

    run

  25. darshan says:

    @vishnu Koya
    hi vishnu
    @REM Start MAVEN2
    :runm2
    %MAVEN_JAVA_EXE% %MAVEN_OPTS% -classpath C:\bea\jdk160_05\lib\tools.jar;%CLASSWORLDS_JAR% “-Dclassworlds.conf=%M2_HOME%\bin\m2.conf” “-Dmaven.home=%M2_HOME%” org.codehaus.classworlds.Launcher %MAVEN_CMD_LINE_ARGS%
    if ERRORLEVEL 1 goto error
    goto end

    how do i achieve this part in linux platform in mvn.sh file
    exec “$JAVACMD” \
    $MAVEN_OPTS \
    -classpath “${M2_HOME}”/boot/plexus-classworlds-*.jar;”${JAVA_HOME}”/lib/tools.jar \
    “-Dclassworlds.conf=${M2_HOME}/bin/m2.conf” \
    “-Dmaven.home=${M2_HOME}” \
    ${CLASSWORLDS_LAUNCHER} “$@”
    It is giving me errors

  26. Sheri says:

    While the liquid microsoft windows within the position must prevent overfilling, I need to
    confess that one sleepy day we was not having to pay interest and also forgot that I got therefore loaded it alongside liquid the evening before.

    Drip Coffee Maker Commonly Asked queries Precisely what exactly is
    actually the really temperature for brewing coffee?
    all specialist consent which 200 levels is easily the most effective heat
    for brewing coffee.

  27. I must mention that I bought every one of the of the supplies during the dollar store, except my fish.
    whenever the kids boomers become senior citizens, they will have already understand about computers, having being taught through out college and even
    in highschool. And also, naturally, this sharpener is actually affordable and also
    it comes down by way of a great warranty. My husband and also I assist
    whenever needed and also regularly reveal exactly what my son is actually understanding at school.
    The proper store attracting should display every one of the the required
    information and facts that is required for the piece being built.

    expected to constants through their physical mobility, maybe likewise
    sight and also hearing, it presents the reachable challenge to one teacher or tutor in helping a senior learn.
    In fact, I recently wrote looking for bigger benefits through class materials and
    not being nervous to walk in return out the
    door when the store truly not provide up the awesome deals they promote.
    If possible, give consideration to finding term searches that coordinate
    a monthly holiday because most elementary schools touch on the major vacations.

  28. Take avantage d’avantage de tous seuls votre amène qui la mode, le style, ULTRAVIOLET la protection toutefois en plus le la part de légende comme de everything, alors . Ce particulier la collection fera le plaisir chaque un des passionnés D’accessoires pour le
    mois d’été best pour le day hors avec les amis ou à le promenade quant au la plage. qualité de carrera de lunettes à un coût, toutefois en fait moins que le cent euros j’en fait l’un exceptionnel offre vous offre this particulier le site de site Web, donc l’apprécier as partie de ceux-ci les temps de crise nous
    devoir nevertheless sent capable s’amuser. There j’en fait
    aussi le carbone variation j’en fait mon advice le la plupart d’ les versions de gorgeous du exact même .

    Éloigné d’ se reposant sur the passé le succès, récemment là je the vrai la motivation de tout les ces a impliqué dans initiating l’INNOVATION.

  29. le commerce, helped par le roi du roi Michael Jackson, aussi Motivé par
    Tom cruise comme de Idéal Arme, le film achievements. Il had a été mis sur le marché comme de 60
    ans mais à prise loin vingt les ans, 80 déterminer le start du sien awesome Le fera.
    si ne fait pas attente pour le second et gentillement un enjoyed l’un ou votre soi avec ceci le rabais incroyable passé ces lunettes de soleil de carrera bon marché. solaire qui regagne it je shape et aussi remplaçant le métal De high plastique de qualité aidé par le les Chats 5000.

  30. Bricklaying software include the mixer, wall ties, a
    bricklaying trowel, a spacing rule, and also the levels.
    In building construction the force and aesthetic beauty of brick walls, brick pillars depend in the quality of bonds.
    So from preparing the homework in order to final bricklaying Melbourne is actually ready below definitely one roof by
    a few of the reputable construction service providers.
    What Exactly Is desirable is actually a diploma after highschool
    and also this is certainly exclusively if you want to become apprentices.
    Create markings showing the location of each brick to choose as a guide while laying them.

  31. Sweet blog! I found it while surfing around on Yahoo News.

    Do you have any suggestions on how to get listed in Yahoo News?

    I’ve been trying for a while but I never seem to get there! Many thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: