0

I'm running IntelliJ with Java 6 to build my project. I'm doing a clean checkout via SVN and trying to do a mvn clean install It runs successfully but then when I try to deploy my application I get a compile time error. It says that I'm trying to use a constructor that doesn't exist.

Specifically, I'm trying to use a constructor from Here . This constructor is NOT in the Java 5 version. But for some reason, the .class file in my jdk 1.6 install appears to be the Java 5 version. The location of the .class file is /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar!/javax/xml/ws/Service.class and that path was copied directly from IntelliJ when I drill down .

Here is the decompiled code from IntelliJ

  // IntelliJ API Decompiler stub source generated from a class file
  // Implementation of methods is not available

package javax.xml.ws;

public class Service {
    private javax.xml.ws.spi.ServiceDelegate delegate;

    protected Service(java.net.URL url, javax.xml.namespace.QName qName) { /* compiled code */ }

    public <T> T getPort(javax.xml.namespace.QName qName, java.lang.Class<T> aClass) { /* compiled code */ }

    public <T> T getPort(javax.xml.namespace.QName qName, java.lang.Class<T> aClass, javax.xml.ws.WebServiceFeature... webServiceFeatures) { /* compiled code */ }

    public <T> T getPort(java.lang.Class<T> aClass) { /* compiled code */ }

    public <T> T getPort(java.lang.Class<T> aClass, javax.xml.ws.WebServiceFeature... webServiceFeatures) { /* compiled code */ }

    public <T> T getPort(javax.xml.ws.EndpointReference endpointReference, java.lang.Class<T> aClass, javax.xml.ws.WebServiceFeature... webServiceFeatures) { /* compiled code */ }

    public void addPort(javax.xml.namespace.QName qName, java.lang.String s, java.lang.String s1) { /* compiled code */ }

    public <T> javax.xml.ws.Dispatch<T> createDispatch(javax.xml.namespace.QName qName, java.lang.Class<T> aClass, javax.xml.ws.Service.Mode mode) { /* compiled code */ }

    public <T> javax.xml.ws.Dispatch<T> createDispatch(javax.xml.namespace.QName qName, java.lang.Class<T> aClass, javax.xml.ws.Service.Mode mode, javax.xml.ws.WebServiceFeature... webServiceFeatures) { /* compiled code */ }

    public <T> javax.xml.ws.Dispatch<T> createDispatch(javax.xml.ws.EndpointReference endpointReference, java.lang.Class<T> aClass, javax.xml.ws.Service.Mode mode, javax.xml.ws.WebServiceFeature... webServiceFeatures) { /* compiled code */ }

    public javax.xml.ws.Dispatch<java.lang.Object> createDispatch(javax.xml.namespace.QName qName, javax.xml.bind.JAXBContext jaxbContext, javax.xml.ws.Service.Mode mode) { /* compiled code */ }

    public javax.xml.ws.Dispatch<java.lang.Object> createDispatch(javax.xml.namespace.QName qName, javax.xml.bind.JAXBContext jaxbContext, javax.xml.ws.Service.Mode mode, javax.xml.ws.WebServiceFeature... webServiceFeatures) { /* compiled code */ }

    public javax.xml.ws.Dispatch<java.lang.Object> createDispatch(javax.xml.ws.EndpointReference endpointReference, javax.xml.bind.JAXBContext jaxbContext, javax.xml.ws.Service.Mode mode, javax.xml.ws.WebServiceFeature... webServiceFeatures) { /* compiled code */ }

    public javax.xml.namespace.QName getServiceName() { /* compiled code */ }

    public java.util.Iterator<javax.xml.namespace.QName> getPorts() { /* compiled code */ }

    public java.net.URL getWSDLDocumentLocation() { /* compiled code */ }

    public javax.xml.ws.handler.HandlerResolver getHandlerResolver() { /* compiled code */ }

    public void setHandlerResolver(javax.xml.ws.handler.HandlerResolver handlerResolver) { /* compiled code */ }

    public java.util.concurrent.Executor getExecutor() { /* compiled code */ }

    public void setExecutor(java.util.concurrent.Executor executor) { /* compiled code */ }

    public static javax.xml.ws.Service create(java.net.URL url, javax.xml.namespace.QName qName) { /* compiled code */ }

    public static javax.xml.ws.Service create(javax.xml.namespace.QName qName) { /* compiled code */ }

    public static enum Mode {
        MESSAGE, PAYLOAD;

        public static javax.xml.ws.Service.Mode[] values() { /* compiled code */ }

        public static javax.xml.ws.Service.Mode valueOf(java.lang.String s) { /* compiled code */ }

        private Mode() { /* compiled code */ }
    }
}

Can anyone explain what is going on?

Edit #1: It doesn't error at deploy, its errors at compile time. I communicated that poorly above. You can see the red squiggles in IntelliJ. When I try to drill down on the constructor, it shows me the decompiled code seen above. The issue is that it does NOT look like the Java 6 class, it appears to be the Java 5 class but it is in my Java 6 SDK. Also, someone pointed out that the constructor is protected so I can't use it. However, my class extends service so its allowed to use the constructor.

Output from mvn -v

<machine_name>:record-replay carlos$ mvn -v
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 08:51:28-0500)
Maven home: /Users/carlos/workspace/dev/apache-maven/current
Java version: 1.6.0_65, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: en_US, platform encoding: MacRoman
OS name: "mac os x", version: "10.9.4", arch: "x86_64", family: "mac"

Edit #2: @Didier Yeah, I can get around it by using the Jaxb and jaxws version of Service.class Thanks for that. But I'm more interested in why this class in my Java 6 SDK is failing when the API says it should have the constructor

Carlos Bribiescas
  • 4,197
  • 9
  • 35
  • 66
  • Deploy to where exactly? I've had problems like this by deploying to for example JBoss 4.2.X. You may also be accidentally deploying an older version of the API jar with your application because it is a transitive Maven dependency – Gimby Sep 29 '14 at 13:26
  • what version of java is `mvn` using? (please show the output of `mvn -v`) – ljgw Sep 29 '14 at 13:29
  • 2
    `i try to deploy my applciation I get a compile time error. It says that I'm trying to use a contructor that doesn't exist.` this sounds like a **runtime error** as the machine you are deploying to is running Java 5.0. – Peter Lawrey Sep 29 '14 at 13:31
  • My earlier comment mostly stands - you may have an older version of the jar on your Maven compile classpath which needs to be excluded. Do a mvn dependency:tree and see what is in there and what is transitively added to the Maven dependencies. – Gimby Sep 29 '14 at 14:01
  • The thing is that the java class doesn't match what the API says. Is it an old java bug? Yes, I can manually edit the classpath to fix, but I shouldn't have to because as configured, according to documentation, it should work. (That is my understanding at least, which is why I'm confused it isn't that way.) – Carlos Bribiescas Sep 29 '14 at 14:07
  • 1
    I don't care what whatever documentation you do not specifically refer to says - the problems you describe have all the hallmarks of a classpath conflict and so unless you make the effort to prove it is not the case, that's what I want to believe is the truth - Occam's Razor. – Gimby Sep 29 '14 at 14:40
  • I do specifically refer to the documentation in the post. How do i prove it isn't to do with the classpath then? I put the path of the class file that its using, and its where its supposed to be. BUT it doesn't look like what the Java API says it should. – Carlos Bribiescas Sep 29 '14 at 15:40
  • possible duplicate of [javac cannot find symbol constructor Service](http://stackoverflow.com/questions/14131503/javac-cannot-find-symbol-constructor-service) – Didier L Sep 29 '14 at 16:10

1 Answers1

2

The actual javax.xml.ws.Service included in JDK6 is the one from JAXB/JAX-WS 2.0 and does not have this constructor. The actual documentation is here.

You are referring to the documentation of Java EE 6 which includes JAXB/JAX-WS 2.1 with the new constructor.

You should be able to fix your issue following these instructions. See also this question.

Community
  • 1
  • 1
Didier L
  • 18,905
  • 10
  • 61
  • 103
  • 1
    I think Java 6 includes the same class as JEE 5 (see [here](http://docs.oracle.com/javaee/5/api/javax/xml/ws/Service.html)). Java 5 didn't include this class at all. – Didier L Sep 29 '14 at 16:21
  • I almost always use those two documentations interchangeably. Bit me in the ass this time. Thanks. – Carlos Bribiescas Sep 29 '14 at 16:23