The constructor Service(URL, QName, WebServiceFeature[]) is undefined
Asked Answered
K

7

19

I got The constructor Service(URL, QName, WebServiceFeature[]) is undefined error after I run wsimport for my client web service. Im using JDK 1.6. Please help.

Error

Khat answered 7/3, 2012 at 11:59 Comment(0)
D
12

You had produced code that needs JAX-WS 2.1. Version 2.0 does not have WebServiceFeature class, and as result also not constructor in Service with such a argument type.

As you see, in Java SE 6 there is no such a constructor: javax.xml.ws.Service SE 6, but for example in Java EE 6 there is: javax.xml.ws.Service EE 6

Dishabille answered 9/3, 2012 at 6:42 Comment(5)
@Sergey What do you mean? In general past versions do not reflect future changes. When 2.1 features are needed, 2.1 should be used.Dishabille
Mikko Maunu, sorry for being stupid but how to set the version of jaxws - just replace jar files?Senhauser
Yeah you need the new code, for an lib make sure it takes precedence over the jdk classes (in eclipse the order and export order must place the jdk below the new lib). Also, there is jdk 1.7.Historian
I personally think that @Sireesh Yarlagadda's answer is the real solution whereas this answer is more like a hints on the problem.Runkel
@Fritz's answer could also be an alternate solution.Runkel
N
16

add additional option "-target 2.0" while using wsimport to generate source codes for JAX-WS 2.0 and so on.

Neurosurgery answered 21/11, 2012 at 7:30 Comment(1)
This worked for me, as I'm using Java EE 5, which overrides the version of JAC-WS.Famish
D
12

You had produced code that needs JAX-WS 2.1. Version 2.0 does not have WebServiceFeature class, and as result also not constructor in Service with such a argument type.

As you see, in Java SE 6 there is no such a constructor: javax.xml.ws.Service SE 6, but for example in Java EE 6 there is: javax.xml.ws.Service EE 6

Dishabille answered 9/3, 2012 at 6:42 Comment(5)
@Sergey What do you mean? In general past versions do not reflect future changes. When 2.1 features are needed, 2.1 should be used.Dishabille
Mikko Maunu, sorry for being stupid but how to set the version of jaxws - just replace jar files?Senhauser
Yeah you need the new code, for an lib make sure it takes precedence over the jdk classes (in eclipse the order and export order must place the jdk below the new lib). Also, there is jdk 1.7.Historian
I personally think that @Sireesh Yarlagadda's answer is the real solution whereas this answer is more like a hints on the problem.Runkel
@Fritz's answer could also be an alternate solution.Runkel
B
7

Change your JAX-WS in the preferences. It is compatibility issue for Java 6 SE and Java EE

enter image description here

Sometimes changing from Java 1.6 to Java 1.7 also solves this issue.

Brodsky answered 5/8, 2014 at 22:12 Comment(0)
H
3

remove jdk1.6 from classpath,then add jdk1.7 can resolve this issue

Hak answered 29/12, 2015 at 12:7 Comment(1)
You can also replace jdk1.6 with jdk1.8Transmarine
A
1

You can manually add webservices-api.jar from JAX-WS 2.2 API, into /lib/endorsed. See the bottom of this page: https://blogs.oracle.com/ritzmann/entry/metro_2_0_on_java

Acclivity answered 28/3, 2012 at 17:11 Comment(0)
V
1

Additionally to switch from java 6 to java 7 you may need to change the 'Order and Export' Eclipse tab in 'Java build path' and put 'JRE system library' on top of the list. If that works it could mean you have an old jar somewhere in your project.

Vocable answered 10/11, 2017 at 15:10 Comment(0)
M
0

Check the Java version in Eclipse. Go the command prompt and check for the Java version there (command: java -version). Match both the versions and it should work just fine.

Myosotis answered 5/12, 2015 at 0:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.