You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Claudio Ranieri <cl...@buscape-inc.com> on 2008/05/20 12:46:43 UTC

Problem with classloader in maven plugin

Hi

I am trying to create a maven plugin to jboss wsconsume, but I have a problem with classloader in plugin.
My plugin is based in an ant task (WSConsumeTask).
I am using maven 2.0.8 on Windows machine.
When I created a simple Java project with libraries necessary, my code works.
How shown below:

public static void main(String[] args) {
  WSConsumeTask t = new WSConsumeTask();
  t.setWsdl("https://xxx/crypto?wsdl");
  t.setVerbose(true);
  t.setKeep(true);
  t.execute();
}

But when I am using into maven plugin, I got problem with classloader.
I got this exception:

C:\eclipse\workspace\TestePluginMaven\output\com\buscape\bean\CryptoService.java:7: cannot find symbol
symbol  : class Service
location: package javax.xml.ws
import javax.xml.ws.Service;
                    ^
C:\eclipse\workspace\TestePluginMaven\output\com\buscape\bean\CryptoService.java:8: cannot find symbol
symbol  : class WebEndpoint
location: package javax.xml.ws
import javax.xml.ws.WebEndpoint;
                    ^
C:\eclipse\workspace\TestePluginMaven\output\com\buscape\bean\CryptoService.java:9: cannot find symbol
symbol  : class WebServiceClient
location: package javax.xml.ws
import javax.xml.ws.WebServiceClient;

The plugin classloader doesn´t load the jaxws libraries. But this libraries was added in pom.xml of plugin.
I tried to add dependencies tag in my plugin config, but didn´t works. How shown below:

<plugin>
  <groupId>jboss</groupId>
  <artifactId>maven-jbossws-plugin</artifactId>
  <version>1.0.0</version>
  <configuration>
    <verbose>true</verbose>
    <keep>true</keep>
    <wsdl>https://xxx/crypto?wsdl</wsdl>
  </configuration>
  <dependencies>
    <dependency>
      <groupId>jboss.jbossws</groupId>
      <artifactId>jaxws-tools</artifactId>
      <version>3.0.1-native-2.0.4.GA</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>jboss.jbossws</groupId>
      <artifactId>jboss-jaxws</artifactId>
      <version>3.0.1-native-2.0.4.GA</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
</plugin>

I tried too to use an initClassLoader based in jaxws-maven-plugin source, how shown below:

   private String initClassLoader(ClassLoader parent) throws MojoExecutionException {
                    try {
                                List classpathFiles = project.getCompileClasspathElements();
                        URL[] urls = new URL[classpathFiles.size() + 4];
                        StringBuffer classPath = new StringBuffer();
                        for (int i = 0; i < classpathFiles.size(); ++i) {
                            getLog().debug((String)classpathFiles.get(i));
                            urls[i] = new File((String)classpathFiles.get(i)).toURL();
                            classPath.append((String)classpathFiles.get(i));
                            classPath.append(File.pathSeparatorChar);
                        }
                        urls[classpathFiles.size()] = new File(project.getBuild().getOutputDirectory()).toURL();

                        urls[classpathFiles.size() + 1] = getArtifact("jboss.jbossws:jboss-jaxws");

                        urls[classpathFiles.size() + 2] = getArtifact("jboss.jbossws:jaxws-tools");

                        File toolsJar = new File(System.getProperty("java.home"),"../lib/tools.jar");
                        if (!toolsJar.exists()) {
                                toolsJar = new File(System.getProperty("java.home"),"lib/tools.jar");
                        }
                        urls[classpathFiles.size() + 3] = toolsJar.toURL();

                        System.out.println("urls: "+Arrays.toString(urls));

                        URLClassLoader cl = new URLClassLoader(urls,parent);
                        // Set the new classloader
                        Thread.currentThread().setContextClassLoader(cl);
                        System.setProperty("java.class.path",classPath.toString());
                        String sysCp = System.getProperty("java.class.path");
                        return sysCp;
                    }
                    catch (MalformedURLException e) {
                        throw new MojoExecutionException(e.getMessage(),e);
                    }
                    catch (DependencyResolutionRequiredException e) {
                        throw new MojoExecutionException(e.getMessage(),e);
                    }

    }

    public void execute() throws MojoExecutionException {
                  // Need to build a URLClassloader since Maven removed it form the chain
        ClassLoader parent = this.getClass().getClassLoader();
        String originalSystemClasspath = this.initClassLoader( parent );

        try {

                        // Execute WSConsumeTask
                        WSConsumeTask t = new WSConsumeTask();
                                  t.setWsdl(wsdl);
                                  t.setVerbose(verbose);
                                  t.setKeep(keep);
                                  t.execute();
        }
        finally {
                // Set back the old classloader
          Thread.currentThread().setContextClassLoader(parent);
          System.setProperty("java.class.path",originalSystemClasspath);
        }
    }

But, it doesn´t works.
Please, can someone help me?
Thanks

Re: Configuring settings through MAVEN_OPTS

Posted by Heinrich Nirschl <he...@gmail.com>.
On Tue, May 27, 2008 at 5:48 PM, Heinrich Nirschl
<he...@gmail.com> wrote:
> On Tue, May 27, 2008 at 5:28 PM, Salvador Diaz <sd...@m6.fr> wrote:
>> Hi all,
>>
>> What do you have to add to MAVEN_OPTS to tell maven to use a specific
>> settings.xml ?
>
> Try mvn -h. Near the end of the list you will find:
>
> -s,--settings                 Alternate path for the user settings file
>
> -Henry
>

Sorry, I just recognized it does not work when put into MAVEN_OPTS.
You can only pass options for the JVM with this variable.

Another possibility would be to use an alias (if you are on *NIX) or a
small wrapper script.

- Henry

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


Re: Configuring settings through MAVEN_OPTS

Posted by Heinrich Nirschl <he...@gmail.com>.
On Tue, May 27, 2008 at 5:28 PM, Salvador Diaz <sd...@m6.fr> wrote:
> Hi all,
>
> What do you have to add to MAVEN_OPTS to tell maven to use a specific
> settings.xml ?

Try mvn -h. Near the end of the list you will find:

-s,--settings                 Alternate path for the user settings file

-Henry

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


Configuring settings through MAVEN_OPTS

Posted by Salvador Diaz <sd...@m6.fr>.
Hi all,

What do you have to add to MAVEN_OPTS to tell maven to use a specific 
settings.xml ?

Thanks,

Salvador Diaz


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


RES: RES: RES: Problem with classloader in maven plugin

Posted by Claudio Ranieri <cl...@buscape-inc.com>.
Hi Tim

I created a variable of the type javax.xml.ws.WebServiceClient with successful in my plugin.
I looked the source of WSConsumeTask.
In executeNonForked method, the code calls getTaskClassPathStrings() which try cast the ClassLoader to AntClassLoader.
I think that problem is in this point. When I call the WSConsumeTask from maven plugin, the method getTaskClassPathStrings()
can not cast the ClassLoader to AntClassLoader.
I tried to use WSContractConsumer directly. I set the classpath through the setAdditionalCompilerClassPath method of WSContractConsumer.
I got the classpath from ${plugin.artifactMap} of maven plugin.
I code worked!

Tim, thank you very much for your patience.
In soon, I will publish the plugin.
Thanks.

-----Mensagem original-----
De: Tim Kettler [mailto:tim.kettler@udo.edu]
Enviada em: terça-feira, 27 de maio de 2008 05:44
Para: Maven Users List
Assunto: Re: RES: RES: Problem with classloader in maven plugin

Hi,

have you tried (just as a test) to declare a variable of one of the
missing types? Just something simple like:

   javax.xml.ws.WebServiceClient testClient;

in your plugin source code. Just to see if it compiles. If it compiles,
you can be sure that the classes are on the classpath of the plugin and
you need to further investigate the inner workings in the wsconsume task
you are reusing.

...later:

I Just took a very quick look at the wsconsume source code [1]. In
particular you should have a look at the executeNonForked() and
executeForked() methods to see the source of your problems. The task
sets up a classpath on it's own, so everything you set up on the maven
site is just not used. You should investigate how to properly configure
the classpath for the task or even use WSContractConsumer [2] directly.

If you have further questions about the correct usage of WSConsumeTask
and WSContractConsumer it's probably best to ask the people developing
it on their mailinglist.

-Tim

[1]
http://anonsvn.jboss.org/repos/jbossws/spi/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/WSConsumeTask.java
[2]
http://anonsvn.jboss.org/repos/jbossws/spi/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractConsumer.java

Claudio Ranieri schrieb:
> Hi,
>
> Tim wrote:
>
> "All libraries (with a proper scope) declared in the pom of the plugin project are available (on the classpath) to the plugin during execution"
>
> It is not true for my plugin project.
> My plugin project has this pom.xml:
>
> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
>   <modelVersion>4.0.0</modelVersion>
>   <groupId>jboss</groupId>
>   <artifactId>maven-jbossws-plugin</artifactId>
>   <packaging>maven-plugin</packaging>
>   <version>1.0.0</version>
>   <name>maven-jbossws-plugin Maven Mojo</name>
>   <url>http://maven.apache.org</url>
>   <dependencies>
>     <!-- Maven Plugin -->
>     <dependency>
>       <groupId>org.apache.maven</groupId>
>       <artifactId>maven-plugin-api</artifactId>
>       <version>2.0</version>
>     </dependency>
>     <dependency>
>        <groupId>org.apache.maven</groupId>
>        <artifactId>maven-project</artifactId>
>        <version>2.0</version>
>     </dependency>
>     <!-- Test -->
>     <dependency>
>       <groupId>junit</groupId>
>       <artifactId>junit</artifactId>
>       <version>3.8.1</version>
>       <scope>test</scope>
>     </dependency>
>     <!-- JbossAs Dependencies -->
>     <dependency>
>                 <groupId>jboss</groupId>
>                 <artifactId>activation</artifactId>
>                 <version>4.2.2.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss</groupId>
>                 <artifactId>getopt</artifactId>
>                 <version>4.2.2.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss</groupId>
>                 <artifactId>javassist</artifactId>
>                 <version>4.2.2.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss</groupId>
>                 <artifactId>jbossall-client</artifactId>
>                 <version>4.2.2.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss</groupId>
>                 <artifactId>log4j</artifactId>
>                 <version>4.2.2.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss</groupId>
>                 <artifactId>mail</artifactId>
>                 <version>4.2.2.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>     <!-- JBossWS Dependencies -->
>     <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>stax-ex</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>     <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>streambuffer</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>jaxb-api</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>jaxb-impl</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>jboss-jaxrpc</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>jaxb-xjc</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>jaxws-rt</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>jaxws-tools</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>wstx</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>jboss-jaxws</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>jboss-saaj</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>jbossws-client</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>jbossws-spi</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>jboss-xml-binding</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>stax-api</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <!-- Java Tools -->
>         <dependency>
>         <groupId>sun.jdk</groupId>
>         <artifactId>tools</artifactId>
>         <version>1.5.0</version>
>         <scope>system</scope>
>         <systemPath>${java.home}/../lib/tools.jar</systemPath>
>     </dependency>
>     <!-- Ant -->
>     <dependency>
>                 <groupId>org.apache.ant</groupId>
>                 <artifactId>ant</artifactId>
>                 <version>1.7.0</version>
>                 <scope>compile</scope>
>         </dependency>
>   </dependencies>
> </project>
>
> My project that uses my maven plugin has this pom.xml:
>
> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
>   <modelVersion>4.0.0</modelVersion>
>   <groupId>com</groupId>
>   <artifactId>TestePluginMaven</artifactId>
>   <packaging>jar</packaging>
>   <version>1.0-SNAPSHOT</version>
>   <name>TestePluginMaven</name>
>   <url>http://maven.apache.org</url>
>   <dependencies>
>     <dependency>
>       <groupId>junit</groupId>
>       <artifactId>junit</artifactId>
>       <version>3.8.1</version>
>       <scope>test</scope>
>     </dependency>
>   </dependencies>
>   <build>
>     <plugins>
>       <plugin>
>         <groupId>jboss</groupId>
>         <artifactId>maven-jbossws-plugin</artifactId>
>         <version>1.0.0</version>
>         <configuration>
>                 <verbose>true</verbose>
>                 <keep>true</keep>
>                 <wsdl>https://xxx/crypto?wsdl</wsdl>
>         </configuration>
>       </plugin>
>       <!-- Don't forget Java 5!! -->
>       <plugin>
>         <artifactId>maven-compiler-plugin</artifactId>
>         <configuration>
>           <source>1.5</source>
>           <target>1.5</target>
>         </configuration>
>       </plugin>
>     </plugins>
>   </build>
> </project>
>
> When I execute my plugin I get:
>
> + Error stacktraces are turned on.
> Maven version: 2.0.8
> Java version: 1.5.0_06
> OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"
> [DEBUG] Building Maven user-level plugin registry from: 'C:\Documents and Settings\claudior\.m2\plugin-registry.xml'
> [DEBUG] Building Maven global-level plugin registry from: 'C:\apache-maven-2.0.8\bin\..\conf\plugin-registry.xml'
> [INFO] Scanning for projects...
> [INFO] Searching repository for plugin with prefix: 'jbossws'.
> [DEBUG] Loading plugin prefixes from group: org.apache.maven.plugins
> [DEBUG] Loading plugin prefixes from group: org.codehaus.mojo
> [DEBUG] maven-compiler-plugin: resolved to version 2.0.2 from repository central
> [DEBUG] Retrieving parent-POM: org.apache.maven.plugins:maven-plugins::8 for project: null:maven-compiler-plugin:maven-plugin:2.0.2 from the repository.
> [DEBUG] Retrieving parent-POM: org.apache.maven:maven-parent::5 for project: org.apache.maven.plugins:maven-plugins:pom:8 from the repository.
> [DEBUG] Retrieving parent-POM: org.apache:apache::3 for project: org.apache.maven:maven-parent:pom:5 from the repository.
> [INFO] ------------------------------------------------------------------------
> [INFO] Building TestePluginMaven
> [INFO]    task-segment: [jbossws:wsconsume]
> [INFO] ------------------------------------------------------------------------
> [DEBUG] jboss:maven-jbossws-plugin:maven-plugin:1.0.0:runtime (selected for runtime)
> [DEBUG]   jboss:mail:jar:4.2.2.GA:runtime (selected for runtime)
> [DEBUG] Retrieving parent-POM: org.apache.ant:ant-parent::1.7.0 for project: org.apache.ant:ant:jar:1.7.0 from the repository.
> [DEBUG]   org.apache.ant:ant:jar:1.7.0:runtime (selected for runtime)
> [DEBUG]     org.apache.ant:ant-launcher:jar:1.7.0:runtime (selected for runtime)
> [DEBUG]   jboss:getopt:jar:4.2.2.GA:runtime (selected for runtime)
> [DEBUG]   jboss.jbossws:streambuffer:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG]   jboss.jbossws:jaxb-xjc:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG]   jboss.jbossws:jboss-xml-binding:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG]   jboss.jbossws:stax-ex:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG]   jboss:javassist:jar:4.2.2.GA:runtime (selected for runtime)
> [DEBUG]   jboss.jbossws:jaxb-impl:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG]   jboss.jbossws:jaxws-tools:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG]   jboss:log4j:jar:4.2.2.GA:runtime (selected for runtime)
> [DEBUG]   jboss.jbossws:jboss-saaj:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG] Retrieving parent-POM: org.codehaus.plexus:plexus::1.0.4 for project: null:plexus-utils:jar:1.1 from the repository.
> [DEBUG]   org.codehaus.plexus:plexus-utils:jar:1.1:runtime (selected for runtime)
> [DEBUG]   sun.jdk:tools:jar:1.5.0:system (selected for system)
> [DEBUG]   jboss.jbossws:jboss-jaxrpc:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG]   jboss:jbossall-client:jar:4.2.2.GA:runtime (selected for runtime)
> [DEBUG]   jboss.jbossws:jaxb-api:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG]   jboss.jbossws:jbossws-client:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG]   jboss.jbossws:jbossws-spi:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG]   jboss:activation:jar:4.2.2.GA:runtime (selected for runtime)
> [DEBUG]   jboss.jbossws:jboss-jaxws:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG]   jboss.jbossws:wstx:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG] Retrieving parent-POM: org.apache.maven:maven::2.0 for project: null:maven-project:jar:2.0 from the repository.
> [DEBUG] Adding managed dependencies for unknown:maven-project
> [DEBUG]   org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
> [DEBUG]   org.codehaus.plexus:plexus-utils:jar:1.0.4
> [DEBUG]   org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-ssh:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-file:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-http-lightweight:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven:maven-project:jar:2.0:runtime (selected for runtime)
> [DEBUG] Adding managed dependencies for unknown:maven-profile
> [DEBUG]   org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
> [DEBUG]   org.codehaus.plexus:plexus-utils:jar:1.0.4
> [DEBUG]   org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-ssh:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-file:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-http-lightweight:jar:1.0-alpha-5
> [DEBUG]     org.apache.maven:maven-profile:jar:2.0:runtime (selected for runtime)
> [DEBUG] Adding managed dependencies for org.apache.maven:maven-model
> [DEBUG]   org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
> [DEBUG]   org.codehaus.plexus:plexus-utils:jar:1.0.4
> [DEBUG]   org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-ssh:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-file:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-http-lightweight:jar:1.0-alpha-5
> [DEBUG]       org.apache.maven:maven-model:jar:2.0:runtime (selected for runtime)
> [DEBUG]         org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
> [DEBUG]       org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
> [DEBUG]       org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8:runtime (selected for runtime)
> [DEBUG]         org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
> [DEBUG]         junit:junit:jar:3.8.1:runtime (selected for runtime)
> [DEBUG]         classworlds:classworlds:jar:1.1-alpha-2:runtime (selected for runtime)
> [DEBUG]     org.apache.maven:maven-model:jar:2.0:runtime (selected for runtime)
> [DEBUG]       org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
> [DEBUG] Adding managed dependencies for org.apache.maven:maven-artifact-manager
> [DEBUG]   org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
> [DEBUG]   org.codehaus.plexus:plexus-utils:jar:1.0.4
> [DEBUG]   org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-ssh:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-file:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-http-lightweight:jar:1.0-alpha-5
> [DEBUG]     org.apache.maven:maven-artifact-manager:jar:2.0:runtime (selected for runtime)
> [DEBUG] Adding managed dependencies for org.apache.maven:maven-repository-metadata
> [DEBUG]   org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
> [DEBUG]   org.codehaus.plexus:plexus-utils:jar:1.0.4
> [DEBUG]   org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-ssh:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-file:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-http-lightweight:jar:1.0-alpha-5
> [DEBUG]       org.apache.maven:maven-repository-metadata:jar:2.0:runtime (selected for runtime)
> [DEBUG]         org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
> [DEBUG]       org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
> [DEBUG] Adding managed dependencies for org.apache.maven:maven-artifact
> [DEBUG]   org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
> [DEBUG]   org.codehaus.plexus:plexus-utils:jar:1.0.4
> [DEBUG]   org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-ssh:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-file:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-http-lightweight:jar:1.0-alpha-5
> [DEBUG]       org.apache.maven:maven-artifact:jar:2.0:runtime (selected for runtime)
> [DEBUG]         org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
> [DEBUG]       org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-5:runtime (selected for runtime)
> [DEBUG]         org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
> [DEBUG]     org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
> [DEBUG]     org.apache.maven:maven-artifact:jar:2.0:runtime (selected for runtime)
> [DEBUG]       org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
> [DEBUG]     org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8:runtime (selected for runtime)
> [DEBUG]       org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
> [DEBUG]       junit:junit:jar:3.8.1:runtime (selected for runtime)
> [DEBUG]       classworlds:classworlds:jar:1.1-alpha-2:runtime (selected for runtime)
> [DEBUG] Adding managed dependencies for org.apache.maven:maven-plugin-api
> [DEBUG]   org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
> [DEBUG]   org.codehaus.plexus:plexus-utils:jar:1.0.4
> [DEBUG]   org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-ssh:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-file:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-http-lightweight:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven:maven-plugin-api:jar:2.0:runtime (selected for runtime)
> [DEBUG]   jboss.jbossws:stax-api:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG]   jboss.jbossws:jaxws-rt:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG] Configuring mojo 'jboss:maven-jbossws-plugin:1.0.0:wsconsume' -->
> [DEBUG]   (f) destdir = output
> [DEBUG]   (f) extension = false
> [DEBUG]   (f) fork = true
> [DEBUG]   (f) keep = true
> [DEBUG]   (f) verbose = true
> [DEBUG]   (f) wsdl = https://xxx/crypto?wsdl
> [DEBUG] -- end configuration --
> [INFO] [jbossws:wsconsume]
> [INFO] Using...
> [INFO] fork: true
> [INFO] keep: true
> [INFO] package: null
> [INFO] wsdlLocation: null
> [INFO] destdir: output
> [INFO] sourcedestdir: output
> [INFO] verbose: true
> [INFO] wsdl: https://xxx/crypto?wsdl
> [INFO] extension: false
> [INFO] binding: null
> Consuming wsdl: https://xxx/crypto?wsdl
> parsing WSDL...
>
>
> generating code...
> com\bean\CryptoService.java
> com\bean\MeioPagamento.java
> com\bean\MeioPagamentoArray.java
> com\bean\ObjectFactory.java
> com\bean\WebServiceCrypto.java
> com\bean\package-info.java
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\CryptoService.java:7: cannot find symbol
> symbol  : class Service
> location: package javax.xml.ws
> import javax.xml.ws.Service;
>                     ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\CryptoService.java:8: cannot find symbol
> symbol  : class WebEndpoint
> location: package javax.xml.ws
> import javax.xml.ws.WebEndpoint;
>                     ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\CryptoService.java:9: cannot find symbol
> symbol  : class WebServiceClient
> location: package javax.xml.ws
> import javax.xml.ws.WebServiceClient;
>                     ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\CryptoService.java:20: cannot find symbol
> symbol: class Service
>     extends Service
>             ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:4: package javax.jws does not exist
> import javax.jws.WebMethod;
>                  ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:5: package javax.jws does not exist
> import javax.jws.WebParam;
>                  ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:6: package javax.jws does not exist
> import javax.jws.WebResult;
>                  ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:7: package javax.jws does not exist
> import javax.jws.WebService;
>                  ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:8: package javax.jws.soap does not exist
> import javax.jws.soap.SOAPBinding;
>                       ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\CryptoService.java:18: cannot find symbol
> symbol: class WebServiceClient
> @WebServiceClient(name = "CryptoService", targetNamespace = "http://bean.com", wsdlLocation = "https://xxx/crypto?wsdl")
>  ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:17: cannot find symbol
> symbol: class WebService
> @WebService(name = "WebServiceCrypto", targetNamespace = "http://bean.com")
>  ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:18: cannot find symbol
> symbol: class SOAPBinding
> @SOAPBinding(style = SOAPBinding.Style.RPC)
>  ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\CryptoService.java:48: cannot find symbol
> symbol  : class WebEndpoint
> location: class com.bean.CryptoService
>     @WebEndpoint(name = "WebServiceCryptoPort")
>      ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:31: cannot find symbol
> symbol  : class WebParam
> location: interface com.bean.WebServiceCrypto
>         @WebParam(name = "MeioDePagamento", partName = "MeioDePagamento")
>          ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:28: cannot find symbol
> symbol  : class WebMethod
> location: interface com.bean.WebServiceCrypto
>     @WebMethod
>      ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:29: cannot find symbol
> symbol  : class WebResult
> location: interface com.bean.WebServiceCrypto
>     @WebResult(partName = "return")
>      ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\CryptoService.java:50: cannot find symbol
> symbol  : variable super
> location: class com.bean.CryptoService
>         return (WebServiceCrypto)super.getPort(new QName("http://bean.com", "WebServiceCryptoPort"), WebServiceCrypto.class);
>                                  ^
> 17 errors
> compilation failed, errors should have been reported
> Failed to invoke WsImport
> java.lang.IllegalStateException: WsImport invocation failed. Try the verbose switch for more information
>         at org.jboss.ws.tools.jaxws.impl.SunRIConsumerImpl.consume(SunRIConsumerImpl.java:220)
>         at org.jboss.wsf.spi.tools.WSContractConsumer.consume(WSContractConsumer.java:196)
>         at org.jboss.wsf.spi.tools.ant.WSConsumeTask.executeNonForked(WSConsumeTask.java:214)
>         at org.jboss.wsf.spi.tools.ant.WSConsumeTask.execute(WSConsumeTask.java:234)
>         at jboss.WSConsumeMojo.execute(WSConsumeMojo.java:86)
>         at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:447)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:539)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:493)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:463)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:311)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:278)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143)
>         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:333)
>         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:126)
>         at org.apache.maven.cli.MavenCli.main(MavenCli.java:282)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:585)
>         at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
>         at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
>         at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
>         at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
> [INFO] ------------------------------------------------------------------------
> [INFO] BUILD SUCCESSFUL
> [INFO] ------------------------------------------------------------------------
> [INFO] Total time: 6 seconds
> [INFO] Finished at: Mon May 26 10:59:31 BRT 2008
> [INFO] Final Memory: 4M/10M
> [INFO] ------------------------------------------------------------------------
>
> The package javax.xml.ws is located in jboss-jaxws-3.0.1-native-2.0.4.GA.jar declared in maven plugin pom.xml!
> Please, help me!
> Thanks
>
>
>
> -----Mensagem original-----
> De: Tim Kettler [mailto:tim.kettler@udo.edu]
> Enviada em: quinta-feira, 22 de maio de 2008 05:29
> Para: Maven Users List
> Assunto: Re: RES: Problem with classloader in maven plugin
>
> Hi,
>
> Claudio Ranieri schrieb:
>> Hi,
>>
>> Why the maven plugins doesn´t load all libraries declared in pom.xml?
>
> You have to distinguish between the plugin project and the project you
> are using the plugin with. All libraries (with a proper scope) declared
> in the pom of the plugin project are available (on the classpath) to the
> plugin during execution. This includes libraries you are specifying in
> the <plugin><dependencies> section of the project using your plugin.
>
> The libraries declared in the pom of the project you are using your
> plugin in however, are not available. And for a good reason, just think
> abaout the bad things that could happen when both, the plugin and your
> project use the same library for example, but a different version of it.
>
> The conclusion in one sentence: You don't ever want the dependencies
> (classpathes) of your project and the dependencies of a plugin used
> during the build of your project mixed.
>
>> I tried to use the initClassLoader because this code works in jaxws-maven-plugin.
>> In the code of jaxws-maven-plugin there is:
>>
>> " Need to build a URLClassloader since Maven removed it form the chain "
>>
>> Why?
>
> I don't know the jaxws-maven-plugin, so I can't really tell anything
> about its design and implementation. You will have to ask the developers
> of the plugin about such specific questions.
>
> All advice I can give you is that you should read and learn about the
> different kinds of classloaders (and classloaders in generel) in Java
> and how to properly use them.
>
> So far, all plugins I've seen the source code of construct a new
> classloader with the classes the external tool needs and then use the
> loadClass() method of that classloader to get an instance of the class
> they need. Examples of this can be seen in the compiler-plugin or
> fit-maven-plugin (as someone on the dev list already wrote).
>
>> Thanks
>
> -Tim
>
>> -----Mensagem original-----
>> De: Tim Kettler [mailto:tim.kettler@udo.edu]
>> Enviada em: quarta-feira, 21 de maio de 2008 10:57
>> Para: Maven Users List
>> Assunto: Re: Problem with classloader in maven plugin
>>
>> Hi,
>>
>> you've missunderstood the concept of a context classloader.
>>
>> A documentation bug [1] is open since a long time. Setting the context
>> classloader doesn't mean that all classes created from that point on are
>> created through this classloader. See here [2] and [3] for more information.
>>
>> [1] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4868493
>> [2] http://www.javaworld.com/javaqa/2003-06/01-qa-0606-load.html
>> [3] http://www.javageeks.com/Papers/ClassForName/index.html
>>
>> -Tim
>>
>> Claudio Ranieri schrieb:
>>> Hi
>>>
>>> I am trying to create a maven plugin to jboss wsconsume, but I have a problem with classloader in plugin.
>>> My plugin is based in an ant task (WSConsumeTask).
>>> I am using maven 2.0.8 on Windows machine.
>>> When I created a simple Java project with libraries necessary, my code works.
>>> How shown below:
>>>
>>> public static void main(String[] args) {
>>>   WSConsumeTask t = new WSConsumeTask();
>>>   t.setWsdl("https://xxx/crypto?wsdl");
>>>   t.setVerbose(true);
>>>   t.setKeep(true);
>>>   t.execute();
>>> }
>>>
>>> But when I am using into maven plugin, I got problem with classloader.
>>> I got this exception:
>>>
>>> C:\eclipse\workspace\TestePluginMaven\output\com\buscape\bean\CryptoService.java:7: cannot find symbol
>>> symbol  : class Service
>>> location: package javax.xml.ws
>>> import javax.xml.ws.Service;
>>>                     ^
>>> C:\eclipse\workspace\TestePluginMaven\output\com\buscape\bean\CryptoService.java:8: cannot find symbol
>>> symbol  : class WebEndpoint
>>> location: package javax.xml.ws
>>> import javax.xml.ws.WebEndpoint;
>>>                     ^
>>> C:\eclipse\workspace\TestePluginMaven\output\com\buscape\bean\CryptoService.java:9: cannot find symbol
>>> symbol  : class WebServiceClient
>>> location: package javax.xml.ws
>>> import javax.xml.ws.WebServiceClient;
>>>
>>> The plugin classloader doesn´t load the jaxws libraries. But this libraries was added in pom.xml of plugin.
>>> I tried to add dependencies tag in my plugin config, but didn´t works. How shown below:
>>>
>>> <plugin>
>>>   <groupId>jboss</groupId>
>>>   <artifactId>maven-jbossws-plugin</artifactId>
>>>   <version>1.0.0</version>
>>>   <configuration>
>>>     <verbose>true</verbose>
>>>     <keep>true</keep>
>>>     <wsdl>https://xxx/crypto?wsdl</wsdl>
>>>   </configuration>
>>>   <dependencies>
>>>     <dependency>
>>>       <groupId>jboss.jbossws</groupId>
>>>       <artifactId>jaxws-tools</artifactId>
>>>       <version>3.0.1-native-2.0.4.GA</version>
>>>       <scope>compile</scope>
>>>     </dependency>
>>>     <dependency>
>>>       <groupId>jboss.jbossws</groupId>
>>>       <artifactId>jboss-jaxws</artifactId>
>>>       <version>3.0.1-native-2.0.4.GA</version>
>>>       <scope>compile</scope>
>>>     </dependency>
>>>   </dependencies>
>>> </plugin>
>>>
>>> I tried too to use an initClassLoader based in jaxws-maven-plugin source, how shown below:
>>>
>>>    private String initClassLoader(ClassLoader parent) throws MojoExecutionException {
>>>                     try {
>>>                                 List classpathFiles = project.getCompileClasspathElements();
>>>                         URL[] urls = new URL[classpathFiles.size() + 4];
>>>                         StringBuffer classPath = new StringBuffer();
>>>                         for (int i = 0; i < classpathFiles.size(); ++i) {
>>>                             getLog().debug((String)classpathFiles.get(i));
>>>                             urls[i] = new File((String)classpathFiles.get(i)).toURL();
>>>                             classPath.append((String)classpathFiles.get(i));
>>>                             classPath.append(File.pathSeparatorChar);
>>>                         }
>>>                         urls[classpathFiles.size()] = new File(project.getBuild().getOutputDirectory()).toURL();
>>>
>>>                         urls[classpathFiles.size() + 1] = getArtifact("jboss.jbossws:jboss-jaxws");
>>>
>>>                         urls[classpathFiles.size() + 2] = getArtifact("jboss.jbossws:jaxws-tools");
>>>
>>>                         File toolsJar = new File(System.getProperty("java.home"),"../lib/tools.jar");
>>>                         if (!toolsJar.exists()) {
>>>                                 toolsJar = new File(System.getProperty("java.home"),"lib/tools.jar");
>>>                         }
>>>                         urls[classpathFiles.size() + 3] = toolsJar.toURL();
>>>
>>>                         System.out.println("urls: "+Arrays.toString(urls));
>>>
>>>                         URLClassLoader cl = new URLClassLoader(urls,parent);
>>>                         // Set the new classloader
>>>                         Thread.currentThread().setContextClassLoader(cl);
>>>                         System.setProperty("java.class.path",classPath.toString());
>>>                         String sysCp = System.getProperty("java.class.path");
>>>                         return sysCp;
>>>                     }
>>>                     catch (MalformedURLException e) {
>>>                         throw new MojoExecutionException(e.getMessage(),e);
>>>                     }
>>>                     catch (DependencyResolutionRequiredException e) {
>>>                         throw new MojoExecutionException(e.getMessage(),e);
>>>                     }
>>>
>>>     }
>>>
>>>     public void execute() throws MojoExecutionException {
>>>                   // Need to build a URLClassloader since Maven removed it form the chain
>>>         ClassLoader parent = this.getClass().getClassLoader();
>>>         String originalSystemClasspath = this.initClassLoader( parent );
>>>
>>>         try {
>>>
>>>                         // Execute WSConsumeTask
>>>                         WSConsumeTask t = new WSConsumeTask();
>>>                                   t.setWsdl(wsdl);
>>>                                   t.setVerbose(verbose);
>>>                                   t.setKeep(keep);
>>>                                   t.execute();
>>>         }
>>>         finally {
>>>                 // Set back the old classloader
>>>           Thread.currentThread().setContextClassLoader(parent);
>>>           System.setProperty("java.class.path",originalSystemClasspath);
>>>         }
>>>     }
>>>
>>> But, it doesn´t works.
>>> Please, can someone help me?
>>> Thanks
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>


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


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


Re: RES: RES: Problem with classloader in maven plugin

Posted by Tim Kettler <ti...@udo.edu>.
Hi,

have you tried (just as a test) to declare a variable of one of the 
missing types? Just something simple like:

   javax.xml.ws.WebServiceClient testClient;

in your plugin source code. Just to see if it compiles. If it compiles, 
you can be sure that the classes are on the classpath of the plugin and 
you need to further investigate the inner workings in the wsconsume task 
you are reusing.

...later:

I Just took a very quick look at the wsconsume source code [1]. In 
particular you should have a look at the executeNonForked() and 
executeForked() methods to see the source of your problems. The task 
sets up a classpath on it's own, so everything you set up on the maven 
site is just not used. You should investigate how to properly configure 
the classpath for the task or even use WSContractConsumer [2] directly.

If you have further questions about the correct usage of WSConsumeTask 
and WSContractConsumer it's probably best to ask the people developing 
it on their mailinglist.

-Tim

[1] 
http://anonsvn.jboss.org/repos/jbossws/spi/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/WSConsumeTask.java
[2] 
http://anonsvn.jboss.org/repos/jbossws/spi/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractConsumer.java

Claudio Ranieri schrieb:
> Hi,
> 
> Tim wrote:
> 
> "All libraries (with a proper scope) declared in the pom of the plugin project are available (on the classpath) to the plugin during execution"
> 
> It is not true for my plugin project.
> My plugin project has this pom.xml:
> 
> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
>   <modelVersion>4.0.0</modelVersion>
>   <groupId>jboss</groupId>
>   <artifactId>maven-jbossws-plugin</artifactId>
>   <packaging>maven-plugin</packaging>
>   <version>1.0.0</version>
>   <name>maven-jbossws-plugin Maven Mojo</name>
>   <url>http://maven.apache.org</url>
>   <dependencies>
>     <!-- Maven Plugin -->
>     <dependency>
>       <groupId>org.apache.maven</groupId>
>       <artifactId>maven-plugin-api</artifactId>
>       <version>2.0</version>
>     </dependency>
>     <dependency>
>        <groupId>org.apache.maven</groupId>
>        <artifactId>maven-project</artifactId>
>        <version>2.0</version>
>     </dependency>
>     <!-- Test -->
>     <dependency>
>       <groupId>junit</groupId>
>       <artifactId>junit</artifactId>
>       <version>3.8.1</version>
>       <scope>test</scope>
>     </dependency>
>     <!-- JbossAs Dependencies -->
>     <dependency>
>                 <groupId>jboss</groupId>
>                 <artifactId>activation</artifactId>
>                 <version>4.2.2.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss</groupId>
>                 <artifactId>getopt</artifactId>
>                 <version>4.2.2.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss</groupId>
>                 <artifactId>javassist</artifactId>
>                 <version>4.2.2.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss</groupId>
>                 <artifactId>jbossall-client</artifactId>
>                 <version>4.2.2.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss</groupId>
>                 <artifactId>log4j</artifactId>
>                 <version>4.2.2.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss</groupId>
>                 <artifactId>mail</artifactId>
>                 <version>4.2.2.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>     <!-- JBossWS Dependencies -->
>     <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>stax-ex</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>     <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>streambuffer</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>jaxb-api</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>jaxb-impl</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>jboss-jaxrpc</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>jaxb-xjc</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>jaxws-rt</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>jaxws-tools</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>wstx</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>jboss-jaxws</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>jboss-saaj</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>jbossws-client</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>jbossws-spi</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>jboss-xml-binding</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <dependency>
>                 <groupId>jboss.jbossws</groupId>
>                 <artifactId>stax-api</artifactId>
>                 <version>3.0.1-native-2.0.4.GA</version>
>                 <scope>compile</scope>
>         </dependency>
>         <!-- Java Tools -->
>         <dependency>
>         <groupId>sun.jdk</groupId>
>         <artifactId>tools</artifactId>
>         <version>1.5.0</version>
>         <scope>system</scope>
>         <systemPath>${java.home}/../lib/tools.jar</systemPath>
>     </dependency>
>     <!-- Ant -->
>     <dependency>
>                 <groupId>org.apache.ant</groupId>
>                 <artifactId>ant</artifactId>
>                 <version>1.7.0</version>
>                 <scope>compile</scope>
>         </dependency>
>   </dependencies>
> </project>
> 
> My project that uses my maven plugin has this pom.xml:
> 
> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
>   <modelVersion>4.0.0</modelVersion>
>   <groupId>com</groupId>
>   <artifactId>TestePluginMaven</artifactId>
>   <packaging>jar</packaging>
>   <version>1.0-SNAPSHOT</version>
>   <name>TestePluginMaven</name>
>   <url>http://maven.apache.org</url>
>   <dependencies>
>     <dependency>
>       <groupId>junit</groupId>
>       <artifactId>junit</artifactId>
>       <version>3.8.1</version>
>       <scope>test</scope>
>     </dependency>
>   </dependencies>
>   <build>
>     <plugins>
>       <plugin>
>         <groupId>jboss</groupId>
>         <artifactId>maven-jbossws-plugin</artifactId>
>         <version>1.0.0</version>
>         <configuration>
>                 <verbose>true</verbose>
>                 <keep>true</keep>
>                 <wsdl>https://xxx/crypto?wsdl</wsdl>
>         </configuration>
>       </plugin>
>       <!-- Don't forget Java 5!! -->
>       <plugin>
>         <artifactId>maven-compiler-plugin</artifactId>
>         <configuration>
>           <source>1.5</source>
>           <target>1.5</target>
>         </configuration>
>       </plugin>
>     </plugins>
>   </build>
> </project>
> 
> When I execute my plugin I get:
> 
> + Error stacktraces are turned on.
> Maven version: 2.0.8
> Java version: 1.5.0_06
> OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"
> [DEBUG] Building Maven user-level plugin registry from: 'C:\Documents and Settings\claudior\.m2\plugin-registry.xml'
> [DEBUG] Building Maven global-level plugin registry from: 'C:\apache-maven-2.0.8\bin\..\conf\plugin-registry.xml'
> [INFO] Scanning for projects...
> [INFO] Searching repository for plugin with prefix: 'jbossws'.
> [DEBUG] Loading plugin prefixes from group: org.apache.maven.plugins
> [DEBUG] Loading plugin prefixes from group: org.codehaus.mojo
> [DEBUG] maven-compiler-plugin: resolved to version 2.0.2 from repository central
> [DEBUG] Retrieving parent-POM: org.apache.maven.plugins:maven-plugins::8 for project: null:maven-compiler-plugin:maven-plugin:2.0.2 from the repository.
> [DEBUG] Retrieving parent-POM: org.apache.maven:maven-parent::5 for project: org.apache.maven.plugins:maven-plugins:pom:8 from the repository.
> [DEBUG] Retrieving parent-POM: org.apache:apache::3 for project: org.apache.maven:maven-parent:pom:5 from the repository.
> [INFO] ------------------------------------------------------------------------
> [INFO] Building TestePluginMaven
> [INFO]    task-segment: [jbossws:wsconsume]
> [INFO] ------------------------------------------------------------------------
> [DEBUG] jboss:maven-jbossws-plugin:maven-plugin:1.0.0:runtime (selected for runtime)
> [DEBUG]   jboss:mail:jar:4.2.2.GA:runtime (selected for runtime)
> [DEBUG] Retrieving parent-POM: org.apache.ant:ant-parent::1.7.0 for project: org.apache.ant:ant:jar:1.7.0 from the repository.
> [DEBUG]   org.apache.ant:ant:jar:1.7.0:runtime (selected for runtime)
> [DEBUG]     org.apache.ant:ant-launcher:jar:1.7.0:runtime (selected for runtime)
> [DEBUG]   jboss:getopt:jar:4.2.2.GA:runtime (selected for runtime)
> [DEBUG]   jboss.jbossws:streambuffer:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG]   jboss.jbossws:jaxb-xjc:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG]   jboss.jbossws:jboss-xml-binding:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG]   jboss.jbossws:stax-ex:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG]   jboss:javassist:jar:4.2.2.GA:runtime (selected for runtime)
> [DEBUG]   jboss.jbossws:jaxb-impl:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG]   jboss.jbossws:jaxws-tools:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG]   jboss:log4j:jar:4.2.2.GA:runtime (selected for runtime)
> [DEBUG]   jboss.jbossws:jboss-saaj:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG] Retrieving parent-POM: org.codehaus.plexus:plexus::1.0.4 for project: null:plexus-utils:jar:1.1 from the repository.
> [DEBUG]   org.codehaus.plexus:plexus-utils:jar:1.1:runtime (selected for runtime)
> [DEBUG]   sun.jdk:tools:jar:1.5.0:system (selected for system)
> [DEBUG]   jboss.jbossws:jboss-jaxrpc:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG]   jboss:jbossall-client:jar:4.2.2.GA:runtime (selected for runtime)
> [DEBUG]   jboss.jbossws:jaxb-api:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG]   jboss.jbossws:jbossws-client:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG]   jboss.jbossws:jbossws-spi:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG]   jboss:activation:jar:4.2.2.GA:runtime (selected for runtime)
> [DEBUG]   jboss.jbossws:jboss-jaxws:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG]   jboss.jbossws:wstx:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG] Retrieving parent-POM: org.apache.maven:maven::2.0 for project: null:maven-project:jar:2.0 from the repository.
> [DEBUG] Adding managed dependencies for unknown:maven-project
> [DEBUG]   org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
> [DEBUG]   org.codehaus.plexus:plexus-utils:jar:1.0.4
> [DEBUG]   org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-ssh:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-file:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-http-lightweight:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven:maven-project:jar:2.0:runtime (selected for runtime)
> [DEBUG] Adding managed dependencies for unknown:maven-profile
> [DEBUG]   org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
> [DEBUG]   org.codehaus.plexus:plexus-utils:jar:1.0.4
> [DEBUG]   org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-ssh:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-file:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-http-lightweight:jar:1.0-alpha-5
> [DEBUG]     org.apache.maven:maven-profile:jar:2.0:runtime (selected for runtime)
> [DEBUG] Adding managed dependencies for org.apache.maven:maven-model
> [DEBUG]   org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
> [DEBUG]   org.codehaus.plexus:plexus-utils:jar:1.0.4
> [DEBUG]   org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-ssh:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-file:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-http-lightweight:jar:1.0-alpha-5
> [DEBUG]       org.apache.maven:maven-model:jar:2.0:runtime (selected for runtime)
> [DEBUG]         org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
> [DEBUG]       org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
> [DEBUG]       org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8:runtime (selected for runtime)
> [DEBUG]         org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
> [DEBUG]         junit:junit:jar:3.8.1:runtime (selected for runtime)
> [DEBUG]         classworlds:classworlds:jar:1.1-alpha-2:runtime (selected for runtime)
> [DEBUG]     org.apache.maven:maven-model:jar:2.0:runtime (selected for runtime)
> [DEBUG]       org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
> [DEBUG] Adding managed dependencies for org.apache.maven:maven-artifact-manager
> [DEBUG]   org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
> [DEBUG]   org.codehaus.plexus:plexus-utils:jar:1.0.4
> [DEBUG]   org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-ssh:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-file:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-http-lightweight:jar:1.0-alpha-5
> [DEBUG]     org.apache.maven:maven-artifact-manager:jar:2.0:runtime (selected for runtime)
> [DEBUG] Adding managed dependencies for org.apache.maven:maven-repository-metadata
> [DEBUG]   org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
> [DEBUG]   org.codehaus.plexus:plexus-utils:jar:1.0.4
> [DEBUG]   org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-ssh:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-file:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-http-lightweight:jar:1.0-alpha-5
> [DEBUG]       org.apache.maven:maven-repository-metadata:jar:2.0:runtime (selected for runtime)
> [DEBUG]         org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
> [DEBUG]       org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
> [DEBUG] Adding managed dependencies for org.apache.maven:maven-artifact
> [DEBUG]   org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
> [DEBUG]   org.codehaus.plexus:plexus-utils:jar:1.0.4
> [DEBUG]   org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-ssh:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-file:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-http-lightweight:jar:1.0-alpha-5
> [DEBUG]       org.apache.maven:maven-artifact:jar:2.0:runtime (selected for runtime)
> [DEBUG]         org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
> [DEBUG]       org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-5:runtime (selected for runtime)
> [DEBUG]         org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
> [DEBUG]     org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
> [DEBUG]     org.apache.maven:maven-artifact:jar:2.0:runtime (selected for runtime)
> [DEBUG]       org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
> [DEBUG]     org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8:runtime (selected for runtime)
> [DEBUG]       org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
> [DEBUG]       junit:junit:jar:3.8.1:runtime (selected for runtime)
> [DEBUG]       classworlds:classworlds:jar:1.1-alpha-2:runtime (selected for runtime)
> [DEBUG] Adding managed dependencies for org.apache.maven:maven-plugin-api
> [DEBUG]   org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
> [DEBUG]   org.codehaus.plexus:plexus-utils:jar:1.0.4
> [DEBUG]   org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-ssh:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-file:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven.wagon:wagon-http-lightweight:jar:1.0-alpha-5
> [DEBUG]   org.apache.maven:maven-plugin-api:jar:2.0:runtime (selected for runtime)
> [DEBUG]   jboss.jbossws:stax-api:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG]   jboss.jbossws:jaxws-rt:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
> [DEBUG] Configuring mojo 'jboss:maven-jbossws-plugin:1.0.0:wsconsume' -->
> [DEBUG]   (f) destdir = output
> [DEBUG]   (f) extension = false
> [DEBUG]   (f) fork = true
> [DEBUG]   (f) keep = true
> [DEBUG]   (f) verbose = true
> [DEBUG]   (f) wsdl = https://xxx/crypto?wsdl
> [DEBUG] -- end configuration --
> [INFO] [jbossws:wsconsume]
> [INFO] Using...
> [INFO] fork: true
> [INFO] keep: true
> [INFO] package: null
> [INFO] wsdlLocation: null
> [INFO] destdir: output
> [INFO] sourcedestdir: output
> [INFO] verbose: true
> [INFO] wsdl: https://xxx/crypto?wsdl
> [INFO] extension: false
> [INFO] binding: null
> Consuming wsdl: https://xxx/crypto?wsdl
> parsing WSDL...
> 
> 
> generating code...
> com\bean\CryptoService.java
> com\bean\MeioPagamento.java
> com\bean\MeioPagamentoArray.java
> com\bean\ObjectFactory.java
> com\bean\WebServiceCrypto.java
> com\bean\package-info.java
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\CryptoService.java:7: cannot find symbol
> symbol  : class Service
> location: package javax.xml.ws
> import javax.xml.ws.Service;
>                     ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\CryptoService.java:8: cannot find symbol
> symbol  : class WebEndpoint
> location: package javax.xml.ws
> import javax.xml.ws.WebEndpoint;
>                     ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\CryptoService.java:9: cannot find symbol
> symbol  : class WebServiceClient
> location: package javax.xml.ws
> import javax.xml.ws.WebServiceClient;
>                     ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\CryptoService.java:20: cannot find symbol
> symbol: class Service
>     extends Service
>             ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:4: package javax.jws does not exist
> import javax.jws.WebMethod;
>                  ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:5: package javax.jws does not exist
> import javax.jws.WebParam;
>                  ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:6: package javax.jws does not exist
> import javax.jws.WebResult;
>                  ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:7: package javax.jws does not exist
> import javax.jws.WebService;
>                  ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:8: package javax.jws.soap does not exist
> import javax.jws.soap.SOAPBinding;
>                       ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\CryptoService.java:18: cannot find symbol
> symbol: class WebServiceClient
> @WebServiceClient(name = "CryptoService", targetNamespace = "http://bean.com", wsdlLocation = "https://xxx/crypto?wsdl")
>  ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:17: cannot find symbol
> symbol: class WebService
> @WebService(name = "WebServiceCrypto", targetNamespace = "http://bean.com")
>  ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:18: cannot find symbol
> symbol: class SOAPBinding
> @SOAPBinding(style = SOAPBinding.Style.RPC)
>  ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\CryptoService.java:48: cannot find symbol
> symbol  : class WebEndpoint
> location: class com.bean.CryptoService
>     @WebEndpoint(name = "WebServiceCryptoPort")
>      ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:31: cannot find symbol
> symbol  : class WebParam
> location: interface com.bean.WebServiceCrypto
>         @WebParam(name = "MeioDePagamento", partName = "MeioDePagamento")
>          ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:28: cannot find symbol
> symbol  : class WebMethod
> location: interface com.bean.WebServiceCrypto
>     @WebMethod
>      ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:29: cannot find symbol
> symbol  : class WebResult
> location: interface com.bean.WebServiceCrypto
>     @WebResult(partName = "return")
>      ^
> C:\eclipse\workspace\TestePluginMaven\output\com\bean\CryptoService.java:50: cannot find symbol
> symbol  : variable super
> location: class com.bean.CryptoService
>         return (WebServiceCrypto)super.getPort(new QName("http://bean.com", "WebServiceCryptoPort"), WebServiceCrypto.class);
>                                  ^
> 17 errors
> compilation failed, errors should have been reported
> Failed to invoke WsImport
> java.lang.IllegalStateException: WsImport invocation failed. Try the verbose switch for more information
>         at org.jboss.ws.tools.jaxws.impl.SunRIConsumerImpl.consume(SunRIConsumerImpl.java:220)
>         at org.jboss.wsf.spi.tools.WSContractConsumer.consume(WSContractConsumer.java:196)
>         at org.jboss.wsf.spi.tools.ant.WSConsumeTask.executeNonForked(WSConsumeTask.java:214)
>         at org.jboss.wsf.spi.tools.ant.WSConsumeTask.execute(WSConsumeTask.java:234)
>         at jboss.WSConsumeMojo.execute(WSConsumeMojo.java:86)
>         at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:447)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:539)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:493)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:463)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:311)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:278)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143)
>         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:333)
>         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:126)
>         at org.apache.maven.cli.MavenCli.main(MavenCli.java:282)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:585)
>         at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
>         at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
>         at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
>         at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
> [INFO] ------------------------------------------------------------------------
> [INFO] BUILD SUCCESSFUL
> [INFO] ------------------------------------------------------------------------
> [INFO] Total time: 6 seconds
> [INFO] Finished at: Mon May 26 10:59:31 BRT 2008
> [INFO] Final Memory: 4M/10M
> [INFO] ------------------------------------------------------------------------
> 
> The package javax.xml.ws is located in jboss-jaxws-3.0.1-native-2.0.4.GA.jar declared in maven plugin pom.xml!
> Please, help me!
> Thanks
> 
> 
> 
> -----Mensagem original-----
> De: Tim Kettler [mailto:tim.kettler@udo.edu]
> Enviada em: quinta-feira, 22 de maio de 2008 05:29
> Para: Maven Users List
> Assunto: Re: RES: Problem with classloader in maven plugin
> 
> Hi,
> 
> Claudio Ranieri schrieb:
>> Hi,
>>
>> Why the maven plugins doesn´t load all libraries declared in pom.xml?
> 
> You have to distinguish between the plugin project and the project you
> are using the plugin with. All libraries (with a proper scope) declared
> in the pom of the plugin project are available (on the classpath) to the
> plugin during execution. This includes libraries you are specifying in
> the <plugin><dependencies> section of the project using your plugin.
> 
> The libraries declared in the pom of the project you are using your
> plugin in however, are not available. And for a good reason, just think
> abaout the bad things that could happen when both, the plugin and your
> project use the same library for example, but a different version of it.
> 
> The conclusion in one sentence: You don't ever want the dependencies
> (classpathes) of your project and the dependencies of a plugin used
> during the build of your project mixed.
> 
>> I tried to use the initClassLoader because this code works in jaxws-maven-plugin.
>> In the code of jaxws-maven-plugin there is:
>>
>> " Need to build a URLClassloader since Maven removed it form the chain "
>>
>> Why?
> 
> I don't know the jaxws-maven-plugin, so I can't really tell anything
> about its design and implementation. You will have to ask the developers
> of the plugin about such specific questions.
> 
> All advice I can give you is that you should read and learn about the
> different kinds of classloaders (and classloaders in generel) in Java
> and how to properly use them.
> 
> So far, all plugins I've seen the source code of construct a new
> classloader with the classes the external tool needs and then use the
> loadClass() method of that classloader to get an instance of the class
> they need. Examples of this can be seen in the compiler-plugin or
> fit-maven-plugin (as someone on the dev list already wrote).
> 
>> Thanks
> 
> -Tim
> 
>> -----Mensagem original-----
>> De: Tim Kettler [mailto:tim.kettler@udo.edu]
>> Enviada em: quarta-feira, 21 de maio de 2008 10:57
>> Para: Maven Users List
>> Assunto: Re: Problem with classloader in maven plugin
>>
>> Hi,
>>
>> you've missunderstood the concept of a context classloader.
>>
>> A documentation bug [1] is open since a long time. Setting the context
>> classloader doesn't mean that all classes created from that point on are
>> created through this classloader. See here [2] and [3] for more information.
>>
>> [1] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4868493
>> [2] http://www.javaworld.com/javaqa/2003-06/01-qa-0606-load.html
>> [3] http://www.javageeks.com/Papers/ClassForName/index.html
>>
>> -Tim
>>
>> Claudio Ranieri schrieb:
>>> Hi
>>>
>>> I am trying to create a maven plugin to jboss wsconsume, but I have a problem with classloader in plugin.
>>> My plugin is based in an ant task (WSConsumeTask).
>>> I am using maven 2.0.8 on Windows machine.
>>> When I created a simple Java project with libraries necessary, my code works.
>>> How shown below:
>>>
>>> public static void main(String[] args) {
>>>   WSConsumeTask t = new WSConsumeTask();
>>>   t.setWsdl("https://xxx/crypto?wsdl");
>>>   t.setVerbose(true);
>>>   t.setKeep(true);
>>>   t.execute();
>>> }
>>>
>>> But when I am using into maven plugin, I got problem with classloader.
>>> I got this exception:
>>>
>>> C:\eclipse\workspace\TestePluginMaven\output\com\buscape\bean\CryptoService.java:7: cannot find symbol
>>> symbol  : class Service
>>> location: package javax.xml.ws
>>> import javax.xml.ws.Service;
>>>                     ^
>>> C:\eclipse\workspace\TestePluginMaven\output\com\buscape\bean\CryptoService.java:8: cannot find symbol
>>> symbol  : class WebEndpoint
>>> location: package javax.xml.ws
>>> import javax.xml.ws.WebEndpoint;
>>>                     ^
>>> C:\eclipse\workspace\TestePluginMaven\output\com\buscape\bean\CryptoService.java:9: cannot find symbol
>>> symbol  : class WebServiceClient
>>> location: package javax.xml.ws
>>> import javax.xml.ws.WebServiceClient;
>>>
>>> The plugin classloader doesn´t load the jaxws libraries. But this libraries was added in pom.xml of plugin.
>>> I tried to add dependencies tag in my plugin config, but didn´t works. How shown below:
>>>
>>> <plugin>
>>>   <groupId>jboss</groupId>
>>>   <artifactId>maven-jbossws-plugin</artifactId>
>>>   <version>1.0.0</version>
>>>   <configuration>
>>>     <verbose>true</verbose>
>>>     <keep>true</keep>
>>>     <wsdl>https://xxx/crypto?wsdl</wsdl>
>>>   </configuration>
>>>   <dependencies>
>>>     <dependency>
>>>       <groupId>jboss.jbossws</groupId>
>>>       <artifactId>jaxws-tools</artifactId>
>>>       <version>3.0.1-native-2.0.4.GA</version>
>>>       <scope>compile</scope>
>>>     </dependency>
>>>     <dependency>
>>>       <groupId>jboss.jbossws</groupId>
>>>       <artifactId>jboss-jaxws</artifactId>
>>>       <version>3.0.1-native-2.0.4.GA</version>
>>>       <scope>compile</scope>
>>>     </dependency>
>>>   </dependencies>
>>> </plugin>
>>>
>>> I tried too to use an initClassLoader based in jaxws-maven-plugin source, how shown below:
>>>
>>>    private String initClassLoader(ClassLoader parent) throws MojoExecutionException {
>>>                     try {
>>>                                 List classpathFiles = project.getCompileClasspathElements();
>>>                         URL[] urls = new URL[classpathFiles.size() + 4];
>>>                         StringBuffer classPath = new StringBuffer();
>>>                         for (int i = 0; i < classpathFiles.size(); ++i) {
>>>                             getLog().debug((String)classpathFiles.get(i));
>>>                             urls[i] = new File((String)classpathFiles.get(i)).toURL();
>>>                             classPath.append((String)classpathFiles.get(i));
>>>                             classPath.append(File.pathSeparatorChar);
>>>                         }
>>>                         urls[classpathFiles.size()] = new File(project.getBuild().getOutputDirectory()).toURL();
>>>
>>>                         urls[classpathFiles.size() + 1] = getArtifact("jboss.jbossws:jboss-jaxws");
>>>
>>>                         urls[classpathFiles.size() + 2] = getArtifact("jboss.jbossws:jaxws-tools");
>>>
>>>                         File toolsJar = new File(System.getProperty("java.home"),"../lib/tools.jar");
>>>                         if (!toolsJar.exists()) {
>>>                                 toolsJar = new File(System.getProperty("java.home"),"lib/tools.jar");
>>>                         }
>>>                         urls[classpathFiles.size() + 3] = toolsJar.toURL();
>>>
>>>                         System.out.println("urls: "+Arrays.toString(urls));
>>>
>>>                         URLClassLoader cl = new URLClassLoader(urls,parent);
>>>                         // Set the new classloader
>>>                         Thread.currentThread().setContextClassLoader(cl);
>>>                         System.setProperty("java.class.path",classPath.toString());
>>>                         String sysCp = System.getProperty("java.class.path");
>>>                         return sysCp;
>>>                     }
>>>                     catch (MalformedURLException e) {
>>>                         throw new MojoExecutionException(e.getMessage(),e);
>>>                     }
>>>                     catch (DependencyResolutionRequiredException e) {
>>>                         throw new MojoExecutionException(e.getMessage(),e);
>>>                     }
>>>
>>>     }
>>>
>>>     public void execute() throws MojoExecutionException {
>>>                   // Need to build a URLClassloader since Maven removed it form the chain
>>>         ClassLoader parent = this.getClass().getClassLoader();
>>>         String originalSystemClasspath = this.initClassLoader( parent );
>>>
>>>         try {
>>>
>>>                         // Execute WSConsumeTask
>>>                         WSConsumeTask t = new WSConsumeTask();
>>>                                   t.setWsdl(wsdl);
>>>                                   t.setVerbose(verbose);
>>>                                   t.setKeep(keep);
>>>                                   t.execute();
>>>         }
>>>         finally {
>>>                 // Set back the old classloader
>>>           Thread.currentThread().setContextClassLoader(parent);
>>>           System.setProperty("java.class.path",originalSystemClasspath);
>>>         }
>>>     }
>>>
>>> But, it doesn´t works.
>>> Please, can someone help me?
>>> Thanks
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 


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


RES: RES: Problem with classloader in maven plugin

Posted by Claudio Ranieri <cl...@buscape-inc.com>.
Hi,

Tim wrote:

"All libraries (with a proper scope) declared in the pom of the plugin project are available (on the classpath) to the plugin during execution"

It is not true for my plugin project.
My plugin project has this pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>jboss</groupId>
  <artifactId>maven-jbossws-plugin</artifactId>
  <packaging>maven-plugin</packaging>
  <version>1.0.0</version>
  <name>maven-jbossws-plugin Maven Mojo</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <!-- Maven Plugin -->
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-plugin-api</artifactId>
      <version>2.0</version>
    </dependency>
    <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-project</artifactId>
       <version>2.0</version>
    </dependency>
    <!-- Test -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <!-- JbossAs Dependencies -->
    <dependency>
                <groupId>jboss</groupId>
                <artifactId>activation</artifactId>
                <version>4.2.2.GA</version>
                <scope>compile</scope>
        </dependency>
        <dependency>
                <groupId>jboss</groupId>
                <artifactId>getopt</artifactId>
                <version>4.2.2.GA</version>
                <scope>compile</scope>
        </dependency>
        <dependency>
                <groupId>jboss</groupId>
                <artifactId>javassist</artifactId>
                <version>4.2.2.GA</version>
                <scope>compile</scope>
        </dependency>
        <dependency>
                <groupId>jboss</groupId>
                <artifactId>jbossall-client</artifactId>
                <version>4.2.2.GA</version>
                <scope>compile</scope>
        </dependency>
        <dependency>
                <groupId>jboss</groupId>
                <artifactId>log4j</artifactId>
                <version>4.2.2.GA</version>
                <scope>compile</scope>
        </dependency>
        <dependency>
                <groupId>jboss</groupId>
                <artifactId>mail</artifactId>
                <version>4.2.2.GA</version>
                <scope>compile</scope>
        </dependency>
    <!-- JBossWS Dependencies -->
    <dependency>
                <groupId>jboss.jbossws</groupId>
                <artifactId>stax-ex</artifactId>
                <version>3.0.1-native-2.0.4.GA</version>
                <scope>compile</scope>
        </dependency>
    <dependency>
                <groupId>jboss.jbossws</groupId>
                <artifactId>streambuffer</artifactId>
                <version>3.0.1-native-2.0.4.GA</version>
                <scope>compile</scope>
        </dependency>
        <dependency>
                <groupId>jboss.jbossws</groupId>
                <artifactId>jaxb-api</artifactId>
                <version>3.0.1-native-2.0.4.GA</version>
                <scope>compile</scope>
        </dependency>
        <dependency>
                <groupId>jboss.jbossws</groupId>
                <artifactId>jaxb-impl</artifactId>
                <version>3.0.1-native-2.0.4.GA</version>
                <scope>compile</scope>
        </dependency>
        <dependency>
                <groupId>jboss.jbossws</groupId>
                <artifactId>jboss-jaxrpc</artifactId>
                <version>3.0.1-native-2.0.4.GA</version>
                <scope>compile</scope>
        </dependency>
        <dependency>
                <groupId>jboss.jbossws</groupId>
                <artifactId>jaxb-xjc</artifactId>
                <version>3.0.1-native-2.0.4.GA</version>
                <scope>compile</scope>
        </dependency>
        <dependency>
                <groupId>jboss.jbossws</groupId>
                <artifactId>jaxws-rt</artifactId>
                <version>3.0.1-native-2.0.4.GA</version>
                <scope>compile</scope>
        </dependency>
        <dependency>
                <groupId>jboss.jbossws</groupId>
                <artifactId>jaxws-tools</artifactId>
                <version>3.0.1-native-2.0.4.GA</version>
                <scope>compile</scope>
        </dependency>
        <dependency>
                <groupId>jboss.jbossws</groupId>
                <artifactId>wstx</artifactId>
                <version>3.0.1-native-2.0.4.GA</version>
                <scope>compile</scope>
        </dependency>
        <dependency>
                <groupId>jboss.jbossws</groupId>
                <artifactId>jboss-jaxws</artifactId>
                <version>3.0.1-native-2.0.4.GA</version>
                <scope>compile</scope>
        </dependency>
        <dependency>
                <groupId>jboss.jbossws</groupId>
                <artifactId>jboss-saaj</artifactId>
                <version>3.0.1-native-2.0.4.GA</version>
                <scope>compile</scope>
        </dependency>
        <dependency>
                <groupId>jboss.jbossws</groupId>
                <artifactId>jbossws-client</artifactId>
                <version>3.0.1-native-2.0.4.GA</version>
                <scope>compile</scope>
        </dependency>
        <dependency>
                <groupId>jboss.jbossws</groupId>
                <artifactId>jbossws-spi</artifactId>
                <version>3.0.1-native-2.0.4.GA</version>
                <scope>compile</scope>
        </dependency>
        <dependency>
                <groupId>jboss.jbossws</groupId>
                <artifactId>jboss-xml-binding</artifactId>
                <version>3.0.1-native-2.0.4.GA</version>
                <scope>compile</scope>
        </dependency>
        <dependency>
                <groupId>jboss.jbossws</groupId>
                <artifactId>stax-api</artifactId>
                <version>3.0.1-native-2.0.4.GA</version>
                <scope>compile</scope>
        </dependency>
        <!-- Java Tools -->
        <dependency>
        <groupId>sun.jdk</groupId>
        <artifactId>tools</artifactId>
        <version>1.5.0</version>
        <scope>system</scope>
        <systemPath>${java.home}/../lib/tools.jar</systemPath>
    </dependency>
    <!-- Ant -->
    <dependency>
                <groupId>org.apache.ant</groupId>
                <artifactId>ant</artifactId>
                <version>1.7.0</version>
                <scope>compile</scope>
        </dependency>
  </dependencies>
</project>

My project that uses my maven plugin has this pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com</groupId>
  <artifactId>TestePluginMaven</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>TestePluginMaven</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>jboss</groupId>
        <artifactId>maven-jbossws-plugin</artifactId>
        <version>1.0.0</version>
        <configuration>
                <verbose>true</verbose>
                <keep>true</keep>
                <wsdl>https://xxx/crypto?wsdl</wsdl>
        </configuration>
      </plugin>
      <!-- Don't forget Java 5!! -->
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

When I execute my plugin I get:

+ Error stacktraces are turned on.
Maven version: 2.0.8
Java version: 1.5.0_06
OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"
[DEBUG] Building Maven user-level plugin registry from: 'C:\Documents and Settings\claudior\.m2\plugin-registry.xml'
[DEBUG] Building Maven global-level plugin registry from: 'C:\apache-maven-2.0.8\bin\..\conf\plugin-registry.xml'
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'jbossws'.
[DEBUG] Loading plugin prefixes from group: org.apache.maven.plugins
[DEBUG] Loading plugin prefixes from group: org.codehaus.mojo
[DEBUG] maven-compiler-plugin: resolved to version 2.0.2 from repository central
[DEBUG] Retrieving parent-POM: org.apache.maven.plugins:maven-plugins::8 for project: null:maven-compiler-plugin:maven-plugin:2.0.2 from the repository.
[DEBUG] Retrieving parent-POM: org.apache.maven:maven-parent::5 for project: org.apache.maven.plugins:maven-plugins:pom:8 from the repository.
[DEBUG] Retrieving parent-POM: org.apache:apache::3 for project: org.apache.maven:maven-parent:pom:5 from the repository.
[INFO] ------------------------------------------------------------------------
[INFO] Building TestePluginMaven
[INFO]    task-segment: [jbossws:wsconsume]
[INFO] ------------------------------------------------------------------------
[DEBUG] jboss:maven-jbossws-plugin:maven-plugin:1.0.0:runtime (selected for runtime)
[DEBUG]   jboss:mail:jar:4.2.2.GA:runtime (selected for runtime)
[DEBUG] Retrieving parent-POM: org.apache.ant:ant-parent::1.7.0 for project: org.apache.ant:ant:jar:1.7.0 from the repository.
[DEBUG]   org.apache.ant:ant:jar:1.7.0:runtime (selected for runtime)
[DEBUG]     org.apache.ant:ant-launcher:jar:1.7.0:runtime (selected for runtime)
[DEBUG]   jboss:getopt:jar:4.2.2.GA:runtime (selected for runtime)
[DEBUG]   jboss.jbossws:streambuffer:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
[DEBUG]   jboss.jbossws:jaxb-xjc:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
[DEBUG]   jboss.jbossws:jboss-xml-binding:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
[DEBUG]   jboss.jbossws:stax-ex:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
[DEBUG]   jboss:javassist:jar:4.2.2.GA:runtime (selected for runtime)
[DEBUG]   jboss.jbossws:jaxb-impl:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
[DEBUG]   jboss.jbossws:jaxws-tools:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
[DEBUG]   jboss:log4j:jar:4.2.2.GA:runtime (selected for runtime)
[DEBUG]   jboss.jbossws:jboss-saaj:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
[DEBUG] Retrieving parent-POM: org.codehaus.plexus:plexus::1.0.4 for project: null:plexus-utils:jar:1.1 from the repository.
[DEBUG]   org.codehaus.plexus:plexus-utils:jar:1.1:runtime (selected for runtime)
[DEBUG]   sun.jdk:tools:jar:1.5.0:system (selected for system)
[DEBUG]   jboss.jbossws:jboss-jaxrpc:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
[DEBUG]   jboss:jbossall-client:jar:4.2.2.GA:runtime (selected for runtime)
[DEBUG]   jboss.jbossws:jaxb-api:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
[DEBUG]   jboss.jbossws:jbossws-client:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
[DEBUG]   jboss.jbossws:jbossws-spi:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
[DEBUG]   jboss:activation:jar:4.2.2.GA:runtime (selected for runtime)
[DEBUG]   jboss.jbossws:jboss-jaxws:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
[DEBUG]   jboss.jbossws:wstx:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
[DEBUG] Retrieving parent-POM: org.apache.maven:maven::2.0 for project: null:maven-project:jar:2.0 from the repository.
[DEBUG] Adding managed dependencies for unknown:maven-project
[DEBUG]   org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
[DEBUG]   org.codehaus.plexus:plexus-utils:jar:1.0.4
[DEBUG]   org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-5
[DEBUG]   org.apache.maven.wagon:wagon-ssh:jar:1.0-alpha-5
[DEBUG]   org.apache.maven.wagon:wagon-file:jar:1.0-alpha-5
[DEBUG]   org.apache.maven.wagon:wagon-http-lightweight:jar:1.0-alpha-5
[DEBUG]   org.apache.maven:maven-project:jar:2.0:runtime (selected for runtime)
[DEBUG] Adding managed dependencies for unknown:maven-profile
[DEBUG]   org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
[DEBUG]   org.codehaus.plexus:plexus-utils:jar:1.0.4
[DEBUG]   org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-5
[DEBUG]   org.apache.maven.wagon:wagon-ssh:jar:1.0-alpha-5
[DEBUG]   org.apache.maven.wagon:wagon-file:jar:1.0-alpha-5
[DEBUG]   org.apache.maven.wagon:wagon-http-lightweight:jar:1.0-alpha-5
[DEBUG]     org.apache.maven:maven-profile:jar:2.0:runtime (selected for runtime)
[DEBUG] Adding managed dependencies for org.apache.maven:maven-model
[DEBUG]   org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
[DEBUG]   org.codehaus.plexus:plexus-utils:jar:1.0.4
[DEBUG]   org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-5
[DEBUG]   org.apache.maven.wagon:wagon-ssh:jar:1.0-alpha-5
[DEBUG]   org.apache.maven.wagon:wagon-file:jar:1.0-alpha-5
[DEBUG]   org.apache.maven.wagon:wagon-http-lightweight:jar:1.0-alpha-5
[DEBUG]       org.apache.maven:maven-model:jar:2.0:runtime (selected for runtime)
[DEBUG]         org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
[DEBUG]       org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
[DEBUG]       org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8:runtime (selected for runtime)
[DEBUG]         org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
[DEBUG]         junit:junit:jar:3.8.1:runtime (selected for runtime)
[DEBUG]         classworlds:classworlds:jar:1.1-alpha-2:runtime (selected for runtime)
[DEBUG]     org.apache.maven:maven-model:jar:2.0:runtime (selected for runtime)
[DEBUG]       org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
[DEBUG] Adding managed dependencies for org.apache.maven:maven-artifact-manager
[DEBUG]   org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
[DEBUG]   org.codehaus.plexus:plexus-utils:jar:1.0.4
[DEBUG]   org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-5
[DEBUG]   org.apache.maven.wagon:wagon-ssh:jar:1.0-alpha-5
[DEBUG]   org.apache.maven.wagon:wagon-file:jar:1.0-alpha-5
[DEBUG]   org.apache.maven.wagon:wagon-http-lightweight:jar:1.0-alpha-5
[DEBUG]     org.apache.maven:maven-artifact-manager:jar:2.0:runtime (selected for runtime)
[DEBUG] Adding managed dependencies for org.apache.maven:maven-repository-metadata
[DEBUG]   org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
[DEBUG]   org.codehaus.plexus:plexus-utils:jar:1.0.4
[DEBUG]   org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-5
[DEBUG]   org.apache.maven.wagon:wagon-ssh:jar:1.0-alpha-5
[DEBUG]   org.apache.maven.wagon:wagon-file:jar:1.0-alpha-5
[DEBUG]   org.apache.maven.wagon:wagon-http-lightweight:jar:1.0-alpha-5
[DEBUG]       org.apache.maven:maven-repository-metadata:jar:2.0:runtime (selected for runtime)
[DEBUG]         org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
[DEBUG]       org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
[DEBUG] Adding managed dependencies for org.apache.maven:maven-artifact
[DEBUG]   org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
[DEBUG]   org.codehaus.plexus:plexus-utils:jar:1.0.4
[DEBUG]   org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-5
[DEBUG]   org.apache.maven.wagon:wagon-ssh:jar:1.0-alpha-5
[DEBUG]   org.apache.maven.wagon:wagon-file:jar:1.0-alpha-5
[DEBUG]   org.apache.maven.wagon:wagon-http-lightweight:jar:1.0-alpha-5
[DEBUG]       org.apache.maven:maven-artifact:jar:2.0:runtime (selected for runtime)
[DEBUG]         org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
[DEBUG]       org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-5:runtime (selected for runtime)
[DEBUG]         org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
[DEBUG]     org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
[DEBUG]     org.apache.maven:maven-artifact:jar:2.0:runtime (selected for runtime)
[DEBUG]       org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
[DEBUG]     org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8:runtime (selected for runtime)
[DEBUG]       org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed - nearer found: 1.1)
[DEBUG]       junit:junit:jar:3.8.1:runtime (selected for runtime)
[DEBUG]       classworlds:classworlds:jar:1.1-alpha-2:runtime (selected for runtime)
[DEBUG] Adding managed dependencies for org.apache.maven:maven-plugin-api
[DEBUG]   org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
[DEBUG]   org.codehaus.plexus:plexus-utils:jar:1.0.4
[DEBUG]   org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-5
[DEBUG]   org.apache.maven.wagon:wagon-ssh:jar:1.0-alpha-5
[DEBUG]   org.apache.maven.wagon:wagon-file:jar:1.0-alpha-5
[DEBUG]   org.apache.maven.wagon:wagon-http-lightweight:jar:1.0-alpha-5
[DEBUG]   org.apache.maven:maven-plugin-api:jar:2.0:runtime (selected for runtime)
[DEBUG]   jboss.jbossws:stax-api:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
[DEBUG]   jboss.jbossws:jaxws-rt:jar:3.0.1-native-2.0.4.GA:runtime (selected for runtime)
[DEBUG] Configuring mojo 'jboss:maven-jbossws-plugin:1.0.0:wsconsume' -->
[DEBUG]   (f) destdir = output
[DEBUG]   (f) extension = false
[DEBUG]   (f) fork = true
[DEBUG]   (f) keep = true
[DEBUG]   (f) verbose = true
[DEBUG]   (f) wsdl = https://xxx/crypto?wsdl
[DEBUG] -- end configuration --
[INFO] [jbossws:wsconsume]
[INFO] Using...
[INFO] fork: true
[INFO] keep: true
[INFO] package: null
[INFO] wsdlLocation: null
[INFO] destdir: output
[INFO] sourcedestdir: output
[INFO] verbose: true
[INFO] wsdl: https://xxx/crypto?wsdl
[INFO] extension: false
[INFO] binding: null
Consuming wsdl: https://xxx/crypto?wsdl
parsing WSDL...


generating code...
com\bean\CryptoService.java
com\bean\MeioPagamento.java
com\bean\MeioPagamentoArray.java
com\bean\ObjectFactory.java
com\bean\WebServiceCrypto.java
com\bean\package-info.java
C:\eclipse\workspace\TestePluginMaven\output\com\bean\CryptoService.java:7: cannot find symbol
symbol  : class Service
location: package javax.xml.ws
import javax.xml.ws.Service;
                    ^
C:\eclipse\workspace\TestePluginMaven\output\com\bean\CryptoService.java:8: cannot find symbol
symbol  : class WebEndpoint
location: package javax.xml.ws
import javax.xml.ws.WebEndpoint;
                    ^
C:\eclipse\workspace\TestePluginMaven\output\com\bean\CryptoService.java:9: cannot find symbol
symbol  : class WebServiceClient
location: package javax.xml.ws
import javax.xml.ws.WebServiceClient;
                    ^
C:\eclipse\workspace\TestePluginMaven\output\com\bean\CryptoService.java:20: cannot find symbol
symbol: class Service
    extends Service
            ^
C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:4: package javax.jws does not exist
import javax.jws.WebMethod;
                 ^
C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:5: package javax.jws does not exist
import javax.jws.WebParam;
                 ^
C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:6: package javax.jws does not exist
import javax.jws.WebResult;
                 ^
C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:7: package javax.jws does not exist
import javax.jws.WebService;
                 ^
C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:8: package javax.jws.soap does not exist
import javax.jws.soap.SOAPBinding;
                      ^
C:\eclipse\workspace\TestePluginMaven\output\com\bean\CryptoService.java:18: cannot find symbol
symbol: class WebServiceClient
@WebServiceClient(name = "CryptoService", targetNamespace = "http://bean.com", wsdlLocation = "https://xxx/crypto?wsdl")
 ^
C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:17: cannot find symbol
symbol: class WebService
@WebService(name = "WebServiceCrypto", targetNamespace = "http://bean.com")
 ^
C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:18: cannot find symbol
symbol: class SOAPBinding
@SOAPBinding(style = SOAPBinding.Style.RPC)
 ^
C:\eclipse\workspace\TestePluginMaven\output\com\bean\CryptoService.java:48: cannot find symbol
symbol  : class WebEndpoint
location: class com.bean.CryptoService
    @WebEndpoint(name = "WebServiceCryptoPort")
     ^
C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:31: cannot find symbol
symbol  : class WebParam
location: interface com.bean.WebServiceCrypto
        @WebParam(name = "MeioDePagamento", partName = "MeioDePagamento")
         ^
C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:28: cannot find symbol
symbol  : class WebMethod
location: interface com.bean.WebServiceCrypto
    @WebMethod
     ^
C:\eclipse\workspace\TestePluginMaven\output\com\bean\WebServiceCrypto.java:29: cannot find symbol
symbol  : class WebResult
location: interface com.bean.WebServiceCrypto
    @WebResult(partName = "return")
     ^
C:\eclipse\workspace\TestePluginMaven\output\com\bean\CryptoService.java:50: cannot find symbol
symbol  : variable super
location: class com.bean.CryptoService
        return (WebServiceCrypto)super.getPort(new QName("http://bean.com", "WebServiceCryptoPort"), WebServiceCrypto.class);
                                 ^
17 errors
compilation failed, errors should have been reported
Failed to invoke WsImport
java.lang.IllegalStateException: WsImport invocation failed. Try the verbose switch for more information
        at org.jboss.ws.tools.jaxws.impl.SunRIConsumerImpl.consume(SunRIConsumerImpl.java:220)
        at org.jboss.wsf.spi.tools.WSContractConsumer.consume(WSContractConsumer.java:196)
        at org.jboss.wsf.spi.tools.ant.WSConsumeTask.executeNonForked(WSConsumeTask.java:214)
        at org.jboss.wsf.spi.tools.ant.WSConsumeTask.execute(WSConsumeTask.java:234)
        at jboss.WSConsumeMojo.execute(WSConsumeMojo.java:86)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:447)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:539)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:493)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:463)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:311)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:278)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:333)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:126)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:282)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6 seconds
[INFO] Finished at: Mon May 26 10:59:31 BRT 2008
[INFO] Final Memory: 4M/10M
[INFO] ------------------------------------------------------------------------

The package javax.xml.ws is located in jboss-jaxws-3.0.1-native-2.0.4.GA.jar declared in maven plugin pom.xml!
Please, help me!
Thanks



-----Mensagem original-----
De: Tim Kettler [mailto:tim.kettler@udo.edu]
Enviada em: quinta-feira, 22 de maio de 2008 05:29
Para: Maven Users List
Assunto: Re: RES: Problem with classloader in maven plugin

Hi,

Claudio Ranieri schrieb:
> Hi,
>
> Why the maven plugins doesn´t load all libraries declared in pom.xml?

You have to distinguish between the plugin project and the project you
are using the plugin with. All libraries (with a proper scope) declared
in the pom of the plugin project are available (on the classpath) to the
plugin during execution. This includes libraries you are specifying in
the <plugin><dependencies> section of the project using your plugin.

The libraries declared in the pom of the project you are using your
plugin in however, are not available. And for a good reason, just think
abaout the bad things that could happen when both, the plugin and your
project use the same library for example, but a different version of it.

The conclusion in one sentence: You don't ever want the dependencies
(classpathes) of your project and the dependencies of a plugin used
during the build of your project mixed.

> I tried to use the initClassLoader because this code works in jaxws-maven-plugin.
> In the code of jaxws-maven-plugin there is:
>
> " Need to build a URLClassloader since Maven removed it form the chain "
>
> Why?

I don't know the jaxws-maven-plugin, so I can't really tell anything
about its design and implementation. You will have to ask the developers
of the plugin about such specific questions.

All advice I can give you is that you should read and learn about the
different kinds of classloaders (and classloaders in generel) in Java
and how to properly use them.

So far, all plugins I've seen the source code of construct a new
classloader with the classes the external tool needs and then use the
loadClass() method of that classloader to get an instance of the class
they need. Examples of this can be seen in the compiler-plugin or
fit-maven-plugin (as someone on the dev list already wrote).

> Thanks

-Tim

> -----Mensagem original-----
> De: Tim Kettler [mailto:tim.kettler@udo.edu]
> Enviada em: quarta-feira, 21 de maio de 2008 10:57
> Para: Maven Users List
> Assunto: Re: Problem with classloader in maven plugin
>
> Hi,
>
> you've missunderstood the concept of a context classloader.
>
> A documentation bug [1] is open since a long time. Setting the context
> classloader doesn't mean that all classes created from that point on are
> created through this classloader. See here [2] and [3] for more information.
>
> [1] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4868493
> [2] http://www.javaworld.com/javaqa/2003-06/01-qa-0606-load.html
> [3] http://www.javageeks.com/Papers/ClassForName/index.html
>
> -Tim
>
> Claudio Ranieri schrieb:
>> Hi
>>
>> I am trying to create a maven plugin to jboss wsconsume, but I have a problem with classloader in plugin.
>> My plugin is based in an ant task (WSConsumeTask).
>> I am using maven 2.0.8 on Windows machine.
>> When I created a simple Java project with libraries necessary, my code works.
>> How shown below:
>>
>> public static void main(String[] args) {
>>   WSConsumeTask t = new WSConsumeTask();
>>   t.setWsdl("https://xxx/crypto?wsdl");
>>   t.setVerbose(true);
>>   t.setKeep(true);
>>   t.execute();
>> }
>>
>> But when I am using into maven plugin, I got problem with classloader.
>> I got this exception:
>>
>> C:\eclipse\workspace\TestePluginMaven\output\com\buscape\bean\CryptoService.java:7: cannot find symbol
>> symbol  : class Service
>> location: package javax.xml.ws
>> import javax.xml.ws.Service;
>>                     ^
>> C:\eclipse\workspace\TestePluginMaven\output\com\buscape\bean\CryptoService.java:8: cannot find symbol
>> symbol  : class WebEndpoint
>> location: package javax.xml.ws
>> import javax.xml.ws.WebEndpoint;
>>                     ^
>> C:\eclipse\workspace\TestePluginMaven\output\com\buscape\bean\CryptoService.java:9: cannot find symbol
>> symbol  : class WebServiceClient
>> location: package javax.xml.ws
>> import javax.xml.ws.WebServiceClient;
>>
>> The plugin classloader doesn´t load the jaxws libraries. But this libraries was added in pom.xml of plugin.
>> I tried to add dependencies tag in my plugin config, but didn´t works. How shown below:
>>
>> <plugin>
>>   <groupId>jboss</groupId>
>>   <artifactId>maven-jbossws-plugin</artifactId>
>>   <version>1.0.0</version>
>>   <configuration>
>>     <verbose>true</verbose>
>>     <keep>true</keep>
>>     <wsdl>https://xxx/crypto?wsdl</wsdl>
>>   </configuration>
>>   <dependencies>
>>     <dependency>
>>       <groupId>jboss.jbossws</groupId>
>>       <artifactId>jaxws-tools</artifactId>
>>       <version>3.0.1-native-2.0.4.GA</version>
>>       <scope>compile</scope>
>>     </dependency>
>>     <dependency>
>>       <groupId>jboss.jbossws</groupId>
>>       <artifactId>jboss-jaxws</artifactId>
>>       <version>3.0.1-native-2.0.4.GA</version>
>>       <scope>compile</scope>
>>     </dependency>
>>   </dependencies>
>> </plugin>
>>
>> I tried too to use an initClassLoader based in jaxws-maven-plugin source, how shown below:
>>
>>    private String initClassLoader(ClassLoader parent) throws MojoExecutionException {
>>                     try {
>>                                 List classpathFiles = project.getCompileClasspathElements();
>>                         URL[] urls = new URL[classpathFiles.size() + 4];
>>                         StringBuffer classPath = new StringBuffer();
>>                         for (int i = 0; i < classpathFiles.size(); ++i) {
>>                             getLog().debug((String)classpathFiles.get(i));
>>                             urls[i] = new File((String)classpathFiles.get(i)).toURL();
>>                             classPath.append((String)classpathFiles.get(i));
>>                             classPath.append(File.pathSeparatorChar);
>>                         }
>>                         urls[classpathFiles.size()] = new File(project.getBuild().getOutputDirectory()).toURL();
>>
>>                         urls[classpathFiles.size() + 1] = getArtifact("jboss.jbossws:jboss-jaxws");
>>
>>                         urls[classpathFiles.size() + 2] = getArtifact("jboss.jbossws:jaxws-tools");
>>
>>                         File toolsJar = new File(System.getProperty("java.home"),"../lib/tools.jar");
>>                         if (!toolsJar.exists()) {
>>                                 toolsJar = new File(System.getProperty("java.home"),"lib/tools.jar");
>>                         }
>>                         urls[classpathFiles.size() + 3] = toolsJar.toURL();
>>
>>                         System.out.println("urls: "+Arrays.toString(urls));
>>
>>                         URLClassLoader cl = new URLClassLoader(urls,parent);
>>                         // Set the new classloader
>>                         Thread.currentThread().setContextClassLoader(cl);
>>                         System.setProperty("java.class.path",classPath.toString());
>>                         String sysCp = System.getProperty("java.class.path");
>>                         return sysCp;
>>                     }
>>                     catch (MalformedURLException e) {
>>                         throw new MojoExecutionException(e.getMessage(),e);
>>                     }
>>                     catch (DependencyResolutionRequiredException e) {
>>                         throw new MojoExecutionException(e.getMessage(),e);
>>                     }
>>
>>     }
>>
>>     public void execute() throws MojoExecutionException {
>>                   // Need to build a URLClassloader since Maven removed it form the chain
>>         ClassLoader parent = this.getClass().getClassLoader();
>>         String originalSystemClasspath = this.initClassLoader( parent );
>>
>>         try {
>>
>>                         // Execute WSConsumeTask
>>                         WSConsumeTask t = new WSConsumeTask();
>>                                   t.setWsdl(wsdl);
>>                                   t.setVerbose(verbose);
>>                                   t.setKeep(keep);
>>                                   t.execute();
>>         }
>>         finally {
>>                 // Set back the old classloader
>>           Thread.currentThread().setContextClassLoader(parent);
>>           System.setProperty("java.class.path",originalSystemClasspath);
>>         }
>>     }
>>
>> But, it doesn´t works.
>> Please, can someone help me?
>> Thanks
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>


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


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


Re: RES: Problem with classloader in maven plugin

Posted by Tim Kettler <ti...@udo.edu>.
Hi,

Claudio Ranieri schrieb:
> Hi,
> 
> Why the maven plugins doesn´t load all libraries declared in pom.xml?

You have to distinguish between the plugin project and the project you 
are using the plugin with. All libraries (with a proper scope) declared 
in the pom of the plugin project are available (on the classpath) to the 
plugin during execution. This includes libraries you are specifying in 
the <plugin><dependencies> section of the project using your plugin.

The libraries declared in the pom of the project you are using your 
plugin in however, are not available. And for a good reason, just think 
abaout the bad things that could happen when both, the plugin and your 
project use the same library for example, but a different version of it.

The conclusion in one sentence: You don't ever want the dependencies 
(classpathes) of your project and the dependencies of a plugin used 
during the build of your project mixed.

> I tried to use the initClassLoader because this code works in jaxws-maven-plugin.
> In the code of jaxws-maven-plugin there is:
> 
> " Need to build a URLClassloader since Maven removed it form the chain "
> 
> Why?

I don't know the jaxws-maven-plugin, so I can't really tell anything 
about its design and implementation. You will have to ask the developers 
of the plugin about such specific questions.

All advice I can give you is that you should read and learn about the 
different kinds of classloaders (and classloaders in generel) in Java 
and how to properly use them.

So far, all plugins I've seen the source code of construct a new 
classloader with the classes the external tool needs and then use the 
loadClass() method of that classloader to get an instance of the class 
they need. Examples of this can be seen in the compiler-plugin or 
fit-maven-plugin (as someone on the dev list already wrote).

> Thanks

-Tim

> -----Mensagem original-----
> De: Tim Kettler [mailto:tim.kettler@udo.edu]
> Enviada em: quarta-feira, 21 de maio de 2008 10:57
> Para: Maven Users List
> Assunto: Re: Problem with classloader in maven plugin
> 
> Hi,
> 
> you've missunderstood the concept of a context classloader.
> 
> A documentation bug [1] is open since a long time. Setting the context
> classloader doesn't mean that all classes created from that point on are
> created through this classloader. See here [2] and [3] for more information.
> 
> [1] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4868493
> [2] http://www.javaworld.com/javaqa/2003-06/01-qa-0606-load.html
> [3] http://www.javageeks.com/Papers/ClassForName/index.html
> 
> -Tim
> 
> Claudio Ranieri schrieb:
>> Hi
>>
>> I am trying to create a maven plugin to jboss wsconsume, but I have a problem with classloader in plugin.
>> My plugin is based in an ant task (WSConsumeTask).
>> I am using maven 2.0.8 on Windows machine.
>> When I created a simple Java project with libraries necessary, my code works.
>> How shown below:
>>
>> public static void main(String[] args) {
>>   WSConsumeTask t = new WSConsumeTask();
>>   t.setWsdl("https://xxx/crypto?wsdl");
>>   t.setVerbose(true);
>>   t.setKeep(true);
>>   t.execute();
>> }
>>
>> But when I am using into maven plugin, I got problem with classloader.
>> I got this exception:
>>
>> C:\eclipse\workspace\TestePluginMaven\output\com\buscape\bean\CryptoService.java:7: cannot find symbol
>> symbol  : class Service
>> location: package javax.xml.ws
>> import javax.xml.ws.Service;
>>                     ^
>> C:\eclipse\workspace\TestePluginMaven\output\com\buscape\bean\CryptoService.java:8: cannot find symbol
>> symbol  : class WebEndpoint
>> location: package javax.xml.ws
>> import javax.xml.ws.WebEndpoint;
>>                     ^
>> C:\eclipse\workspace\TestePluginMaven\output\com\buscape\bean\CryptoService.java:9: cannot find symbol
>> symbol  : class WebServiceClient
>> location: package javax.xml.ws
>> import javax.xml.ws.WebServiceClient;
>>
>> The plugin classloader doesn´t load the jaxws libraries. But this libraries was added in pom.xml of plugin.
>> I tried to add dependencies tag in my plugin config, but didn´t works. How shown below:
>>
>> <plugin>
>>   <groupId>jboss</groupId>
>>   <artifactId>maven-jbossws-plugin</artifactId>
>>   <version>1.0.0</version>
>>   <configuration>
>>     <verbose>true</verbose>
>>     <keep>true</keep>
>>     <wsdl>https://xxx/crypto?wsdl</wsdl>
>>   </configuration>
>>   <dependencies>
>>     <dependency>
>>       <groupId>jboss.jbossws</groupId>
>>       <artifactId>jaxws-tools</artifactId>
>>       <version>3.0.1-native-2.0.4.GA</version>
>>       <scope>compile</scope>
>>     </dependency>
>>     <dependency>
>>       <groupId>jboss.jbossws</groupId>
>>       <artifactId>jboss-jaxws</artifactId>
>>       <version>3.0.1-native-2.0.4.GA</version>
>>       <scope>compile</scope>
>>     </dependency>
>>   </dependencies>
>> </plugin>
>>
>> I tried too to use an initClassLoader based in jaxws-maven-plugin source, how shown below:
>>
>>    private String initClassLoader(ClassLoader parent) throws MojoExecutionException {
>>                     try {
>>                                 List classpathFiles = project.getCompileClasspathElements();
>>                         URL[] urls = new URL[classpathFiles.size() + 4];
>>                         StringBuffer classPath = new StringBuffer();
>>                         for (int i = 0; i < classpathFiles.size(); ++i) {
>>                             getLog().debug((String)classpathFiles.get(i));
>>                             urls[i] = new File((String)classpathFiles.get(i)).toURL();
>>                             classPath.append((String)classpathFiles.get(i));
>>                             classPath.append(File.pathSeparatorChar);
>>                         }
>>                         urls[classpathFiles.size()] = new File(project.getBuild().getOutputDirectory()).toURL();
>>
>>                         urls[classpathFiles.size() + 1] = getArtifact("jboss.jbossws:jboss-jaxws");
>>
>>                         urls[classpathFiles.size() + 2] = getArtifact("jboss.jbossws:jaxws-tools");
>>
>>                         File toolsJar = new File(System.getProperty("java.home"),"../lib/tools.jar");
>>                         if (!toolsJar.exists()) {
>>                                 toolsJar = new File(System.getProperty("java.home"),"lib/tools.jar");
>>                         }
>>                         urls[classpathFiles.size() + 3] = toolsJar.toURL();
>>
>>                         System.out.println("urls: "+Arrays.toString(urls));
>>
>>                         URLClassLoader cl = new URLClassLoader(urls,parent);
>>                         // Set the new classloader
>>                         Thread.currentThread().setContextClassLoader(cl);
>>                         System.setProperty("java.class.path",classPath.toString());
>>                         String sysCp = System.getProperty("java.class.path");
>>                         return sysCp;
>>                     }
>>                     catch (MalformedURLException e) {
>>                         throw new MojoExecutionException(e.getMessage(),e);
>>                     }
>>                     catch (DependencyResolutionRequiredException e) {
>>                         throw new MojoExecutionException(e.getMessage(),e);
>>                     }
>>
>>     }
>>
>>     public void execute() throws MojoExecutionException {
>>                   // Need to build a URLClassloader since Maven removed it form the chain
>>         ClassLoader parent = this.getClass().getClassLoader();
>>         String originalSystemClasspath = this.initClassLoader( parent );
>>
>>         try {
>>
>>                         // Execute WSConsumeTask
>>                         WSConsumeTask t = new WSConsumeTask();
>>                                   t.setWsdl(wsdl);
>>                                   t.setVerbose(verbose);
>>                                   t.setKeep(keep);
>>                                   t.execute();
>>         }
>>         finally {
>>                 // Set back the old classloader
>>           Thread.currentThread().setContextClassLoader(parent);
>>           System.setProperty("java.class.path",originalSystemClasspath);
>>         }
>>     }
>>
>> But, it doesn´t works.
>> Please, can someone help me?
>> Thanks
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 


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


RES: Problem with classloader in maven plugin

Posted by Claudio Ranieri <cl...@buscape-inc.com>.
Hi,

Why the maven plugins doesn´t load all libraries declared in pom.xml?
I tried to use the initClassLoader because this code works in jaxws-maven-plugin.
In the code of jaxws-maven-plugin there is:

" Need to build a URLClassloader since Maven removed it form the chain "

Why?

Thanks


-----Mensagem original-----
De: Tim Kettler [mailto:tim.kettler@udo.edu]
Enviada em: quarta-feira, 21 de maio de 2008 10:57
Para: Maven Users List
Assunto: Re: Problem with classloader in maven plugin

Hi,

you've missunderstood the concept of a context classloader.

A documentation bug [1] is open since a long time. Setting the context
classloader doesn't mean that all classes created from that point on are
created through this classloader. See here [2] and [3] for more information.

[1] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4868493
[2] http://www.javaworld.com/javaqa/2003-06/01-qa-0606-load.html
[3] http://www.javageeks.com/Papers/ClassForName/index.html

-Tim

Claudio Ranieri schrieb:
> Hi
>
> I am trying to create a maven plugin to jboss wsconsume, but I have a problem with classloader in plugin.
> My plugin is based in an ant task (WSConsumeTask).
> I am using maven 2.0.8 on Windows machine.
> When I created a simple Java project with libraries necessary, my code works.
> How shown below:
>
> public static void main(String[] args) {
>   WSConsumeTask t = new WSConsumeTask();
>   t.setWsdl("https://xxx/crypto?wsdl");
>   t.setVerbose(true);
>   t.setKeep(true);
>   t.execute();
> }
>
> But when I am using into maven plugin, I got problem with classloader.
> I got this exception:
>
> C:\eclipse\workspace\TestePluginMaven\output\com\buscape\bean\CryptoService.java:7: cannot find symbol
> symbol  : class Service
> location: package javax.xml.ws
> import javax.xml.ws.Service;
>                     ^
> C:\eclipse\workspace\TestePluginMaven\output\com\buscape\bean\CryptoService.java:8: cannot find symbol
> symbol  : class WebEndpoint
> location: package javax.xml.ws
> import javax.xml.ws.WebEndpoint;
>                     ^
> C:\eclipse\workspace\TestePluginMaven\output\com\buscape\bean\CryptoService.java:9: cannot find symbol
> symbol  : class WebServiceClient
> location: package javax.xml.ws
> import javax.xml.ws.WebServiceClient;
>
> The plugin classloader doesn´t load the jaxws libraries. But this libraries was added in pom.xml of plugin.
> I tried to add dependencies tag in my plugin config, but didn´t works. How shown below:
>
> <plugin>
>   <groupId>jboss</groupId>
>   <artifactId>maven-jbossws-plugin</artifactId>
>   <version>1.0.0</version>
>   <configuration>
>     <verbose>true</verbose>
>     <keep>true</keep>
>     <wsdl>https://xxx/crypto?wsdl</wsdl>
>   </configuration>
>   <dependencies>
>     <dependency>
>       <groupId>jboss.jbossws</groupId>
>       <artifactId>jaxws-tools</artifactId>
>       <version>3.0.1-native-2.0.4.GA</version>
>       <scope>compile</scope>
>     </dependency>
>     <dependency>
>       <groupId>jboss.jbossws</groupId>
>       <artifactId>jboss-jaxws</artifactId>
>       <version>3.0.1-native-2.0.4.GA</version>
>       <scope>compile</scope>
>     </dependency>
>   </dependencies>
> </plugin>
>
> I tried too to use an initClassLoader based in jaxws-maven-plugin source, how shown below:
>
>    private String initClassLoader(ClassLoader parent) throws MojoExecutionException {
>                     try {
>                                 List classpathFiles = project.getCompileClasspathElements();
>                         URL[] urls = new URL[classpathFiles.size() + 4];
>                         StringBuffer classPath = new StringBuffer();
>                         for (int i = 0; i < classpathFiles.size(); ++i) {
>                             getLog().debug((String)classpathFiles.get(i));
>                             urls[i] = new File((String)classpathFiles.get(i)).toURL();
>                             classPath.append((String)classpathFiles.get(i));
>                             classPath.append(File.pathSeparatorChar);
>                         }
>                         urls[classpathFiles.size()] = new File(project.getBuild().getOutputDirectory()).toURL();
>
>                         urls[classpathFiles.size() + 1] = getArtifact("jboss.jbossws:jboss-jaxws");
>
>                         urls[classpathFiles.size() + 2] = getArtifact("jboss.jbossws:jaxws-tools");
>
>                         File toolsJar = new File(System.getProperty("java.home"),"../lib/tools.jar");
>                         if (!toolsJar.exists()) {
>                                 toolsJar = new File(System.getProperty("java.home"),"lib/tools.jar");
>                         }
>                         urls[classpathFiles.size() + 3] = toolsJar.toURL();
>
>                         System.out.println("urls: "+Arrays.toString(urls));
>
>                         URLClassLoader cl = new URLClassLoader(urls,parent);
>                         // Set the new classloader
>                         Thread.currentThread().setContextClassLoader(cl);
>                         System.setProperty("java.class.path",classPath.toString());
>                         String sysCp = System.getProperty("java.class.path");
>                         return sysCp;
>                     }
>                     catch (MalformedURLException e) {
>                         throw new MojoExecutionException(e.getMessage(),e);
>                     }
>                     catch (DependencyResolutionRequiredException e) {
>                         throw new MojoExecutionException(e.getMessage(),e);
>                     }
>
>     }
>
>     public void execute() throws MojoExecutionException {
>                   // Need to build a URLClassloader since Maven removed it form the chain
>         ClassLoader parent = this.getClass().getClassLoader();
>         String originalSystemClasspath = this.initClassLoader( parent );
>
>         try {
>
>                         // Execute WSConsumeTask
>                         WSConsumeTask t = new WSConsumeTask();
>                                   t.setWsdl(wsdl);
>                                   t.setVerbose(verbose);
>                                   t.setKeep(keep);
>                                   t.execute();
>         }
>         finally {
>                 // Set back the old classloader
>           Thread.currentThread().setContextClassLoader(parent);
>           System.setProperty("java.class.path",originalSystemClasspath);
>         }
>     }
>
> But, it doesn´t works.
> Please, can someone help me?
> Thanks
>


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


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


Re: Problem with classloader in maven plugin

Posted by Tim Kettler <ti...@udo.edu>.
Hi,

you've missunderstood the concept of a context classloader.

A documentation bug [1] is open since a long time. Setting the context 
classloader doesn't mean that all classes created from that point on are 
created through this classloader. See here [2] and [3] for more information.

[1] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4868493
[2] http://www.javaworld.com/javaqa/2003-06/01-qa-0606-load.html
[3] http://www.javageeks.com/Papers/ClassForName/index.html

-Tim

Claudio Ranieri schrieb:
> Hi
> 
> I am trying to create a maven plugin to jboss wsconsume, but I have a problem with classloader in plugin.
> My plugin is based in an ant task (WSConsumeTask).
> I am using maven 2.0.8 on Windows machine.
> When I created a simple Java project with libraries necessary, my code works.
> How shown below:
> 
> public static void main(String[] args) {
>   WSConsumeTask t = new WSConsumeTask();
>   t.setWsdl("https://xxx/crypto?wsdl");
>   t.setVerbose(true);
>   t.setKeep(true);
>   t.execute();
> }
> 
> But when I am using into maven plugin, I got problem with classloader.
> I got this exception:
> 
> C:\eclipse\workspace\TestePluginMaven\output\com\buscape\bean\CryptoService.java:7: cannot find symbol
> symbol  : class Service
> location: package javax.xml.ws
> import javax.xml.ws.Service;
>                     ^
> C:\eclipse\workspace\TestePluginMaven\output\com\buscape\bean\CryptoService.java:8: cannot find symbol
> symbol  : class WebEndpoint
> location: package javax.xml.ws
> import javax.xml.ws.WebEndpoint;
>                     ^
> C:\eclipse\workspace\TestePluginMaven\output\com\buscape\bean\CryptoService.java:9: cannot find symbol
> symbol  : class WebServiceClient
> location: package javax.xml.ws
> import javax.xml.ws.WebServiceClient;
> 
> The plugin classloader doesn´t load the jaxws libraries. But this libraries was added in pom.xml of plugin.
> I tried to add dependencies tag in my plugin config, but didn´t works. How shown below:
> 
> <plugin>
>   <groupId>jboss</groupId>
>   <artifactId>maven-jbossws-plugin</artifactId>
>   <version>1.0.0</version>
>   <configuration>
>     <verbose>true</verbose>
>     <keep>true</keep>
>     <wsdl>https://xxx/crypto?wsdl</wsdl>
>   </configuration>
>   <dependencies>
>     <dependency>
>       <groupId>jboss.jbossws</groupId>
>       <artifactId>jaxws-tools</artifactId>
>       <version>3.0.1-native-2.0.4.GA</version>
>       <scope>compile</scope>
>     </dependency>
>     <dependency>
>       <groupId>jboss.jbossws</groupId>
>       <artifactId>jboss-jaxws</artifactId>
>       <version>3.0.1-native-2.0.4.GA</version>
>       <scope>compile</scope>
>     </dependency>
>   </dependencies>
> </plugin>
> 
> I tried too to use an initClassLoader based in jaxws-maven-plugin source, how shown below:
> 
>    private String initClassLoader(ClassLoader parent) throws MojoExecutionException {
>                     try {
>                                 List classpathFiles = project.getCompileClasspathElements();
>                         URL[] urls = new URL[classpathFiles.size() + 4];
>                         StringBuffer classPath = new StringBuffer();
>                         for (int i = 0; i < classpathFiles.size(); ++i) {
>                             getLog().debug((String)classpathFiles.get(i));
>                             urls[i] = new File((String)classpathFiles.get(i)).toURL();
>                             classPath.append((String)classpathFiles.get(i));
>                             classPath.append(File.pathSeparatorChar);
>                         }
>                         urls[classpathFiles.size()] = new File(project.getBuild().getOutputDirectory()).toURL();
> 
>                         urls[classpathFiles.size() + 1] = getArtifact("jboss.jbossws:jboss-jaxws");
> 
>                         urls[classpathFiles.size() + 2] = getArtifact("jboss.jbossws:jaxws-tools");
> 
>                         File toolsJar = new File(System.getProperty("java.home"),"../lib/tools.jar");
>                         if (!toolsJar.exists()) {
>                                 toolsJar = new File(System.getProperty("java.home"),"lib/tools.jar");
>                         }
>                         urls[classpathFiles.size() + 3] = toolsJar.toURL();
> 
>                         System.out.println("urls: "+Arrays.toString(urls));
> 
>                         URLClassLoader cl = new URLClassLoader(urls,parent);
>                         // Set the new classloader
>                         Thread.currentThread().setContextClassLoader(cl);
>                         System.setProperty("java.class.path",classPath.toString());
>                         String sysCp = System.getProperty("java.class.path");
>                         return sysCp;
>                     }
>                     catch (MalformedURLException e) {
>                         throw new MojoExecutionException(e.getMessage(),e);
>                     }
>                     catch (DependencyResolutionRequiredException e) {
>                         throw new MojoExecutionException(e.getMessage(),e);
>                     }
> 
>     }
> 
>     public void execute() throws MojoExecutionException {
>                   // Need to build a URLClassloader since Maven removed it form the chain
>         ClassLoader parent = this.getClass().getClassLoader();
>         String originalSystemClasspath = this.initClassLoader( parent );
> 
>         try {
> 
>                         // Execute WSConsumeTask
>                         WSConsumeTask t = new WSConsumeTask();
>                                   t.setWsdl(wsdl);
>                                   t.setVerbose(verbose);
>                                   t.setKeep(keep);
>                                   t.execute();
>         }
>         finally {
>                 // Set back the old classloader
>           Thread.currentThread().setContextClassLoader(parent);
>           System.setProperty("java.class.path",originalSystemClasspath);
>         }
>     }
> 
> But, it doesn´t works.
> Please, can someone help me?
> Thanks
> 


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


RES: Problem with classloader in maven plugin

Posted by Claudio Ranieri <cl...@buscape-inc.com>.
Anyone?
I want help the open source community, but I have this problem with classloader.

-----Mensagem original-----
De: Claudio Ranieri [mailto:claudior@buscape-inc.com]
Enviada em: terça-feira, 20 de maio de 2008 07:47
Para: users@maven.apache.org
Assunto: Problem with classloader in maven plugin

Hi

I am trying to create a maven plugin to jboss wsconsume, but I have a problem with classloader in plugin.
My plugin is based in an ant task (WSConsumeTask).
I am using maven 2.0.8 on Windows machine.
When I created a simple Java project with libraries necessary, my code works.
How shown below:

public static void main(String[] args) {
  WSConsumeTask t = new WSConsumeTask();
  t.setWsdl("https://xxx/crypto?wsdl");
  t.setVerbose(true);
  t.setKeep(true);
  t.execute();
}

But when I am using into maven plugin, I got problem with classloader.
I got this exception:

C:\eclipse\workspace\TestePluginMaven\output\com\buscape\bean\CryptoService.java:7: cannot find symbol
symbol  : class Service
location: package javax.xml.ws
import javax.xml.ws.Service;
                    ^
C:\eclipse\workspace\TestePluginMaven\output\com\buscape\bean\CryptoService.java:8: cannot find symbol
symbol  : class WebEndpoint
location: package javax.xml.ws
import javax.xml.ws.WebEndpoint;
                    ^
C:\eclipse\workspace\TestePluginMaven\output\com\buscape\bean\CryptoService.java:9: cannot find symbol
symbol  : class WebServiceClient
location: package javax.xml.ws
import javax.xml.ws.WebServiceClient;

The plugin classloader doesn´t load the jaxws libraries. But this libraries was added in pom.xml of plugin.
I tried to add dependencies tag in my plugin config, but didn´t works. How shown below:

<plugin>
  <groupId>jboss</groupId>
  <artifactId>maven-jbossws-plugin</artifactId>
  <version>1.0.0</version>
  <configuration>
    <verbose>true</verbose>
    <keep>true</keep>
    <wsdl>https://xxx/crypto?wsdl</wsdl>
  </configuration>
  <dependencies>
    <dependency>
      <groupId>jboss.jbossws</groupId>
      <artifactId>jaxws-tools</artifactId>
      <version>3.0.1-native-2.0.4.GA</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>jboss.jbossws</groupId>
      <artifactId>jboss-jaxws</artifactId>
      <version>3.0.1-native-2.0.4.GA</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
</plugin>

I tried too to use an initClassLoader based in jaxws-maven-plugin source, how shown below:

   private String initClassLoader(ClassLoader parent) throws MojoExecutionException {
                    try {
                                List classpathFiles = project.getCompileClasspathElements();
                        URL[] urls = new URL[classpathFiles.size() + 4];
                        StringBuffer classPath = new StringBuffer();
                        for (int i = 0; i < classpathFiles.size(); ++i) {
                            getLog().debug((String)classpathFiles.get(i));
                            urls[i] = new File((String)classpathFiles.get(i)).toURL();
                            classPath.append((String)classpathFiles.get(i));
                            classPath.append(File.pathSeparatorChar);
                        }
                        urls[classpathFiles.size()] = new File(project.getBuild().getOutputDirectory()).toURL();

                        urls[classpathFiles.size() + 1] = getArtifact("jboss.jbossws:jboss-jaxws");

                        urls[classpathFiles.size() + 2] = getArtifact("jboss.jbossws:jaxws-tools");

                        File toolsJar = new File(System.getProperty("java.home"),"../lib/tools.jar");
                        if (!toolsJar.exists()) {
                                toolsJar = new File(System.getProperty("java.home"),"lib/tools.jar");
                        }
                        urls[classpathFiles.size() + 3] = toolsJar.toURL();

                        System.out.println("urls: "+Arrays.toString(urls));

                        URLClassLoader cl = new URLClassLoader(urls,parent);
                        // Set the new classloader
                        Thread.currentThread().setContextClassLoader(cl);
                        System.setProperty("java.class.path",classPath.toString());
                        String sysCp = System.getProperty("java.class.path");
                        return sysCp;
                    }
                    catch (MalformedURLException e) {
                        throw new MojoExecutionException(e.getMessage(),e);
                    }
                    catch (DependencyResolutionRequiredException e) {
                        throw new MojoExecutionException(e.getMessage(),e);
                    }

    }

    public void execute() throws MojoExecutionException {
                  // Need to build a URLClassloader since Maven removed it form the chain
        ClassLoader parent = this.getClass().getClassLoader();
        String originalSystemClasspath = this.initClassLoader( parent );

        try {

                        // Execute WSConsumeTask
                        WSConsumeTask t = new WSConsumeTask();
                                  t.setWsdl(wsdl);
                                  t.setVerbose(verbose);
                                  t.setKeep(keep);
                                  t.execute();
        }
        finally {
                // Set back the old classloader
          Thread.currentThread().setContextClassLoader(parent);
          System.setProperty("java.class.path",originalSystemClasspath);
        }
    }

But, it doesn´t works.
Please, can someone help me?
Thanks

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