Reputation: 3367
I just starting to use Maven and wanted to change my current JavaFX8 FXML application to work with Maven. As a test, I'm trying to retrieve a list of countries from my webservice running on Glassfish 3.
When I run the program, this happens in my FXML controller at initialize()
:
CountryClientSSL cc = new CountryClientSSL();
cc.setUsernamePassword("username", "password");
ObservableList<Country> olCountries = FXCollections.observableArrayList(cc.findAll());
olCountries.stream().forEach((country) -> {
System.out.println(country.getName());
});
cc.close();
The findAll()
method:
public List<Country> findAll() throws ClientErrorException {
WebTarget resource = webTarget;
resource = resource.path("countries");
System.out.println(resource.getUri().toString());
return resource.request(javax.ws.rs.core.MediaType.APPLICATION_XML).get(new GenericType<List<Country>>(){});
}
The URI looks fine and works with the credentials if I test it in my browser, however the following error is being thrown:
...
Caused by: java.lang.NoSuchMethodError: javax.ws.rs.core.MultivaluedMap.addAll(Ljava/lang/Object;[Ljava/lang/Object;)V
at org.glassfish.jersey.client.ClientRequest.accept(ClientRequest.java:335)
at org.glassfish.jersey.client.JerseyWebTarget.request(JerseyWebTarget.java:221)
at org.glassfish.jersey.client.JerseyWebTarget.request(JerseyWebTarget.java:59)
at DA.CountryClientSSL.findAll(CountryClientSSL.java:85)
...
My pom.xml file has the Jersey dependency:
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.21</version>
</dependency>
I found a similar (old) question here NoSuchMethodError: MultivaluedMap.addAll in Jersey Client but it didn't help me much further. Could someone point me in the right direction about what I'm doing wrong?
Thanks in advance!
Edit: Structure
src
|-main
|-java
|-classes
|-DA
|-GUI (the controllers, still have to rename this)
|-resources
|-bundles
|-fxml
|-images
|-jnlp
|-styles
target
pom.xml
Upvotes: 0
Views: 6586
Reputation: 12885
Looks like you have a JAX-RS 1.x dependency on your classpath, as described in the question you mentioned: NoSuchMethodError: MultivaluedMap.addAll in Jersey Client.
You can run mvn dependency:tree
to print all (transitive) dependencies of your project. Then check if there is some other Jersey or javax.ws.rs
dependency preceding the ones you really want.
Upvotes: 5