Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3979322
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:09:21+00:00 2026-05-20T05:09:21+00:00

I’m trying to build a maven project, an OSGi bundle, which contains Webservices. I’m

  • 0

I’m trying to build a maven project, an OSGi bundle, which contains Webservices. I’m using JAX-WS with all the @WebService annotations to specify the webservices I have. To load these Webservices at a client location you are normally using wsgen and wsimport for exporting/importing WSDL files. I plan to use the jaxws-maven-plugin to do so, but here is the problem:

The bundle can act as a server and client at the same time. It can register itself as a client to a parent node of the same bundle (running on a different JVM/host). So this maven project/bundle defines an interface for the webservice and define an implementation class which implements this interface. Both interface and class use the @WebService annotation as usual.

@WebService
public interface Example {
    public void callMe();
}

@WebService
public class ExampleImpl implements Example {
    public void callMe() {};
}

And then somewhere in my code:

Endpoint p = Endpoint.publish(
                 "http://localhost:8080/example",
                 new ExampleImpl());    

The jaxws:wsgen goal reads the annotations and create the output files (.class files, .java files, WSDL files, depending on the configuration…). But how do I use these files during the jaxws:wsimport goal for the same mvn package run? In the same maven project I want to use this webservice, so I need to write something like this:

ExampleImplService service = new ExampleImplService();
Example port = service.getExampleImplPort();
port.callMe();

The jaxws:gen goal is running in the process-classes phase as it needs to read the compiled classes, but jaxws:import must be run in the generate-sources phase to prepare everything for compiling. And now I run in a chicken-egg problem. I need the compiled classes to generate the output files via wsgen, but I need the output files of wsgen for wsimport in the generate-sources phase of maven. My first try was to assign the jaxws:wsgen goal to the generate-sources phase as well but of course its not working as the classes are missing/not compiled yet.

What are my options to solve this problem? Should I run an antrun goal to compile some classes (namely only the classes with the @WebService annotations) prior the generate-sources phase so jaxws:wsgen can use it (in that phase), create the output files which are then used by jaxws:wsimport in the generate-sources phase? Are there other ways to solve this chicken-egg problem? Are there any other “maven ways” for compiling the server and client part of webservices in the same maven project? It should btw. run from a clean mvn clean build, so I don’t want/like any solutions like “run mvn package twice to generate the webservices files first and then to compile everything else”. In other words: mvn clean package should compile the whole maven project/osgi bundle.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T05:09:21+00:00Added an answer on May 20, 2026 at 5:09 am

    I have managed to solve this problem by moving the jaxsw:wsgen goal to the generate-sources phase. I use the following steps.

    1. First I compile the classes with @WebService annotations via an antrun execution, which use <javac> to compile the classes. I save the resulting .class files in a temporary directory which is deleted after I have created the client stubs.
    2. I create the WSDL file from the compiled .class files with the jaxws:wsgen goal.
    3. From the temporary directory I create the client stubs with the normal jaxws:wsimport goal.
    4. I delete the temporary directory with a second antrun execution.

    The resulting pom.xml file looks as follow (only the relevant parts)

    <properties>
        <tmpdirectory>${java.io.tmpdir}${file.separator}${user.name}-${project.groupId}-${project.artifactId}</tmpdirectory>
    </properties>
    ...
            <plugin>
                <!-- clean tmp directory at every "mvn clean" -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <version>2.4.1</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>${tmpdirectory}</directory>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.6</version>
                <dependencies>
                      <dependency>
                          <groupId>com.sun</groupId>
                          <artifactId>tools</artifactId>
                          <version>1.6.0</version>
                          <scope>system</scope>
                          <systemPath>${java.home}/../lib/tools.jar</systemPath>
                      </dependency>
                </dependencies>  
                <executions>
                    <execution>
                        <!-- compile webservice classes into tmp directory -->
                        <id>mini compile of webservices</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <property name="compile_classpath" refid="maven.compile.classpath"/>
                                <mkdir dir="${tmpdirectory}" />
                                <javac includeAntRuntime="false"
                                       classpath="${compile_classpath}"
                                       destdir="${tmpdirectory}">
                                    <src path="${project.build.sourceDirectory}" />
                                    <include name="org/example/project/*/webservice/*.java" />
                                </javac>
                            </target>
                        </configuration>
                    </execution>
                    <execution>
                        <!-- delete temporary directory (in case mvn clean is not called) -->
                        <id>clean up tmp dir</id>
                        <phase>process-sources</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <delete dir="${tmpdirectory}" />
                            </target>
                        </configuration>
                    </execution>
                </executions>  
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <version>1.10</version>
                <executions>
                    <execution>
                        <!-- generate WSDL file from the compiled classes in tmp directory -->
                        <id>generate wsdl file</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>wsgen</goal>
                        </goals>
                        <configuration>
                            <sei><!-- service endpoint implementation  --></sei>
                            <destDir>${tmpdirectory}</destDir>
                            <genWsdl>true</genWsdl>
                            <resourceDestDir>${tmpdirectory}</resourceDestDir>
                        </configuration>
                    </execution>
                    <execution>
                        <!-- create client stub files -->
                        <id>create client files from wsdl file</id>
                        <goals>
                            <goal>wsimport</goal>
                        </goals>
                        <configuration>
                            <keep>true</keep>
                            <wsdlDirectory>${tmpdirectory}</wsdlDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a text area in my form which accepts all possible characters from
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.