JJOC214
JJOC214

Reputation: 51

javax.xml.namespace.QName does not exist in Java 11

I have problems when trying to run Java classes that were generated automatically from a wsdl with the javax.xml.namespace.QName attribute, it was working correctly in Java 7 but when changing version it stopped recognizing. pom.xml

<dependency>
         <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-databind</artifactId>
          <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>${servlet.jstl.version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>${servlet.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.thymeleaf</groupId>
            <artifactId>thymeleaf</artifactId>
            <version>3.0.9.RELEASE</version>
        </dependency>
        
        <dependency>
              <groupId>javax.xml.stream</groupId>
              <artifactId>stax-api</artifactId>
              <version>1.0-2</version>
            </dependency>   
        
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.8</version>
            <!--<scope>provided</scope>-->
        </dependency>
        
        <dependency>
            <groupId>com.thoughtworks.xstream</groupId>
            <artifactId>xstream</artifactId>
            <version>1.4.2</version>
            <!--<scope>provided</scope>-->
        </dependency>           
        
        <!-- POI -->        
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.13</version>
            <!--<scope>provided</scope>-->
            <exclusions>
               <exclusion>
                  <groupId>commons-codec</groupId>
                  <artifactId>commons-codec</artifactId>
               </exclusion>
            </exclusions>
        </dependency>
        
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.9</version>
            <!--<scope>provided</scope>-->
            <exclusions>
               <exclusion>
                  <groupId>org.apache.poi</groupId>
                  <artifactId>poi-ooxml-schemas</artifactId>
               </exclusion>
               <exclusion>
                  <groupId>org.apache.xmlbeans</groupId>
                  <artifactId>xmlbeans</artifactId>
               </exclusion>
               <exclusion>
                  <groupId>stax</groupId>
                  <artifactId>stax-api</artifactId>
               </exclusion>
            </exclusions>
        </dependency>
        
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml-schemas</artifactId>
            <version>3.9</version>
            <!--<scope>provided</scope>-->
        </dependency>
        
        <dependency>
            <groupId>org.apache.xmlbeans</groupId>
            <artifactId>xmlbeans</artifactId>
            <version>2.3.0</version>
            <!--<scope>provided</scope>-->
        </dependency>
        
                
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.2</version>
            <!--<scope>provided</scope>-->
        </dependency>
        
        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>1.9.3</version>
            <!--<scope>provided</scope>-->
        </dependency>
        
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.9</version>
            <!--<scope>provided</scope>-->
        </dependency>
        
        <!-- Apache Commons IO -->
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.4</version>
            <!--<scope>provided</scope>-->
        </dependency>
        
        <!-- Apache Commons Fileupload -->
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.3</version>
            <!--<scope>provided</scope>-->
        </dependency>
        
        <!-- Apache Commons Lang3 -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.4</version>
            <!--<scope>provided</scope>-->
        </dependency>
        
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.6</version>
            <!--<scope>provided</scope>-->
        </dependency>
        
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.2.2</version>
            <!--<scope>provided</scope>-->
        </dependency>
        
        <dependency>
            <groupId>commons-digester</groupId>
            <artifactId>commons-digester</artifactId>
            <version>2.1</version>
            <!--<scope>provided</scope>-->
        </dependency>
        
        <!-- Java Activation -->
        <dependency>
            <groupId>javax.activation</groupId>
            <artifactId>activation</artifactId>
            <version>1.1.1</version>
            <!--<scope>provided</scope>-->
        </dependency>
        <!-- JavaMail extension -->
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4.7</version>
            <!--<scope>provided</scope>-->
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>1.6.11</version>
            <!--<scope>provided</scope>-->
        </dependency>

        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>1.6.11</version>
            <!--<scope>provided</scope>-->
        </dependency>
        
        <dependency>
            <groupId>aopalliance</groupId>
            <artifactId>aopalliance</artifactId>
            <version>1.0</version>
            <!--<scope>provided</scope>-->
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.3.5</version>
            <!--<scope>provided</scope>-->
        </dependency>
        
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-json-org</artifactId>
            <version>2.9.1</version>
        </dependency>
<dependency>
  <groupId>com.sun.xml.ws</groupId>
  <artifactId>jaxws-ri</artifactId>
  <version>2.3.0</version>
  <type>pom</type>
</dependency> 
    </dependencies>

I tried to add exclusions, for xml-apis but it still does not work I do not know what else to remove what else to add I am in a loop I try several things but I cannot reach the solution, mostly it always worked with Java-7 but currently it is making these changes in Java-11 and I can't get past this point because the only thing that causes me problems is: javax.xml.namespace.QName The package javax.xml.namespace is accessible from more than one module:, java.xml

But in bookstores there is that dependency looking for them. I also leave the code that was generated which is causing problems. I would like to know if there is any solution. I would appreciate your support. I have already tried to find a solution for it for 1 week.

Service.java

import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceFeature;

@WebServiceClient(name = "service", 
                  wsdlLocation = "/wsdl/wsd_creado.wsdl",
                  targetNamespace = "http://camel.apache.org/cxf/jaxws/dispatch") 
public class Service extends javax.xml.ws.Service {

    public final static URL WSDL_LOCATION;

    public final static QName SERVICE = new QName("http://camel.apache.org/cxf/jaxws/dispatch", "service");
    public final static QName Port = new QName("http://camel.apache.org/cxf/jaxws/dispatch", "port");
    static {
        URL url = Service.class.getResource("/wsdl/wsd_creado.wsdl");
        if (url == null) {
            url = Service.class.getClassLoader().getResource("/wsdl/wsd_creado.wsdl");
        } 
        if (url == null) {
            java.util.logging.Logger.getLogger(Service.class.getName())
                .log(java.util.logging.Level.INFO, 
                     "Can not initialize the default wsdl from {0}", "/wsdl/wsd_creado.wsdl");
        }       
        WSDL_LOCATION = url;
    }

    public Service(URL wsdlLocation) {
        super(wsdlLocation, SERVICE);
    }

    public Service(URL wsdlLocation, QName serviceName) {
        super(wsdlLocation, serviceName);
    }

    public Service() {
        super(WSDL_LOCATION, SERVICE);
    }
    
    public Service(WebServiceFeature ... features) {
        super(WSDL_LOCATION, SERVICE, features);
    }

    public Service(URL wsdlLocation, WebServiceFeature ... features) {
        super(wsdlLocation, SERVICE, features);
    }

    public Service(URL wsdlLocation, QName serviceName, WebServiceFeature ... features) {
        super(wsdlLocation, serviceName, features);
    }    
    @WebEndpoint(name = "port")
    public AbsenceContingent getPort() {
        return super.getPort(Port, AbsenceContingent.class);
    }
    @WebEndpoint(name = "port")
    public AbsenceContingent getPort(WebServiceFeature... features) {
        return super.getPort(Port, AbsenceContingent.class, features);
    }

}

If there is an error within the pom.xml that can be corrected or if I have to modify the code or there is another method that has to change in java-11, I would appreciate your support.

Upvotes: 5

Views: 36825

Answers (1)

felipeheld
felipeheld

Reputation: 81

I was facing the exact same problem today, and came across a really helpful post. Maybe it might be of use to you too. Here you go.

The solution for me was in the answer by user lilalinux.

Upvotes: 6

Related Questions