Maven Dynamic Web Project dependencies defined in pom.xml file not working

539 Views Asked by At

I have a university project which involves setting up multiple Java Eclipse Dynamic Web Projects. These projects require JAXWS annotations which are set up by adding a couple of properties and dependencies into the pom.xml file of the project.

<dependencies>
    <dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>jaxws-rt</artifactId>
        <version>2.2.6</version>
    </dependency>
    <dependency>
        <groupId>com.sun.org.apache.xml.internal</groupId>
        <artifactId>resolver</artifactId>
        <version>20050927</version>
    </dependency>
</dependencies>

Upon trying to use the JAX-WS annotations required (@WebService, @WebResult, etc.) in the project's Java interface I get an error message stating i.e. " "WebService" cannot be resolved to a type". I have tried manually importing these libraries into the interface class (i.e. import javax.jws.WebService) but get an error message "The import javax.jws cannot be resolved".

My lecturer has stated that the only reason he can think of the annotations not working is if the dependencies haven't been added, even though I've done that? It's really confusing me, any help would be much appreciated.

1

There are 1 best solutions below

0
SharifS On

You are not using the correct dependency for WebService, WebResult

Try this:

<!-- https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api -->
<dependency>
    <groupId>javax.xml.ws</groupId>
    <artifactId>jaxws-api</artifactId>
    <version>2.2.6</version>
</dependency>