Reading a ditamap in ant xslt task - ant

I'm trying to read ditamap file from my XSLT stylesheet processing using fn:doc() function. But ant fails because DTD public identifier cannot be resolved even if there is catalog file specified.
[ditamap: mKeyDefUi.ditamap]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE map PUBLIC "-//OASIS//DTD DITA Map//EN" "map.dtd">
<map>
<keydef keys="UI_Action">
<topicmeta>
<keywords>
<keyword>処理</keyword>
</keywords>
</topicmeta>
</keydef>
<keydef keys="UI_ActionAfterPrinting">
<topicmeta>
<keywords>
<keyword>印刷終了時の設定</keyword>
</keywords>
</topicmeta>
</keydef>
...
</map>
[ant buld.xml main part]
<property name="key.map.url" value="file:/D:/SVN/acme-dev/VisualWorks/ja-JP/keydef-map/mKeyDefUi.ditamap"/>
<property name="dita.catalog.file" value="/D:/DITA-OT/dita-ot-2.5.2/catalog-dita.xml"/>
...
<!-- Main target -->
<target name="uicontrol.conv">
<echo message="topic.file.prop=${topic.file.prop}"/>
<antcall target="uicontrol.conv.impl">
<param name="prmTopicFileProp" value="${topic.file.prop}"/>
<param name="prmOutputDirUrl" value="${output.dir.url}"/>
<param name="prmKeyMapUrl" value="${key.map.url}"/>
<param name="prmLogFileUrl" value="${log.file.url}"/>
</antcall>
</target>
<target name="uicontrol.conv.impl">
<property name="dummy.input" value="${basedir}/dummy-in.xml"/>
<property name="dummy.output" value="${basedir}/dummy-out.xml"/>
<property name="xsl.file" value="${basedir}/xsl/convUicontrol.xsl"/>
<xslt processor="trax" in="${dummy.input}" out="${dummy.output}" style="${xsl.file}" force="true">
<factory name="net.sf.saxon.TransformerFactoryImpl"/>
<param name="PRM_TOPIC_FILE_PROP" expression="${prmTopicFileProp}"/>
<param name="PRM_OUTPUT_DIR_URL" expression="${prmOutputDirUrl}"/>
<param name="PRM_KEY_MAP_URL" expression="${prmKeyMapUrl}"/>
<param name="PRM_LOG_FILE_URL" expression="${prmLogFileUrl}"/>
<xmlcatalog>
<catalogpath>
<pathelement location="${dita.catalog.file}"/>
</catalogpath>
</xmlcatalog>
</xslt>
</target>
[The ant log]
Executing:
"c:\program files\oxygen xml editor 19\jre/bin/java" -Xmx256m -classpath "C:\Program Files\Oxygen XML Editor 19\tools\ant/lib/ant-launcher.jar" "-Dant.home=C:\Program Files\Oxygen XML Editor 19\tools\ant" org.apache.tools.ant.launch.Launcher -lib "D:\My_Documents\Java\SaxonPE9-8-0-3J\saxon9pe.jar" -lib "D:\My_Documents\Java\xml-commons-resolver-1.2\resolver.jar" -lib "D:\My_Documents\Java\xml-commons-external-1.4.01\xml-apis.jar" -lib "D:\My_Documents\Java\xml-commons-external-1.4.01\xml-apis-ext.jar" -f "build.xml" "-Dwebhelp.trial.license=no" -v -d
Apache Ant(TM) version 1.9.8 compiled on December 25 2016
Buildfile: D:\SVN\acme\key\uicontrol-conv\build.xml
Adding reference: ant.PropertyHelper
Detected Java version: 1.8 in: c:\program files\oxygen xml editor 19\jre
Detected OS: Windows 8.1
...
uicontrol.conv.impl:
Setting project property: dummy.input -> D:\SVN\acme\key\uicontrol-conv/dummy-in.xml
Setting project property: dummy.output -> D:\SVN\acme\key\uicontrol-conv/dummy-out.xml
Setting project property: xsl.file -> D:\SVN\acme\key\uicontrol-conv/xsl/convUicontrol.xsl
[xslt] Using class org.apache.tools.ant.taskdefs.optional.TraXLiaison
[xslt] In file D:\SVN\acme\key\uicontrol-conv\dummy-in.xml time: 1504138459522
[xslt] Out file D:\SVN\acme\key\uicontrol-conv\dummy-out.xml time: 0
[xslt] Style file D:\SVN\acme\key\uicontrol-conv/xsl/convUicontrol.xsl time: 1504138455268
[xslt] Processing D:\SVN\acme\key\uicontrol-conv\dummy-in.xml to D:\SVN\acme\key\uicontrol-conv\dummy-out.xml
[xslt] Loading stylesheet D:\SVN\acme\key\uicontrol-conv\xsl\convUicontrol.xsl
java.lang.NoSuchFieldException: _isNotSecureProcessing
resolve: 'util_string.xsl' with base: 'file:/D:/SVN/acme/key/uicontrol-conv/xsl/convUicontrol.xsl'
Class org.apache.tools.ant.types.resolver.ApacheCatalogResolver loaded from parent loader (parentFirst)
Apache resolver library found, xml-commons resolver will be used
Using catalogpath 'D:\DITA-OT\dita-ot-2.5.2\catalog-dita.xml'
Parsing D:\DITA-OT\dita-ot-2.5.2\catalog-dita.xml
resolve: 'file:/D:/SVN/acme-dev/VisualWorks/ja-JP/keydef-map/mKeyDefUi.ditamap' with base: 'file:/D:/SVN/acme/key/uicontrol-conv/xsl/convUicontrol.xsl'
resolveEntity: '-//OASIS//DTD DITA Map//EN': 'file:/D:/SVN/acme-dev/VisualWorks/ja-JP/keydef-map/map.dtd'
No matching catalog entry found, parser will use: 'file:/D:/SVN/acme-dev/VisualWorks/ja-JP/keydef-map/map.dtd'
[xslt] D:\SVN\acme\key\uicontrol-conv\xsl\convUicontrol.xsl:17:4: Fatal Error! I/O error reported by XML parser processing file:/D:/SVN/acme-dev/VisualWorks/ja-JP/keydef-map/mKeyDefUi.ditamap: D:\SVN\acme-dev\VisualWorks\ja-JP\keydef-map\map.dtd (Specified file does not found.) Cause: java.io.FileNotFoundException: D:\SVN\acme-dev\VisualWorks\ja-JP\keydef-map\map.dtd (Specified file does not found.)
[xslt] Failed to process D:\SVN\acme\key\uicontrol-conv\dummy-in.xml
[antcall] Exiting D:\SVN\acme\key\uicontrol-conv\build.xml.
BUILD FAILED
D:\SVN\acme\key\uicontrol-conv\build.xml:20: The following error occurred while executing this line:
D:\SVN\acme\key\uicontrol-conv\build.xml:32: Fatal error during transformation using D:\SVN\acme\key\uicontrol-conv\xsl\convUicontrol.xsl: I/O error reported by XML parser processing file:/D:/SVN/acme-dev/VisualWorks/ja-JP/keydef-map/mKeyDefUi.ditamap: D:\SVN\acme-dev\VisualWorks\ja-JP\keydef-map\map.dtd (Specified file does not found.); SystemID: file:/D:/SVN/acme/key/uicontrol-conv/xsl/convUicontrol.xsl; Line#: 17; Column#: 4
The xslt task loaded the newest DITA-OT catalog file. But public identifier '-//OASIS//DTD DITA Map//EN' was not resolved.
What is wrong with my build.xml?

You should also try to add a classpath reference to the Xerces library "xercesImpl.jar".
Also this error line in your console output:
java.lang.NoSuchFieldException: _isNotSecureProcessing
would seem to indicate that there is an attempt to use the Xalan TransformerFactoryImpl.

Related

Exception when using sshexec in ant 1.10

I'm trying deploy a PHP application using Ant script. I've put all the necessary jars in the library: ie ant-jsch-1.8.1.jar, jsch-0.1.55.jar
In my script i declare the sshexec and scp as followed:
<path id="jsch.class.path">
<pathelement location="lib/ant-jsch-1.8.1.jar" />
<pathelement location="lib/jsch-0.1.55.jar" />
</path>
<taskdef name="scp" classname="org.apache.tools.ant.taskdefs.optional.ssh.Scp" classpathref="jsch.class.path" />
<taskdef name="sshexec" classname="org.apache.tools.ant.taskdefs.optional.ssh.SSHExec" classpathref="jsch.class.path" />
When the build is executed in Jenkins i get these errors event though the location of the public key is correct:
[sshexec] Caught exception: java.io.FileNotFoundException: /home/jenkins/.ssh/id_dsa (No such file or directory)
[sshexec] Caught exception: java.io.FileNotFoundException: /home/jenkins/.ssh/id_dsa (No such file or directory)
[scp] Caught exception: java.io.FileNotFoundException: /home/jenkins/.ssh/id_dsa (No such file or directory)
The weird thing is when i run the build script locally on my machine it works fine.
Any help would be much appreciated.
The issue was that I had a variable that holds the path to the private key, the string probably had an extra space or character and ANT got confused. I replaced variable with the direct path of the private key and it worked. To reuse the variable I copied the path and assigned it to the same variable in run command.

Unable to pass context root to .war application in websphere using wsadmin

I need a little help in updating the context root for my war in my Websphere 8.5 appserver. I have a war file called DefaultApplication.war and during manual deployment through websphere console, iam able to set the context-root. Now i ahve requirment of automating the current flow and i choosed to write ant script to install the war file. Below is the code
<target name="installEAR" depends="uninstallEAR">
<fail unless="wasHome.dir">The property "wasHome.dir" must be specified.
</fail>
<fail unless="appName">The property "appName" must be specified.</fail>
<fail unless="deployEar">The property "deployEar" must be specified.</fail>
<echo message="Deployable EAR File found at: ${deployEar}" />
<wsInstallApp ear="${deployEar}"
options="-appname ${appName} -cell ${was.cell} -node ${was.node} -usedefaultbindings"
wasHome="${wasHome.dir}"
conntype="${connType}"
port="${port}"
host="${hostName}"
user="${userId}"
password="${password}"
failonerror="true" />
</target>
As mentioned in above code, iam setting -usedefaultbindings to use and i have ibm-web-ext.xml file in WEB-INF folder of war file.
Context of ibm-web-ext.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-ext
xmlns="http://websphere.ibm.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee
http://websphere.ibm.com/xml/ns/javaee/ibm-web-ext_1_1.xsd"
version="1.1">
<context-root uri="test"/>
</web-ext>
After deployment my apllication is getting started but unable to access it through /test context path. please help me on this.
Thanks in advance.
You must specify Servlet 3.0 or 3.1 in your web.xml, or ibm-web-ext.xml will not be interpreted. For 2.4, a similar file called ibm-web-ext.xmi is interpreted instead.

Error occurring in command promt while sending command for generating xslt reports

can anyone please help me on this .
I am trying to generate xslt reports using ANT and testng.
I amd using eclipse and have created the project successfully and all the test cases which is running successfully using testNG and reports are also generating.
Now I want to generate reports using ANT , for this I have configures ANT in my system successfully and all other thing (build.xml) are also running fine,
TILL , I type "ant makexsltreports" in command prompt on this point it is throwing the below error in command prompt :-
BUILD FAILED
D:\Projects\Projectname\Selenium\Workspace\build.xml:111: Fatal error during trans
formation using D:\Projects\Projectname\Selenium\Workspace\src\testing\xslt\testng
-results.xsl: org.xml.sax.SAXParseException; systemId: file:/D:/Projects/Plumsli
ce/Selenium/Workspace/src/testing/xslt/testng-results.xsl; lineNumber: 27; colum
nNumber: 72; Attribute name "data-pjax-transient" associated with an element typ
e "meta" must be followed by the ' = ' character.
now , this is the 111 line in build.xml file : -
out="${ws.home}/XSLT_Reports/output/index.html" classpathref="test.c" processor="SaxonLiaison">
below is the build.xml file : -
<target name="makexsltreports">
<mkdir dir="${ws.home}/XSLT_Reports/output"/>
<xslt in="${ng.result}/testng-results.xml" style="src/com/testing/xslt/testng-results.xsl"
out="${ws.home}/XSLT_Reports/output/index.html" classpathref="test.c" processor="SaxonLiaison">
<param name="testNgXslt.outputDir" expression="${ws.home}/XSLT_Reports/output/"/>
<param name="testNgXslt.showRuntimeTotals" expression="true"/>
</xslt>
</target>
And this is
I have resolved this ...the problem was -- I was using wrong .xsl file , now I am using new .xsl file and it is generating reports and working fine....

TeamCity deploy to Tomcat with Ant fails

I'm running TeamCity 7 on Ubuntu 12, and I'm trying to deploy a war file to a tomcat server on machine with IP x using Ant.
The thing is - this worked on a different machine with TeamCity 7, and the only thing I've changed is the machine (moved to Ubuntu running on KVM), and the TC version (upgrade).
I've set ANT_HOME to the correct location, and I see the TC is using it in the build log:
... -Dant.home=/usr/share/ant ...
I've added the following jars to my ANT_HOME/lib:
catalina-ant, tomcat-coyote, tomcat-juli, tomcat-util
The build is running on an agent which has the default Ant settings
My ant file looks like this:
<target name="deploy.to.server">
<property name="port" value="${tomcat.port}"/>
<property name="tomcat.manager" value="manager/text"/>
<property name="url" value="http://${tomcat.server}:${port}/${tomcat.manager}"/>
<property name="path" value="/${server.name}"/>
<echo message="Deploying application to ${url}"/>
<antcall target="undeploy.from.tomcat"/>
<sleep seconds="3"/>
<antcall target="deploy.to.tomcat"/>
</target>
<taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"/>
<taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"/>
<target name="deploy.to.tomcat" description="Install web application">
<deploy url="${url}" username="${username}" password="${password}"
path="${path}" war="${work.dir}/${path}.war"/>
</target>
<target name="undeploy.from.tomcat" description="Remove web application">
<undeploy url="${url}" username="${username}" password="${password}"
path="${path}"/>
</target>
I've got this in the TC log:
[Step 1/2] Starting: /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java -Dagent.home.dir=/home/system/dev/TeamCity/buildDeployAgent -Dagent.name=Deploy Agent -Dagent.ownPort=9091 -Dagent.work.dir=/home/system/dev/TeamCity/buildDeployAgent/work -Dant.home=/usr/share/ant -Dbuild.number=131 -Dbuild.vcs.number.Nutrino_Monitor_sources=588 -Dbuild.vcs.number.Nutrino_build_scripts=590 -Dfile.encoding=ANSI_X3.4-1968 -Dfile.separator=/ -Djava.io.tmpdir=/home/system/dev/TeamCity/buildDeployAgent/temp/buildTmp -Dos.arch=amd64 -Dos.name=Linux -Dos.version=3.5.0-19-generic -Dpath.separator=: -Dteamcity.agent.cpuBenchmark=684 -Dteamcity.agent.dotnet.agent_url=http://localhost:9091/RPC2 -Dteamcity.agent.dotnet.build_id=45574 -Dteamcity.auth.password=mlTjdmhOxwfxuM6vGfcQPsKg81q29rFU -Dteamcity.auth.userId=TeamCityBuildId=45574 -Dteamcity.build.changedFiles.file=/home/system/dev/TeamCity/buildDeployAgent/temp/buildTmp/changedFiles7524737972530602224.txt -Dteamcity.build.checkoutDir=/home/system/dev/TeamCity/Builds/DeployNutritionServer -Dteamcity.build.id=45574 -Dteamcity.build.properties.file=/home/system/dev/TeamCity/buildDeployAgent/temp/buildTmp/teamcity.build3049879068391711216.properties -Dteamcity.build.tempDir=/home/system/dev/TeamCity/buildDeployAgent/temp/buildTmp -Dteamcity.build.workingDir=/home/system/dev/TeamCity/Builds/DeployNutritionServer -Dteamcity.buildConfName=Deploy to Integration -Dteamcity.buildType.id=bt38 -Dteamcity.configuration.properties.file=/home/system/dev/TeamCity/buildDeployAgent/temp/buildTmp/teamcity.config301718488736388101.properties -Dteamcity.projectName=Nutrition Builds -Dteamcity.runner.properties.file=/home/system/dev/TeamCity/buildDeployAgent/temp/buildTmp/teamcity.runner1078243400245029410.properties -Dteamcity.runtime.props.file=/home/system/dev/TeamCity/buildDeployAgent/temp/agentTmp/ant7992360137092769527runtime -Dteamcity.tests.recentlyFailedTests.file=/home/system/dev/TeamCity/buildDeployAgent/temp/buildTmp/testsToRunFirst5600043147441131768.txt -Dteamcity.version=7.1.2 (build 24170) -Dtomcat.server=integration -Duser.country=US -Duser.home=/home/system -Duser.language=en -Duser.name=system -Duser.timezone=Asia/Jerusalem -Dwork.dir=/home/system/dev/TeamCity/Builds/DeployNutritionServer -classpath /usr/share/java/ant-launcher-1.8.2.jar org.apache.tools.ant.launch.Launcher -lib /home/system/dev/TeamCity/buildDeployAgent/plugins/antPlugin/ant-runtime.jar:/home/system/dev/TeamCity/buildDeployAgent/lib/runtime-util.jar -listener jetbrains.buildServer.agent.ant.AgentBuildListener -buildfile /home/system/dev/TeamCity/Builds/DeployNutritionServer/build/deploy.xml deploy.nutrino.server
[15:06:21][Step 1/2] in directory: /home/system/dev/TeamCity/Builds/DeployNutritionServer
[15:06:21][Step 1/2] taskdef
[15:06:21]
[taskdef] taskdef class org.apache.catalina.ant.DeployTask cannot be found
using the classloader AntClassLoader[]
[15:06:21]
[Step 1/2] The following error occurred while executing this line:
/home/system/dev/TeamCity/Builds/DeployNutritionServer/build/tomcat.tasks.xml:9: taskdef class org.apache.catalina.ant.DeployTask cannot be found
using the classloader AntClassLoader[]
[15:06:21][Step 1/2] Process exited with code 1
[15:06:21][Step 1/2] Ant output
[15:06:21][Ant output] Buildfile: /home/system/dev/TeamCity/Builds/DeployNutritionServer/build/deploy.xml
[15:06:21][Ant output]
[15:06:21][Ant output] BUILD FAILED
[15:06:21][Ant output] /home/system/dev/TeamCity/Builds/DeployNutritionServer/build/deploy.xml:8: The following error occurred while executing this line:
[15:06:21][Ant output] /home/system/dev/TeamCity/Builds/DeployNutritionServer/build/tomcat.tasks.xml:9: taskdef class org.apache.catalina.ant.DeployTask cannot be found
[15:06:21][Ant output] using the classloader AntClassLoader[]
[15:06:21][Ant output]
[15:06:21][Ant output] Total time: 0 seconds
[15:06:22][Step 1/2] Step Deploy (Ant) failed
Now, this is extremely weird, as when I run this from the command line it works perfectly:
ant -buildfile deploy.xml -Dtomcat.server= ...
There is no apparent difference between the two - running it from the CL and through the TC agent should both be running Ant from ANT_HOME (usr/share/ant), and loading the libraries in $ANT_HOME/lib.
Any help would be appreciated.
:)
Thanks!
Just answering the question,
Thanks to #timomeinen - adding the catalina-ant.jar to $ANT_HOME/lib did the job.
That means it is not seeing the lib catalina-ant.jar
You can add:
classname="org.apache.catalina.ant.DeployTask"
classpath="C:\Programming\Tomcat\Instances\8080\lib\catalina-ant.jar"
It will solve this reference problem, but I guess you will face similar problems in the future with other libraries, so in the long term you will still need solve the reference problem.

Ant rpm build fails due to unknown option '-bs'

build.xml
<?xml version="1.0"?>
<project default="main" basedir=".">
<echo message="pulling in property files" />
<property file="axis_bujava.properties" />
<echo message="calling the RPM Build Ant" />
<target name="main">
<rpm specfile="example.spec" topdir="${basedir}" command="-bs" />
</target>
</project>
example.spec
Summary: xxx
Name: cdplayer
Version: 1.0
Release: 1
Copyright: xxx
Group: Applications/Sound
Source: xxx.tgz
URL: http://xxx.html
Distribution: xxxx
Vendor:xxx.
Packager: xxx
%description
xxxx
%build
make
%install
make install
output:
Buildfile: /home/user1/workspace/antdemo/build.xml
[echo] pulling in property files
[echo] calling the RPM Build Ant
main:
[rpm] Building the RPM based on the example.spec file
[rpm] -bs: unknown option
[rpm] 'rpm' failed with exit code 1
BUILD SUCCESSFUL
Total time: 848 milliseconds
I had this issue too. In my case the OS did not have the 'rpmbuild' command installed, so the ant task was calling 'rpm' instead as Aaron suggested.
While I'm not sure what "-bs" option is, you might try changing it to "-bb", which is the default. My own builds, plus a few I've seen, usually use -bb (http://richardfriedman.blogspot.com/2007/02/rpm-java-and-frustration.html)
Also see:
http://ant.apache.org/manual/Tasks/rpm.html

Resources