You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Ben Gidley <bg...@gmail.com> on 2006/02/01 15:48:21 UTC

[m2] Forking with Surefire

I am having issues with Maven running the unit tests on my project. The main
error is

java.lang.LinkageError: loader constraints violated when linking
javax/xml/namespace/QName class
    at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.<clinit>(
RuntimeBuiltinLeafInfoImpl.java:779)

Looking at this list I can see a number of people have hit this and the
solution is to fork the JVM for the unit tests. Looking at the surefire
plugin documentation I have added the following to my POM
  <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <forkMode>each</forkMode>
        </configuration>
      </plugin>

However this make no difference. I then suspected it may be not in the
released version of the plugin - so I tried using the snapshot by adding
<pluginRepository>
      <id>Snapshots</id>
      <name>Snapshots</name>
      <url>http://snapshots.maven.codehaus.org/maven2/</url>
   </pluginRepository>

and forcing the plugin version. This also appears to make no different.

Looking at the code for the plugin in Subversion for surefire it does appear
it supports forking and this is the way to turn in on. Am I doing something
wrong to make it use the plugin?

Has anyone got any ideas of how to get round this issue?

Thanks

Ben

Re: [m2] Forking with Surefire

Posted by jerome lacoste <je...@gmail.com>.
On 2/1/06, Ben Gidley <bg...@gmail.com> wrote:
> I am having issues with Maven running the unit tests on my project. The main
> error is
>
> java.lang.LinkageError: loader constraints violated when linking
> javax/xml/namespace/QName class
>     at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.<clinit>(
> RuntimeBuiltinLeafInfoImpl.java:779)
>
> Looking at this list I can see a number of people have hit this and the
> solution is to fork the JVM for the unit tests. Looking at the surefire
> plugin documentation I have added the following to my POM
>   <plugin>
>         <groupId>org.apache.maven.plugins</groupId>
>         <artifactId>maven-surefire-plugin</artifactId>
>         <configuration>
>           <forkMode>each</forkMode>
>         </configuration>
>       </plugin>
>
> However this make no difference. I then suspected it may be not in the
> released version of the plugin - so I tried using the snapshot by adding
> <pluginRepository>
>       <id>Snapshots</id>
>       <name>Snapshots</name>
>       <url>http://snapshots.maven.codehaus.org/maven2/</url>
>    </pluginRepository>
>
> and forcing the plugin version. This also appears to make no different.
>
> Looking at the code for the plugin in Subversion for surefire it does appear
> it supports forking and this is the way to turn in on. Am I doing something
> wrong to make it use the plugin?

I am using the forkMode successfully with mvn 2.0.2 and the only diff
I seem to have with your config is that I specify the execution

         <executions>
           <execution>
              <goals>
                 <goal>test</goal>
              </goals>
           </execution>
         </executions>

Not sure if that will solve your issue.

> Has anyone got any ideas of how to get round this issue?

Jerome

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: [m2] Forking with Surefire

Posted by Ben Gidley <be...@gidley.co.uk>.
Sorry - ignore that. I have found a solution looking at the surefire code.
The trick is to turn childdelegation off when forking. This means that the
JVM only loads the classes once and it is all good.

e.g.

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <forkMode>once</forkMode>
          <testFailureIgnore>true</testFailureIgnore>
          <childDelegation>false</childDelegation>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
I will submit a patch to the docs to make this clear.

Thanks

Ben


On 2/2/06, Ben Gidley <be...@gidley.co.uk> wrote:
>
> Thanks for this - unfortunately even with this setting I am still having
> the same problem it appears to be some interaction between the libraries
> JAXB2 and Surefire is using that even happens when forking is occuring.
>
> I have checked (with -X) and I am definitely running Surefire 1.5.2 which
> is the latest I can see.
>
> The JAXB2 guys think it is likely to be something to do with the way
> surefire is loading classes. Looking at surefire I suspect this could be the
> case as it is using a custom isolated classloader which then loads the
> javax.xml namespace a second time (hence the error).
>
> The percise error is
>
> java.lang.LinkageError: loader constraints violated when linking
> javax/xml/namespace/QName class
>     at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.<clinit>(
> RuntimeBuiltinLeafInfoImpl.java:779)
>     at com.sun.xml.bind.v2.model.impl.RuntimeTypeInfoSetImpl.<init>(
> RuntimeTypeInfoSetImpl.java:25)
>
> I am going to investigate - but any hints would be appreciated.
>
> Ben
>
> On 2/2/06, Jason van Zyl <ja...@maven.org> wrote:
> >
> > Ben Gidley wrote:
> > > I am having issues with Maven running the unit tests on my project.
> > The main
> > > error is
> >
> > http://maven.apache.org/plugins/maven-surefire-plugin/howto.html
> >
> > For forkMode you can specify "once" or "pertest" which really means per
> > test case. I've added:
> >
> > http://jira.codehaus.org/browse/MSUREFIRE-55
> > and
> > http://jira.codehaus.org/browse/MSUREFIRE-56
> >
> > Sorry about the confusion.
> >
> > > java.lang.LinkageError: loader constraints violated when linking
> > > javax/xml/namespace/QName class
> > >     at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl
> > .<clinit>(
> > > RuntimeBuiltinLeafInfoImpl.java:779)
> > >
> > > Looking at this list I can see a number of people have hit this and
> > the
> > > solution is to fork the JVM for the unit tests. Looking at the
> > surefire
> > > plugin documentation I have added the following to my POM
> > >   <plugin>
> > >         <groupId>org.apache.maven.plugins </groupId>
> > >         <artifactId>maven-surefire-plugin</artifactId>
> > >         <configuration>
> > >           <forkMode>each</forkMode>
> > >         </configuration>
> > >       </plugin>
> > >
> > > However this make no difference. I then suspected it may be not in the
> > > released version of the plugin - so I tried using the snapshot by
> > adding
> > > <pluginRepository>
> > >       <id>Snapshots</id>
> > >       <name>Snapshots</name>
> > >       <url>http://snapshots.maven.codehaus.org/maven2/ </url>
> > >    </pluginRepository>
> > >
> > > and forcing the plugin version. This also appears to make no
> > different.
> > >
> > > Looking at the code for the plugin in Subversion for surefire it does
> > appear
> > > it supports forking and this is the way to turn in on. Am I doing
> > something
> > > wrong to make it use the plugin?
> > >
> > > Has anyone got any ideas of how to get round this issue?
> > >
> > > Thanks
> > >
> > > Ben
> > >
> >
> >
> > --
> >
> > jvz.
> >
> > Jason van Zyl
> > jason at maven.org
> > http://maven.apache.org
> >
> > First, the taking in of scattered particulars under one Idea,
> > so that everyone understands what is being talked about ... Second,
> > the separation of the Idea into parts, by dividing it at the joints,
> > as nature directs, not breaking any limb in half as a bad carver might.
> >
> >    -- Plato, Phaedrus (Notes on the Synthesis of Form by C. Alexander)
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
>

Re: [m2] Forking with Surefire

Posted by Ben Gidley <be...@gidley.co.uk>.
Thanks for this - unfortunately even with this setting I am still having the
same problem it appears to be some interaction between the libraries JAXB2
and Surefire is using that even happens when forking is occuring.

I have checked (with -X) and I am definitely running Surefire 1.5.2 which is
the latest I can see.

The JAXB2 guys think it is likely to be something to do with the way
surefire is loading classes. Looking at surefire I suspect this could be the
case as it is using a custom isolated classloader which then loads the
javax.xml namespace a second time (hence the error).

The percise error is

java.lang.LinkageError: loader constraints violated when linking
javax/xml/namespace/QName class
    at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.<clinit>(
RuntimeBuiltinLeafInfoImpl.java:779)
    at com.sun.xml.bind.v2.model.impl.RuntimeTypeInfoSetImpl.<init>(
RuntimeTypeInfoSetImpl.java:25)

I am going to investigate - but any hints would be appreciated.

Ben

On 2/2/06, Jason van Zyl <ja...@maven.org> wrote:
>
> Ben Gidley wrote:
> > I am having issues with Maven running the unit tests on my project. The
> main
> > error is
>
> http://maven.apache.org/plugins/maven-surefire-plugin/howto.html
>
> For forkMode you can specify "once" or "pertest" which really means per
> test case. I've added:
>
> http://jira.codehaus.org/browse/MSUREFIRE-55
> and
> http://jira.codehaus.org/browse/MSUREFIRE-56
>
> Sorry about the confusion.
>
> > java.lang.LinkageError: loader constraints violated when linking
> > javax/xml/namespace/QName class
> >     at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl
> .<clinit>(
> > RuntimeBuiltinLeafInfoImpl.java:779)
> >
> > Looking at this list I can see a number of people have hit this and the
> > solution is to fork the JVM for the unit tests. Looking at the surefire
> > plugin documentation I have added the following to my POM
> >   <plugin>
> >         <groupId>org.apache.maven.plugins</groupId>
> >         <artifactId>maven-surefire-plugin</artifactId>
> >         <configuration>
> >           <forkMode>each</forkMode>
> >         </configuration>
> >       </plugin>
> >
> > However this make no difference. I then suspected it may be not in the
> > released version of the plugin - so I tried using the snapshot by adding
> > <pluginRepository>
> >       <id>Snapshots</id>
> >       <name>Snapshots</name>
> >       <url>http://snapshots.maven.codehaus.org/maven2/</url>
> >    </pluginRepository>
> >
> > and forcing the plugin version. This also appears to make no different.
> >
> > Looking at the code for the plugin in Subversion for surefire it does
> appear
> > it supports forking and this is the way to turn in on. Am I doing
> something
> > wrong to make it use the plugin?
> >
> > Has anyone got any ideas of how to get round this issue?
> >
> > Thanks
> >
> > Ben
> >
>
>
> --
>
> jvz.
>
> Jason van Zyl
> jason at maven.org
> http://maven.apache.org
>
> First, the taking in of scattered particulars under one Idea,
> so that everyone understands what is being talked about ... Second,
> the separation of the Idea into parts, by dividing it at the joints,
> as nature directs, not breaking any limb in half as a bad carver might.
>
>    -- Plato, Phaedrus (Notes on the Synthesis of Form by C. Alexander)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: [m2] Forking with Surefire

Posted by Jason van Zyl <ja...@maven.org>.
Ben Gidley wrote:
> I am having issues with Maven running the unit tests on my project. The main
> error is

http://maven.apache.org/plugins/maven-surefire-plugin/howto.html

For forkMode you can specify "once" or "pertest" which really means per 
test case. I've added:

http://jira.codehaus.org/browse/MSUREFIRE-55
and
http://jira.codehaus.org/browse/MSUREFIRE-56

Sorry about the confusion.

> java.lang.LinkageError: loader constraints violated when linking
> javax/xml/namespace/QName class
>     at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.<clinit>(
> RuntimeBuiltinLeafInfoImpl.java:779)
> 
> Looking at this list I can see a number of people have hit this and the
> solution is to fork the JVM for the unit tests. Looking at the surefire
> plugin documentation I have added the following to my POM
>   <plugin>
>         <groupId>org.apache.maven.plugins</groupId>
>         <artifactId>maven-surefire-plugin</artifactId>
>         <configuration>
>           <forkMode>each</forkMode>
>         </configuration>
>       </plugin>
> 
> However this make no difference. I then suspected it may be not in the
> released version of the plugin - so I tried using the snapshot by adding
> <pluginRepository>
>       <id>Snapshots</id>
>       <name>Snapshots</name>
>       <url>http://snapshots.maven.codehaus.org/maven2/</url>
>    </pluginRepository>
> 
> and forcing the plugin version. This also appears to make no different.
> 
> Looking at the code for the plugin in Subversion for surefire it does appear
> it supports forking and this is the way to turn in on. Am I doing something
> wrong to make it use the plugin?
> 
> Has anyone got any ideas of how to get round this issue?
> 
> Thanks
> 
> Ben
> 


-- 

jvz.

Jason van Zyl
jason at maven.org
http://maven.apache.org

First, the taking in of scattered particulars under one Idea,
so that everyone understands what is being talked about ... Second,
the separation of the Idea into parts, by dividing it at the joints,
as nature directs, not breaking any limb in half as a bad carver might.

   -- Plato, Phaedrus (Notes on the Synthesis of Form by C. Alexander)

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org