MavenReporter throws Serialization Exception for ProjectActions when writing to build.xml

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

MavenReporter throws Serialization Exception for ProjectActions when writing to build.xml

Ulli Hafner-2
Hi,

I tried to add native maven2 to the tasks plug-in. While I managed it to register the plugin (with GUI configuration) in a native maven build (hudson 1.153), e.g. in the compile step, I did not have success to add the persisted build results. What actually is not clear for me, if I should use the hooks for the MavenBuild or the MavenBuildProxy.

1.)  public boolean end(MavenBuild build, Launcher launcher, BuildListener listener)
            throws InterruptedException, IOException {

When I try to reuse the code of my freestyle Publisher in this method, then I could scan for the tasks in the workspace and could publish the results on the build page (as with the freestyle project), however the build actions are not persisted. (This should also produce problems if running the build remote). And its not clear for which submodule (pom) I'm currently running.

Then I tried the second method:

2.)   public boolean postExecute(final MavenBuildProxy build, final MavenProject pom, final MojoInfo mojo,
            final BuildListener listener, final Throwable error) throws InterruptedException, IOException {

Here I could access the files as expected (on a remote machine) and scan for the tasks. However, when trying to pushing the results from the proxy to the actual MavenBuild, then the serialization of the build.xml throws Exceptions messages after the build. I tried to be as close to the SurefireReporterwhen implementing my MavenReporter, but I had no success.

Do you have any ideas?

Here is the code (I removed unimportant parts) and the exception stacktrace:

    /** {@inheritDoc} */
    @Override
    public boolean postExecute(final MavenBuildProxy build, final MavenProject pom, final MojoInfo mojo,
            final BuildListener listener, final Throwable error) throws InterruptedException, IOException {
        if (!"compile".equals(mojo.getGoal())) {
            return true;
        }
        listener.getLogger().println("Scanning workspace files for tasks...");
        FilePath filePath = new FilePath(pom.getBasedir());
        final JavaProject project = filePath.act(new WorkspaceScanner(StringUtils.defaultIfEmpty(pattern, DEFAULT_PATTERN), high, normal, low));

        build.execute(new BuildCallable<Void, IOException>() {
            public Void call(final MavenBuild build) throws IOException, InterruptedException {
                Object previous = build.getPreviousBuild();
                TasksResult result = new TasksResult(build, project, high, normal, low);
                HealthReportBuilder healthReportBuilder = new HealthReportBuilder("Task Scanner", "open task", isThresholdEnabled, minimumTasks, isHealthyReportEnabled, healthyTasks, unHealthyTasks);
                build.getActions().add(new TasksResultAction(build, result, healthReportBuilder));

                return null;
            }
        });

        int warnings = project.getNumberOfAnnotations();
        if (warnings > 0) {
            listener.getLogger().println("A total of " + warnings + " open tasks have been found.");
            if (isThresholdEnabled && warnings >= minimumTasks) {
                build.setResult(Result.UNSTABLE);
            }
        }
        else {
            listener.getLogger().println("No open tasks have been found.");
        }

        return true;
    }

For all of the three non-transient fields in the class TasksResultAction(build, result, healthReportBuilder) I get the following exception. Note
That the same TasksResultAction is used in the freestyle project, and here it is correctly serialized to the build.xml file.

[INFO] Using default encoding to copy filtered resources.
[INFO] [psteclipse:update {execution: update}]
[INFO] Defaulting prefixes to the single prefix 'com.avaloq.'.
Downloading: http://repo1.maven.org/maven2/com/avaloq/adt/org.junit.junit/3.8.2/org.junit.junit-3.8.2.pom
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
Scanning workspace files for tasks...
A total of 108 open tasks have been found.
[HUDSON] Archiving C:\Build\Results\jobs\MAVEN-DEMO\workspace\com.avaloq.util\pom.xml
[HUDSON] Archiving C:\Build\Results\jobs\MAVEN-DEMO\workspace\com.avaloq.util\pom.xml
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Could not get field class java.lang.reflect.Field.owner : Can not set hudson.model.AbstractBuild field hudson.plugins.tasks.util.AbstractResultAction.owner to hudson.plugins.tasks.TasksResultAction
[INFO] ------------------------------------------------------------------------
[INFO] Trace
com.thoughtworks.xstream.converters.reflection.ObjectAccessException: Could not get field class java.lang.reflect.Field.owner : Can not set hudson.model.AbstractBuild field hudson.plugins.tasks.util.AbstractResultAction.owner to hudson.plugins.tasks.TasksResultAction
        at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:111)
        at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:73)
        at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:65)
        at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:55)
        at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:50)
        at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:52)
        at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:44)
        at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:55)
        at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:50)
        at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:139)
        at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:131)
        at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:107)
        at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:109)
        at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:92)
        at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:65)
        at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:55)
        at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:50)
        at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:73)
        at com.thoughtworks.xstream.core.ReferenceByXPathMarshallingStrategy.marshal(ReferenceByXPathMarshallingStrategy.java:34)
        at com.thoughtworks.xstream.XStream.marshal(XStream.java:751)
        at com.thoughtworks.xstream.XStream.marshal(XStream.java:740)
        at com.thoughtworks.xstream.XStream.toXML(XStream.java:721)
        at hudson.XmlFile.write(XmlFile.java:138)
        at hudson.model.Run.save(Run.java:756)
        at hudson.maven.MavenBuild$ProxyImpl2.end(MavenBuild.java:254)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:187)
        at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:170)
        at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:130)
        at hudson.remoting.UserRequest.perform(UserRequest.java:69)
        at hudson.remoting.UserRequest.perform(UserRequest.java:23)
        at hudson.remoting.Request$2.run(Request.java:200)
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: Can not set hudson.model.AbstractBuild field hudson.plugins.tasks.util.AbstractResultAction.owner to hudson.plugins.tasks.TasksResultAction
        at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source)
        at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source)
        at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(Unknown Source)
        at sun.reflect.UnsafeObjectFieldAccessorImpl.get(Unknown Source)
        at java.lang.reflect.Field.get(Unknown Source)
        at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:108)
        ... 40 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10 seconds
[INFO] Finished at: Sun Nov 11 00:14:15 CET 2007
[INFO] Final Memory: 6M/11M
[INFO] ------------------------------------------------------------------------
channel stopped
finished: FAILURE
--
Avaloq - essential for banking.
 
Avaloq Evolution AG
Allmendstrasse 140, 8027 Zürich
T +41 44 488 6790, F +41 44 488 6868, http://www.avaloq.com 
Dr. Ullrich Hafner, mailto:[hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: MavenReporter throws Serialization Exception for ProjectActions when writing to build.xml

Kohsuke Kawaguchi
Administrator
Any chance you can commit that to a branch so that I can take a look?

This appears to be happening when build.xml gets serialized, and so
maybe a XStream issue.

2007/11/10, Hafner Ullrich <[hidden email]>:

> Hi,
>
> I tried to add native maven2 to the tasks plug-in. While I managed it to register the plugin (with GUI configuration) in a native maven build (hudson 1.153), e.g. in the compile step, I did not have success to add the persisted build results. What actually is not clear for me, if I should use the hooks for the MavenBuild or the MavenBuildProxy.
>
> 1.)  public boolean end(MavenBuild build, Launcher launcher, BuildListener listener)
>             throws InterruptedException, IOException {
>
> When I try to reuse the code of my freestyle Publisher in this method, then I could scan for the tasks in the workspace and could publish the results on the build page (as with the freestyle project), however the build actions are not persisted. (This should also produce problems if running the build remote). And its not clear for which submodule (pom) I'm currently running.
>
> Then I tried the second method:
>
> 2.)   public boolean postExecute(final MavenBuildProxy build, final MavenProject pom, final MojoInfo mojo,
>             final BuildListener listener, final Throwable error) throws InterruptedException, IOException {
>
> Here I could access the files as expected (on a remote machine) and scan for the tasks. However, when trying to pushing the results from the proxy to the actual MavenBuild, then the serialization of the build.xml throws Exceptions messages after the build. I tried to be as close to the SurefireReporterwhen implementing my MavenReporter, but I had no success.
>
> Do you have any ideas?
>
> Here is the code (I removed unimportant parts) and the exception stacktrace:
>
>     /** {@inheritDoc} */
>     @Override
>     public boolean postExecute(final MavenBuildProxy build, final MavenProject pom, final MojoInfo mojo,
>             final BuildListener listener, final Throwable error) throws InterruptedException, IOException {
>         if (!"compile".equals(mojo.getGoal())) {
>             return true;
>         }
>         listener.getLogger().println("Scanning workspace files for tasks...");
>         FilePath filePath = new FilePath(pom.getBasedir());
>         final JavaProject project = filePath.act(new WorkspaceScanner(StringUtils.defaultIfEmpty(pattern, DEFAULT_PATTERN), high, normal, low));
>
>         build.execute(new BuildCallable<Void, IOException>() {
>             public Void call(final MavenBuild build) throws IOException, InterruptedException {
>                 Object previous = build.getPreviousBuild();
>                 TasksResult result = new TasksResult(build, project, high, normal, low);
>                 HealthReportBuilder healthReportBuilder = new HealthReportBuilder("Task Scanner", "open task", isThresholdEnabled, minimumTasks, isHealthyReportEnabled, healthyTasks, unHealthyTasks);
>                 build.getActions().add(new TasksResultAction(build, result, healthReportBuilder));
>
>                 return null;
>             }
>         });
>
>         int warnings = project.getNumberOfAnnotations();
>         if (warnings > 0) {
>             listener.getLogger().println("A total of " + warnings + " open tasks have been found.");
>             if (isThresholdEnabled && warnings >= minimumTasks) {
>                 build.setResult(Result.UNSTABLE);
>             }
>         }
>         else {
>             listener.getLogger().println("No open tasks have been found.");
>         }
>
>         return true;
>     }
>
> For all of the three non-transient fields in the class TasksResultAction(build, result, healthReportBuilder) I get the following exception. Note
> That the same TasksResultAction is used in the freestyle project, and here it is correctly serialized to the build.xml file.
>
> [INFO] Using default encoding to copy filtered resources.
> [INFO] [psteclipse:update {execution: update}]
> [INFO] Defaulting prefixes to the single prefix 'com.avaloq.'.
> Downloading: http://repo1.maven.org/maven2/com/avaloq/adt/org.junit.junit/3.8.2/org.junit.junit-3.8.2.pom
> [INFO] [compiler:compile]
> [INFO] Nothing to compile - all classes are up to date
> Scanning workspace files for tasks...
> A total of 108 open tasks have been found.
> [HUDSON] Archiving C:\Build\Results\jobs\MAVEN-DEMO\workspace\com.avaloq.util\pom.xml
> [HUDSON] Archiving C:\Build\Results\jobs\MAVEN-DEMO\workspace\com.avaloq.util\pom.xml
> [INFO] ------------------------------------------------------------------------
> [ERROR] FATAL ERROR
> [INFO] ------------------------------------------------------------------------
> [INFO] Could not get field class java.lang.reflect.Field.owner : Can not set hudson.model.AbstractBuild field hudson.plugins.tasks.util.AbstractResultAction.owner to hudson.plugins.tasks.TasksResultAction
> [INFO] ------------------------------------------------------------------------
> [INFO] Trace
> com.thoughtworks.xstream.converters.reflection.ObjectAccessException: Could not get field class java.lang.reflect.Field.owner : Can not set hudson.model.AbstractBuild field hudson.plugins.tasks.util.AbstractResultAction.owner to hudson.plugins.tasks.TasksResultAction
>         at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:111)
>         at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:73)
>         at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:65)
>         at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:55)
>         at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:50)
>         at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:52)
>         at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:44)
>         at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:55)
>         at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:50)
>         at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:139)
>         at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:131)
>         at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:107)
>         at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:109)
>         at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:92)
>         at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:65)
>         at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:55)
>         at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:50)
>         at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:73)
>         at com.thoughtworks.xstream.core.ReferenceByXPathMarshallingStrategy.marshal(ReferenceByXPathMarshallingStrategy.java:34)
>         at com.thoughtworks.xstream.XStream.marshal(XStream.java:751)
>         at com.thoughtworks.xstream.XStream.marshal(XStream.java:740)
>         at com.thoughtworks.xstream.XStream.toXML(XStream.java:721)
>         at hudson.XmlFile.write(XmlFile.java:138)
>         at hudson.model.Run.save(Run.java:756)
>         at hudson.maven.MavenBuild$ProxyImpl2.end(MavenBuild.java:254)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>         at java.lang.reflect.Method.invoke(Unknown Source)
>         at hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:187)
>         at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:170)
>         at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:130)
>         at hudson.remoting.UserRequest.perform(UserRequest.java:69)
>         at hudson.remoting.UserRequest.perform(UserRequest.java:23)
>         at hudson.remoting.Request$2.run(Request.java:200)
>         at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
>         at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
>         at java.util.concurrent.FutureTask.run(Unknown Source)
>         at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
>         at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
>         at java.lang.Thread.run(Unknown Source)
> Caused by: java.lang.IllegalArgumentException: Can not set hudson.model.AbstractBuild field hudson.plugins.tasks.util.AbstractResultAction.owner to hudson.plugins.tasks.TasksResultAction
>         at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source)
>         at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source)
>         at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(Unknown Source)
>         at sun.reflect.UnsafeObjectFieldAccessorImpl.get(Unknown Source)
>         at java.lang.reflect.Field.get(Unknown Source)
>         at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:108)
>         ... 40 more
> [INFO] ------------------------------------------------------------------------
> [INFO] Total time: 10 seconds
> [INFO] Finished at: Sun Nov 11 00:14:15 CET 2007
> [INFO] Final Memory: 6M/11M
> [INFO] ------------------------------------------------------------------------
> channel stopped
> finished: FAILURE
> --
> Avaloq - essential for banking.
>
> Avaloq Evolution AG
> Allmendstrasse 140, 8027 Zürich
> T +41 44 488 6790, F +41 44 488 6868, http://www.avaloq.com
> Dr. Ullrich Hafner, mailto:[hidden email]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


--
Kohsuke Kawaguchi

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: MavenReporter throws Serialization Exception for ProjectActions when writing to build.xml

Ulli Hafner-2
I already committed that. (Since I didn't release the plug-in, nobody should have problems with that:-)

If you build the tasks plugin from HEAD you should see these errors when you activate this plug-in for a maven build. The maven part of the plug-in is in the TasksReporter class.

Thanks for helping, Ulli

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Kohsuke Kawaguchi
> Sent: Dienstag, 13. November 2007 08:08
> To: [hidden email]
> Subject: Re: MavenReporter throws Serialization Exception for
> ProjectActions when writing to build.xml
>
> Any chance you can commit that to a branch so that I can take a look?
>
> This appears to be happening when build.xml gets serialized,
> and so maybe a XStream issue.
>
> 2007/11/10, Hafner Ullrich <[hidden email]>:
> > Hi,
> >
> > I tried to add native maven2 to the tasks plug-in. While I
> managed it to register the plugin (with GUI configuration) in
> a native maven build (hudson 1.153), e.g. in the compile
> step, I did not have success to add the persisted build
> results. What actually is not clear for me, if I should use
> the hooks for the MavenBuild or the MavenBuildProxy.
> >
> > 1.)  public boolean end(MavenBuild build, Launcher
> launcher, BuildListener listener)
> >             throws InterruptedException, IOException {
> >
> > When I try to reuse the code of my freestyle Publisher in
> this method, then I could scan for the tasks in the workspace
> and could publish the results on the build page (as with the
> freestyle project), however the build actions are not
> persisted. (This should also produce problems if running the
> build remote). And its not clear for which submodule (pom)
> I'm currently running.
> >
> > Then I tried the second method:
> >
> > 2.)   public boolean postExecute(final MavenBuildProxy
> build, final MavenProject pom, final MojoInfo mojo,
> >             final BuildListener listener, final Throwable error)
> > throws InterruptedException, IOException {
> >
> > Here I could access the files as expected (on a remote
> machine) and scan for the tasks. However, when trying to
> pushing the results from the proxy to the actual MavenBuild,
> then the serialization of the build.xml throws Exceptions
> messages after the build. I tried to be as close to the
> SurefireReporterwhen implementing my MavenReporter, but I had
> no success.
> >
> > Do you have any ideas?
> >
> > Here is the code (I removed unimportant parts) and the
> exception stacktrace:
> >
> >     /** {@inheritDoc} */
> >     @Override
> >     public boolean postExecute(final MavenBuildProxy build,
> final MavenProject pom, final MojoInfo mojo,
> >             final BuildListener listener, final Throwable
> error) throws InterruptedException, IOException {
> >         if (!"compile".equals(mojo.getGoal())) {
> >             return true;
> >         }
> >         listener.getLogger().println("Scanning workspace
> files for tasks...");
> >         FilePath filePath = new FilePath(pom.getBasedir());
> >         final JavaProject project = filePath.act(new
> > WorkspaceScanner(StringUtils.defaultIfEmpty(pattern,
> DEFAULT_PATTERN),
> > high, normal, low));
> >
> >         build.execute(new BuildCallable<Void, IOException>() {
> >             public Void call(final MavenBuild build) throws
> IOException, InterruptedException {
> >                 Object previous = build.getPreviousBuild();
> >                 TasksResult result = new TasksResult(build,
> project, high, normal, low);
> >                 HealthReportBuilder healthReportBuilder =
> new HealthReportBuilder("Task Scanner", "open task",
> isThresholdEnabled, minimumTasks, isHealthyReportEnabled,
> healthyTasks, unHealthyTasks);
> >                 build.getActions().add(new TasksResultAction(build,
> > result, healthReportBuilder));
> >
> >                 return null;
> >             }
> >         });
> >
> >         int warnings = project.getNumberOfAnnotations();
> >         if (warnings > 0) {
> >             listener.getLogger().println("A total of " +
> warnings + " open tasks have been found.");
> >             if (isThresholdEnabled && warnings >= minimumTasks) {
> >                 build.setResult(Result.UNSTABLE);
> >             }
> >         }
> >         else {
> >             listener.getLogger().println("No open tasks
> have been found.");
> >         }
> >
> >         return true;
> >     }
> >
> > For all of the three non-transient fields in the class
> > TasksResultAction(build, result, healthReportBuilder) I get
> the following exception. Note That the same TasksResultAction
> is used in the freestyle project, and here it is correctly
> serialized to the build.xml file.
> >
> > [INFO] Using default encoding to copy filtered resources.
> > [INFO] [psteclipse:update {execution: update}] [INFO] Defaulting
> > prefixes to the single prefix 'com.avaloq.'.
> > Downloading:
> >
> http://repo1.maven.org/maven2/com/avaloq/adt/org.junit.junit/3.8.2/org
> > .junit.junit-3.8.2.pom
> > [INFO] [compiler:compile]
> > [INFO] Nothing to compile - all classes are up to date Scanning
> > workspace files for tasks...
> > A total of 108 open tasks have been found.
> > [HUDSON] Archiving
> > C:\Build\Results\jobs\MAVEN-DEMO\workspace\com.avaloq.util\pom.xml
> > [HUDSON] Archiving
> > C:\Build\Results\jobs\MAVEN-DEMO\workspace\com.avaloq.util\pom.xml
> > [INFO]
> >
> ----------------------------------------------------------------------
> > --
> > [ERROR] FATAL ERROR
> > [INFO]
> >
> ----------------------------------------------------------------------
> > -- [INFO] Could not get field class java.lang.reflect.Field.owner :
> > Can not set hudson.model.AbstractBuild field
> > hudson.plugins.tasks.util.AbstractResultAction.owner to
> > hudson.plugins.tasks.TasksResultAction
> > [INFO]
> >
> ----------------------------------------------------------------------
> > --
> > [INFO] Trace
> >
> com.thoughtworks.xstream.converters.reflection.ObjectAccessExc
> eption: Could not get field class
> java.lang.reflect.Field.owner : Can not set
> hudson.model.AbstractBuild field
> hudson.plugins.tasks.util.AbstractResultAction.owner to
> hudson.plugins.tasks.TasksResultAction
> >         at
> com.thoughtworks.xstream.converters.reflection.PureJavaReflect
> ionProvider.visitSerializableFields(PureJavaReflectionProvider
> .java:111)
> >         at
> hudson.util.RobustReflectionConverter.doMarshal(RobustReflecti
> onConverter.java:73)
> >         at
> hudson.util.RobustReflectionConverter.marshal(RobustReflection
> Converter.java:65)
> >         at
> com.thoughtworks.xstream.core.AbstractReferenceMarshaller.conv
> ert(AbstractReferenceMarshaller.java:55)
> >         at
> com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(Tr
> eeMarshaller.java:50)
> >         at
> com.thoughtworks.xstream.converters.collections.AbstractCollec
> tionConverter.writeItem(AbstractCollectionConverter.java:52)
> >         at
> com.thoughtworks.xstream.converters.collections.CollectionConv
> erter.marshal(CollectionConverter.java:44)
> >         at
> com.thoughtworks.xstream.core.AbstractReferenceMarshaller.conv
> ert(AbstractReferenceMarshaller.java:55)
> >         at
> com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(Tr
> eeMarshaller.java:50)
> >         at
> hudson.util.RobustReflectionConverter.marshallField(RobustRefl
> ectionConverter.java:139)
> >         at
> hudson.util.RobustReflectionConverter$2.writeField(RobustRefle
ctionConverter.java:131)
> >         at
> hudson.util.RobustReflectionConverter$2.visit(RobustReflection
Converter.java:107)

> >         at
> com.thoughtworks.xstream.converters.reflection.PureJavaReflect
> ionProvider.visitSerializableFields(PureJavaReflectionProvider
> .java:109)
> >         at
> hudson.util.RobustReflectionConverter.doMarshal(RobustReflecti
> onConverter.java:92)
> >         at
> hudson.util.RobustReflectionConverter.marshal(RobustReflection
> Converter.java:65)
> >         at
> com.thoughtworks.xstream.core.AbstractReferenceMarshaller.conv
> ert(AbstractReferenceMarshaller.java:55)
> >         at
> com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(Tr
> eeMarshaller.java:50)
> >         at
> com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshal
> ler.java:73)
> >         at
> com.thoughtworks.xstream.core.ReferenceByXPathMarshallingStrat
> egy.marshal(ReferenceByXPathMarshallingStrategy.java:34)
> >         at
> com.thoughtworks.xstream.XStream.marshal(XStream.java:751)
> >         at
> com.thoughtworks.xstream.XStream.marshal(XStream.java:740)
> >         at com.thoughtworks.xstream.XStream.toXML(XStream.java:721)
> >         at hudson.XmlFile.write(XmlFile.java:138)
> >         at hudson.model.Run.save(Run.java:756)
> >         at
> hudson.maven.MavenBuild$ProxyImpl2.end(MavenBuild.java:254)
> >         at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >         at
> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> >         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> >         at java.lang.reflect.Method.invoke(Unknown Source)
> >         at
> hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(Rem
oteInvocationHandler.java:187)
> >         at
> hudson.remoting.RemoteInvocationHandler$RPCRequest.call(Remote
InvocationHandler.java:170)
> >         at
> hudson.remoting.RemoteInvocationHandler$RPCRequest.call(Remote
InvocationHandler.java:130)

> >         at hudson.remoting.UserRequest.perform(UserRequest.java:69)
> >         at hudson.remoting.UserRequest.perform(UserRequest.java:23)
> >         at hudson.remoting.Request$2.run(Request.java:200)
> >         at
> java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
> >         at
> java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
> >         at java.util.concurrent.FutureTask.run(Unknown Source)
> >         at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
> >         at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
> >         at java.lang.Thread.run(Unknown Source) Caused by:
> > java.lang.IllegalArgumentException: Can not set
> hudson.model.AbstractBuild field
> hudson.plugins.tasks.util.AbstractResultAction.owner to
> hudson.plugins.tasks.TasksResultAction
> >         at
> sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentExc
> eption(Unknown Source)
> >         at
> sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentExc
> eption(Unknown Source)
> >         at
> sun.reflect.UnsafeFieldAccessorImpl.ensureObj(Unknown Source)
> >         at
> sun.reflect.UnsafeObjectFieldAccessorImpl.get(Unknown Source)
> >         at java.lang.reflect.Field.get(Unknown Source)
> >         at
> com.thoughtworks.xstream.converters.reflection.PureJavaReflect
> ionProvider.visitSerializableFields(PureJavaReflectionProvider
> .java:108)
> >         ... 40 more
> > [INFO]
> >
> ----------------------------------------------------------------------
> > --
> > [INFO] Total time: 10 seconds
> > [INFO] Finished at: Sun Nov 11 00:14:15 CET 2007 [INFO]
> Final Memory:
> > 6M/11M [INFO]
> >
> ----------------------------------------------------------------------
> > --
> > channel stopped
> > finished: FAILURE
> > --
> > Avaloq - essential for banking.
> >
> > Avaloq Evolution AG
> > Allmendstrasse 140, 8027 Zürich
> > T +41 44 488 6790, F +41 44 488 6868, http://www.avaloq.com Dr.
> > Ullrich Hafner, mailto:[hidden email]
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>
>
> --
> Kohsuke Kawaguchi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: MavenReporter throws Serialization Exception for ProjectActions when writing to build.xml

Kohsuke Kawaguchi
Administrator

This turns out to be the same issue as
http://www.nabble.com/Help-Kohsuke%21-m2-project-type-and-cobertura-tf4829718.html 
and the fix is in 1.159.

Hafner Ullrich wrote:

> I already committed that. (Since I didn't release the plug-in, nobody should have problems with that:-)
>
> If you build the tasks plugin from HEAD you should see these errors when you activate this plug-in for a maven build. The maven part of the plug-in is in the TasksReporter class.
>
> Thanks for helping, Ulli
>
>> -----Original Message-----
>> From: [hidden email]
>> [mailto:[hidden email]] On Behalf Of Kohsuke Kawaguchi
>> Sent: Dienstag, 13. November 2007 08:08
>> To: [hidden email]
>> Subject: Re: MavenReporter throws Serialization Exception for
>> ProjectActions when writing to build.xml
>>
>> Any chance you can commit that to a branch so that I can take a look?
>>
>> This appears to be happening when build.xml gets serialized,
>> and so maybe a XStream issue.
>>
>> 2007/11/10, Hafner Ullrich <[hidden email]>:
>> > Hi,
>> >
>> > I tried to add native maven2 to the tasks plug-in. While I
>> managed it to register the plugin (with GUI configuration) in
>> a native maven build (hudson 1.153), e.g. in the compile
>> step, I did not have success to add the persisted build
>> results. What actually is not clear for me, if I should use
>> the hooks for the MavenBuild or the MavenBuildProxy.
>> >
>> > 1.)  public boolean end(MavenBuild build, Launcher
>> launcher, BuildListener listener)
>> >             throws InterruptedException, IOException {
>> >
>> > When I try to reuse the code of my freestyle Publisher in
>> this method, then I could scan for the tasks in the workspace
>> and could publish the results on the build page (as with the
>> freestyle project), however the build actions are not
>> persisted. (This should also produce problems if running the
>> build remote). And its not clear for which submodule (pom)
>> I'm currently running.
>> >
>> > Then I tried the second method:
>> >
>> > 2.)   public boolean postExecute(final MavenBuildProxy
>> build, final MavenProject pom, final MojoInfo mojo,
>> >             final BuildListener listener, final Throwable error)
>> > throws InterruptedException, IOException {
>> >
>> > Here I could access the files as expected (on a remote
>> machine) and scan for the tasks. However, when trying to
>> pushing the results from the proxy to the actual MavenBuild,
>> then the serialization of the build.xml throws Exceptions
>> messages after the build. I tried to be as close to the
>> SurefireReporterwhen implementing my MavenReporter, but I had
>> no success.
>> >
>> > Do you have any ideas?
>> >
>> > Here is the code (I removed unimportant parts) and the
>> exception stacktrace:
>> >
>> >     /** {@inheritDoc} */
>> >     @Override
>> >     public boolean postExecute(final MavenBuildProxy build,
>> final MavenProject pom, final MojoInfo mojo,
>> >             final BuildListener listener, final Throwable
>> error) throws InterruptedException, IOException {
>> >         if (!"compile".equals(mojo.getGoal())) {
>> >             return true;
>> >         }
>> >         listener.getLogger().println("Scanning workspace
>> files for tasks...");
>> >         FilePath filePath = new FilePath(pom.getBasedir());
>> >         final JavaProject project = filePath.act(new
>> > WorkspaceScanner(StringUtils.defaultIfEmpty(pattern,
>> DEFAULT_PATTERN),
>> > high, normal, low));
>> >
>> >         build.execute(new BuildCallable<Void, IOException>() {
>> >             public Void call(final MavenBuild build) throws
>> IOException, InterruptedException {
>> >                 Object previous = build.getPreviousBuild();
>> >                 TasksResult result = new TasksResult(build,
>> project, high, normal, low);
>> >                 HealthReportBuilder healthReportBuilder =
>> new HealthReportBuilder("Task Scanner", "open task",
>> isThresholdEnabled, minimumTasks, isHealthyReportEnabled,
>> healthyTasks, unHealthyTasks);
>> >                 build.getActions().add(new TasksResultAction(build,
>> > result, healthReportBuilder));
>> >
>> >                 return null;
>> >             }
>> >         });
>> >
>> >         int warnings = project.getNumberOfAnnotations();
>> >         if (warnings > 0) {
>> >             listener.getLogger().println("A total of " +
>> warnings + " open tasks have been found.");
>> >             if (isThresholdEnabled && warnings >= minimumTasks) {
>> >                 build.setResult(Result.UNSTABLE);
>> >             }
>> >         }
>> >         else {
>> >             listener.getLogger().println("No open tasks
>> have been found.");
>> >         }
>> >
>> >         return true;
>> >     }
>> >
>> > For all of the three non-transient fields in the class
>> > TasksResultAction(build, result, healthReportBuilder) I get
>> the following exception. Note That the same TasksResultAction
>> is used in the freestyle project, and here it is correctly
>> serialized to the build.xml file.
>> >
>> > [INFO] Using default encoding to copy filtered resources.
>> > [INFO] [psteclipse:update {execution: update}] [INFO] Defaulting
>> > prefixes to the single prefix 'com.avaloq.'.
>> > Downloading:
>> >
>> http://repo1.maven.org/maven2/com/avaloq/adt/org.junit.junit/3.8.2/org
>> > .junit.junit-3.8.2.pom
>> > [INFO] [compiler:compile]
>> > [INFO] Nothing to compile - all classes are up to date Scanning
>> > workspace files for tasks...
>> > A total of 108 open tasks have been found.
>> > [HUDSON] Archiving
>> > C:\Build\Results\jobs\MAVEN-DEMO\workspace\com.avaloq.util\pom.xml
>> > [HUDSON] Archiving
>> > C:\Build\Results\jobs\MAVEN-DEMO\workspace\com.avaloq.util\pom.xml
>> > [INFO]
>> >
>> ----------------------------------------------------------------------
>> > --
>> > [ERROR] FATAL ERROR
>> > [INFO]
>> >
>> ----------------------------------------------------------------------
>> > -- [INFO] Could not get field class java.lang.reflect.Field.owner :
>> > Can not set hudson.model.AbstractBuild field
>> > hudson.plugins.tasks.util.AbstractResultAction.owner to
>> > hudson.plugins.tasks.TasksResultAction
>> > [INFO]
>> >
>> ----------------------------------------------------------------------
>> > --
>> > [INFO] Trace
>> >
>> com.thoughtworks.xstream.converters.reflection.ObjectAccessExc
>> eption: Could not get field class
>> java.lang.reflect.Field.owner : Can not set
>> hudson.model.AbstractBuild field
>> hudson.plugins.tasks.util.AbstractResultAction.owner to
>> hudson.plugins.tasks.TasksResultAction
>> >         at
>> com.thoughtworks.xstream.converters.reflection.PureJavaReflect
>> ionProvider.visitSerializableFields(PureJavaReflectionProvider
>> .java:111)
>> >         at
>> hudson.util.RobustReflectionConverter.doMarshal(RobustReflecti
>> onConverter.java:73)
>> >         at
>> hudson.util.RobustReflectionConverter.marshal(RobustReflection
>> Converter.java:65)
>> >         at
>> com.thoughtworks.xstream.core.AbstractReferenceMarshaller.conv
>> ert(AbstractReferenceMarshaller.java:55)
>> >         at
>> com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(Tr
>> eeMarshaller.java:50)
>> >         at
>> com.thoughtworks.xstream.converters.collections.AbstractCollec
>> tionConverter.writeItem(AbstractCollectionConverter.java:52)
>> >         at
>> com.thoughtworks.xstream.converters.collections.CollectionConv
>> erter.marshal(CollectionConverter.java:44)
>> >         at
>> com.thoughtworks.xstream.core.AbstractReferenceMarshaller.conv
>> ert(AbstractReferenceMarshaller.java:55)
>> >         at
>> com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(Tr
>> eeMarshaller.java:50)
>> >         at
>> hudson.util.RobustReflectionConverter.marshallField(RobustRefl
>> ectionConverter.java:139)
>> >         at
>> hudson.util.RobustReflectionConverter$2.writeField(RobustRefle
> ctionConverter.java:131)
>> >         at
>> hudson.util.RobustReflectionConverter$2.visit(RobustReflection
> Converter.java:107)
>> >         at
>> com.thoughtworks.xstream.converters.reflection.PureJavaReflect
>> ionProvider.visitSerializableFields(PureJavaReflectionProvider
>> .java:109)
>> >         at
>> hudson.util.RobustReflectionConverter.doMarshal(RobustReflecti
>> onConverter.java:92)
>> >         at
>> hudson.util.RobustReflectionConverter.marshal(RobustReflection
>> Converter.java:65)
>> >         at
>> com.thoughtworks.xstream.core.AbstractReferenceMarshaller.conv
>> ert(AbstractReferenceMarshaller.java:55)
>> >         at
>> com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(Tr
>> eeMarshaller.java:50)
>> >         at
>> com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshal
>> ler.java:73)
>> >         at
>> com.thoughtworks.xstream.core.ReferenceByXPathMarshallingStrat
>> egy.marshal(ReferenceByXPathMarshallingStrategy.java:34)
>> >         at
>> com.thoughtworks.xstream.XStream.marshal(XStream.java:751)
>> >         at
>> com.thoughtworks.xstream.XStream.marshal(XStream.java:740)
>> >         at com.thoughtworks.xstream.XStream.toXML(XStream.java:721)
>> >         at hudson.XmlFile.write(XmlFile.java:138)
>> >         at hudson.model.Run.save(Run.java:756)
>> >         at
>> hudson.maven.MavenBuild$ProxyImpl2.end(MavenBuild.java:254)
>> >         at
>> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> >         at
>> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>> >         at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>> >         at java.lang.reflect.Method.invoke(Unknown Source)
>> >         at
>> hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(Rem
> oteInvocationHandler.java:187)
>> >         at
>> hudson.remoting.RemoteInvocationHandler$RPCRequest.call(Remote
> InvocationHandler.java:170)
>> >         at
>> hudson.remoting.RemoteInvocationHandler$RPCRequest.call(Remote
> InvocationHandler.java:130)
>> >         at hudson.remoting.UserRequest.perform(UserRequest.java:69)
>> >         at hudson.remoting.UserRequest.perform(UserRequest.java:23)
>> >         at hudson.remoting.Request$2.run(Request.java:200)
>> >         at
>> java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
>> >         at
>> java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
>> >         at java.util.concurrent.FutureTask.run(Unknown Source)
>> >         at
>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
>> >         at
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
>> >         at java.lang.Thread.run(Unknown Source) Caused by:
>> > java.lang.IllegalArgumentException: Can not set
>> hudson.model.AbstractBuild field
>> hudson.plugins.tasks.util.AbstractResultAction.owner to
>> hudson.plugins.tasks.TasksResultAction
>> >         at
>> sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentExc
>> eption(Unknown Source)
>> >         at
>> sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentExc
>> eption(Unknown Source)
>> >         at
>> sun.reflect.UnsafeFieldAccessorImpl.ensureObj(Unknown Source)
>> >         at
>> sun.reflect.UnsafeObjectFieldAccessorImpl.get(Unknown Source)
>> >         at java.lang.reflect.Field.get(Unknown Source)
>> >         at
>> com.thoughtworks.xstream.converters.reflection.PureJavaReflect
>> ionProvider.visitSerializableFields(PureJavaReflectionProvider
>> .java:108)
>> >         ... 40 more
>> > [INFO]
>> >
>> ----------------------------------------------------------------------
>> > --
>> > [INFO] Total time: 10 seconds
>> > [INFO] Finished at: Sun Nov 11 00:14:15 CET 2007 [INFO]
>> Final Memory:
>> > 6M/11M [INFO]
>> >
>> ----------------------------------------------------------------------
>> > --
>> > channel stopped
>> > finished: FAILURE
>> > --
>> > Avaloq - essential for banking.
>> >
>> > Avaloq Evolution AG
>> > Allmendstrasse 140, 8027 Z?rich
>> > T +41 44 488 6790, F +41 44 488 6868, http://www.avaloq.com Dr.
>> > Ullrich Hafner, mailto:[hidden email]
>> >
>> >
>> >
>> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [hidden email]
>> > For additional commands, e-mail: [hidden email]
>> >
>> >
>>
>>
>> --
>> Kohsuke Kawaguchi
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

--
Kohsuke Kawaguchi
Sun Microsystems                   [hidden email]

smime.p7s (4K) Download Attachment