It's all about the answers!

Ask a question

NPE in startBuildActivity (Ant Script)


Thomas Tardy (3143) | asked Apr 01 '08, 10:54 a.m.
Hi all,

we are trying to move our build environment to Jazz and are struggeling with our existing Ant scripts.


<project name="BaseSolutionPluginBuild" default="generateConfig" xmlns:artifact="antlib:org.apache.maven.artifact.ant">

<import file="/opt/jazz/TeamConcertBuildsystem/buildsystem/buildtoolkit/BuildToolkitTaskDefs.xml"/>

<property name="workspaceDirectory" value="${basedir}/../"/>
<property name="buildApplicationJar" value="IsovBuildApplication.jar"/>

<target name="generateConfig">
<fail message="Property 'project' required" unless="project" />
<fail message="Property 'clientEnvironmentId' required" unless="clientEnvironmentId" />
<fail message="Property 'serverEnvironmentId' required" unless="serverEnvironmentId" />

<startBuildActivity label="before loading pom file ..." autoComplete="true" buildResultUUID="${buildResultUUID}" repositoryAddress="${repositoryAddress}" userId="${jazz.user.name}" password="${jazz.user.password}" />

<artifact:pom id="pom" file="pom.xml" />
<artifact:dependencies filesetId="pom.fileset" versionsId="pom.versions">
<pom refid="pom" />
</artifact:dependencies>

<startBuildActivity verbose="true" label="executing java to generate config ..." autoComplete="true" buildResultUUID="${buildResultUUID}" repositoryAddress="${repositoryAddress}" userId="${jazz.user.name}" password="${jazz.user.password}" />
<java classname="com.ibm.isov.tools.build.BuildConsole" failonerror="true" output="${basedir}/../java-generate-config.log">
<arg value="-workspaceDirectory=${workspaceDirectory}"/>
<arg value="-project=${project}"/>
<arg value="-clientEnvironmentId=${clientEnvironmentId}"/>
<arg value="-serverEnvironmentId=${serverEnvironmentId}"/>
<classpath>
<path location="${buildApplicationJar}" />
<path id="classpath">
<fileset refid="pom.fileset" />
</path>
</classpath>
</java>
<logPublisher filePath="${basedir}/../java-generate-config.log" label="Maven Initialize Database Log" buildResultUUID="${buildResultUUID}" repositoryAddress="${repositoryAddress}" userId="${jazz.user.name}" password="${jazz.user.password}" />
</target>
</project>


We have added a few startBuildActivity tasks to the existing script. The strange thing is, that the first startBuildActivity are working, but after the maven ant tasks are being used, we get a NPE during the execution of the startBuildActivity task (line 20).


<startBuildActivity verbose="true" label="executing java to generate config ..." autoComplete="true" buildResultUUID="${buildResultUUID}" repositoryAddress="${repositoryAddress}" userId="${jazz.user.name}" password="${jazz.user.password}" />



com.ibm.team.repository.common.transport.ServiceMethodInvocationError: java.lang.NullPointerException
at com.ibm.team.repository.transport.client.RemoteTeamService.getAppropriateException(RemoteTeamService.java:505)
at com.ibm.team.repository.transport.client.RemoteTeamService.executeMethod(RemoteTeamService.java:416)
at com.ibm.team.repository.transport.client.RemoteTeamService.invoke(RemoteTeamService.java:176)
at com.ibm.team.repository.transport.client.ServiceInvocationHandler.invoke(ServiceInvocationHandler.java:43)
at $Proxy0.describe(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at com.ibm.team.repository.client.internal.ServiceInterfaceProxy.invokeServiceCall(ServiceInterfaceProxy.java:145)
at com.ibm.team.repository.client.internal.ServiceInterfaceProxy.invoke(ServiceInterfaceProxy.java:80)
at $Proxy0.describe(Unknown Source)
at com.ibm.team.repository.client.internal.TeamRepository$4.run(TeamRepository.java:1220)
at com.ibm.team.repository.client.internal.TeamRepository$4.run(TeamRepository.java:1)
at com.ibm.team.repository.client.internal.TeamRepository$3.run(TeamRepository.java:1061)
at com.ibm.team.repository.common.transport.CancelableCaller.call(CancelableCaller.java:76)
at com.ibm.team.repository.client.internal.TeamRepository.callCancelableService(TeamRepository.java:1054)
at com.ibm.team.repository.client.internal.TeamRepository.internalLogin(TeamRepository.java:1213)
at com.ibm.team.repository.client.internal.TeamRepository.login(TeamRepository.java:480)
at com.ibm.team.build.ant.task.AbstractTeamBuildTask.getTeamRepository(AbstractTeamBuildTask.java:190)
at com.ibm.team.build.ant.task.AbstractPublisherTask.getBuildResult(AbstractPublisherTask.java:167)
at com.ibm.team.build.ant.task.AbstractPublisherTask.doExecute(AbstractPublisherTask.java:112)
at com.ibm.team.build.ant.task.AbstractTeamBuildTask.execute(AbstractTeamBuildTask.java:344)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
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.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
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.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)
at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
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.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)
at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
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.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
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: java.lang.NullPointerException
at com.ibm.team.repository.common.internal.marshal.util.WebServicesSAXXMLHandler.createObjectFromFactory(WebServicesSAXXMLHandler.java:55)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType(XMLHandler.java:1270)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XMLHandler.java:1336)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:970)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:953)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:684)
at com.ibm.team.repository.common.internal.marshal.util.SAXWrapper.startElement(SAXWrapper.java:73)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:179)
at com.ibm.team.repository.common.internal.marshal.util.WebServicesXMLLoadImpl.load(WebServicesXMLLoadImpl.java:76)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:180)
at com.ibm.team.repository.common.internal.marshal.impl.EObjectMarshaller.demarshalInputStreamToObject(EObjectMarshaller.java:491)
at com.ibm.team.repository.transport.client.RemoteTeamService.demarshallEnvelope(RemoteTeamService.java:476)
at com.ibm.team.repository.transport.client.RemoteTeamService.invokePost(RemoteTeamService.java:443)
at com.ibm.team.repository.transport.client.RemoteTeamService.executeMethod(RemoteTeamService.java:392)
... 87 more


If we remove the usage of the maven ant task (lines 15 to 18) the script is working well.

<artifact:pom id="pom" file="pom.xml" />
<artifact:dependencies filesetId="pom.fileset" versionsId="pom.versions">
<pom refid="pom" />
</artifact:dependencies>


Does anybody have an idea what the problem could be with the maven ant tasks?

Thanks for any help!

Regards,
Thomas

5 answers



permanent link
Thomas Tardy (3143) | answered Apr 04 '08, 2:44 a.m.
Does anybody have an idea? Please!

Regards,
Thomas

permanent link
Don Weinand (7851) | answered Apr 04 '08, 10:51 a.m.
JAZZ DEVELOPER
We've been right in the middle of the throws of declaring the M6 milestone build so we have not had a chance to look at this yet. It's tracked in https://jazz.net/jazz/web/projects/Jazz%20Project#action=com.ibm.team.workitem.viewWorkItem&id=49119 and marked for investigation in the RC1 milestone. It's very odd that Maven can some how affect our ability to login to our repository after it executes within the same ant script.


Don Weinand
Jazz Team Build

permanent link
Don Weinand (7851) | answered Apr 07 '08, 8:44 p.m.
JAZZ DEVELOPER
I was able to get some understanding of this problem after a good amount of
painful but interesting debugging. Maven is switching out the context class
loader on the main Ant thread when their task is invoked. Before the Maven
task runs when everything works properly...the main ant thread has a class
loader of...

classLoader Launcher$AppClassLoader (id=113)
sun.misc.Launcher$AppClassLoader@92e78c

After the Maven task runs the class loader is now...

classLoader RealmClassLoader (id=166)
org.codehaus.classworlds.RealmClassLoader@1685e30

EMF can no longer find the appropriate factory as it delegates to the class
loader to find the EMF package. The NPE is then thrown as it attempts to
use the null factory to get the Jazz item type in WebServicesSAXXHandler
while marshalling the request to the server. I hacked into our task a trap
of the class loader before the Maven call and then set it back the next time
our task executed. Everything worked fine again. It seems ridiculous that
Maven is switching the class loader for the main ant thread when their task
executes...at the very least if this insanity is necessary they should be
switching it back.

It appears you can work around this problem by making your pom call into
Maven before you call any of our ant tasks in your build script. We then
appear to get initially loaded into their RealmClassLoader correctly and
everything works ok. Give that a try and see if that works for you too for
now.

Don Weinand
Jazz Team Build

permanent link
Don Weinand (7851) | answered Apr 08 '08, 6:32 p.m.
JAZZ DEVELOPER
This is now an acknowledged problem by Maven in forum post
http://www.nabble.com/Using-Maven-Ant-Tasks-in-a-CI-Environment-with-IBM-Jazz-td16556859s177.html.
Please log a defect with Maven if you'd like them to fix it.

Don Weinand
Jazz Team Build

permanent link
Don Weinand (7851) | answered Apr 09 '08, 4:17 p.m.
JAZZ DEVELOPER
Until Maven gets a chance to fix this I created an ant task that will undo
the switch-a-roo Maven does every time it executes a task. I've attached
the source, a jar and build.xml files I used to test it to
https://jazz.net/jazz/web/projects/Jazz%20Project#action=com.ibm.team.workitem.viewWorkItem&id=49119.
See comment 10 for the details.

Don Weinand
Jazz Team Build

Your answer


Register or to post your answer.