java.lang.LinkageError: loader constraint violation: previously initiated for a different type with name “javax/servlet/http/HttpServletRequest”










0















Just want to use HttpServletRequest in my Rest service.
Get the follow error page when try to do GET request:



java.lang.LinkageError: loader constraint violation: loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoader) previously initiated loading for a different type with name "javax/servlet/http/HttpServletRequest"


I use apache-karaf-4.1.5 as a container, apache-cxf for JAX-RS implementation. And I marked javax.servlet-api as provided in pom.xml:



<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<version>3.1.7</version>
</dependency>


So.. any thoughts to avoid this error and makes this work properly ?



Thanks!



UPDATE mvn dependency:tree output:



[INFO] +- org.codehaus.jackson:jackson-jaxrs:jar:1.9.0:compile
[INFO] | +- org.codehaus.jackson:jackson-core-asl:jar:1.9.0:compile
[INFO] | - org.codehaus.jackson:jackson-mapper-asl:jar:1.9.0:compile
[INFO] +- org.springframework:spring-jdbc:jar:4.3.11.RELEASE:compile
[INFO] | +- org.springframework:spring-beans:jar:4.3.11.RELEASE:compile
[INFO] | +- org.springframework:spring-core:jar:4.3.11.RELEASE:compile
[INFO] | | - commons-logging:commons-logging:jar:1.2:compile
[INFO] | - org.springframework:spring-tx:jar:4.3.11.RELEASE:compile
[INFO] +- net.sourceforge.jtds:jtds:jar:1.3.1:test
[INFO] +- commons-io:commons-io:jar:2.4:compile
[INFO] +- com.google.guava:guava:jar:19.0:compile
[INFO] +- org.apache.commons:commons-csv:jar:1.1:compile
[INFO] +- org.apache.commons:commons-email:jar:1.4:compile
[INFO] | +- com.sun.mail:javax.mail:jar:1.5.2:compile
[INFO] | - javax.activation:activation:jar:1.1.1:compile
[INFO] +- joda-time:joda-time:jar:1.6:compile
[INFO] +- commons-dbutils:commons-dbutils:jar:1.5:compile
[INFO] +- com.thoughtworks.xstream:xstream:jar:1.3.1:compile
[INFO] | - xpp3:xpp3_min:jar:1.1.4c:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.0:compile
[INFO] +- javax.ws.rs:javax.ws.rs-api:jar:2.0:compile
[INFO] +- org.apache.poi:poi-ooxml:jar:3.17:compile
[INFO] | +- org.apache.poi:poi:jar:3.17:compile
[INFO] | | +- commons-codec:commons-codec:jar:1.10:compile
[INFO] | | - org.apache.commons:commons-collections4:jar:4.1:compile
[INFO] | +- org.apache.poi:poi-ooxml-schemas:jar:3.17:compile
[INFO] | | - org.apache.xmlbeans:xmlbeans:jar:2.6.0:compile
[INFO] | | - stax:stax-api:jar:1.0.1:compile
[INFO] | - com.github.virtuald:curvesapi:jar:1.04:compile
[INFO] +- org.dom4j:dom4j:jar:2.0.1:compile
[INFO] | - jaxen:jaxen:jar:1.1.6:compile
[INFO] +- javax.servlet:javax.servlet-api:jar:3.1.0:provided
[INFO] +- org.whitesource:maven-dependency-tree-parser:jar:1.0.5:compile
[INFO] | - commons-lang:commons-lang:jar:2.4:compile
[INFO] +- org.apache.cxf:cxf-rt-frontend-jaxrs:bundle:3.1.7:provided
[INFO] | +- org.apache.cxf:cxf-core:jar:3.1.7:provided
[INFO] | | +- org.codehaus.woodstox:woodstox-core-asl:jar:4.4.1:provided
[INFO] | | | - org.codehaus.woodstox:stax2-api:jar:3.1.4:provided
[INFO] | | - org.apache.ws.xmlschema:xmlschema-core:jar:2.2.1:provided
[INFO] | +- javax.annotation:javax.annotation-api:jar:1.2:provided
[INFO] | - org.apache.cxf:cxf-rt-transports-http:jar:3.1.7:provided
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.0:test
[INFO] | - log4j:log4j:jar:1.2.17:test
[INFO] +- junit:junit:jar:4.12:test
[INFO] | - org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] - org.mockito:mockito-all:jar:1.10.19:test









share|improve this question
























  • Please check the dependency tree (e.g. using mvn dependency:tree), seems that there is another servlet dependency on the classpath.

    – Dennis Kieselhorst
    Nov 16 '18 at 11:58











  • @DennisKieselhorst thanks for your time! I checked this and the dependency tree shows only one servlet dependency.. I've updated my post with mvn dependency:tree output

    – Ruslan
    Nov 16 '18 at 17:39















0















Just want to use HttpServletRequest in my Rest service.
Get the follow error page when try to do GET request:



java.lang.LinkageError: loader constraint violation: loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoader) previously initiated loading for a different type with name "javax/servlet/http/HttpServletRequest"


I use apache-karaf-4.1.5 as a container, apache-cxf for JAX-RS implementation. And I marked javax.servlet-api as provided in pom.xml:



<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<version>3.1.7</version>
</dependency>


So.. any thoughts to avoid this error and makes this work properly ?



Thanks!



UPDATE mvn dependency:tree output:



[INFO] +- org.codehaus.jackson:jackson-jaxrs:jar:1.9.0:compile
[INFO] | +- org.codehaus.jackson:jackson-core-asl:jar:1.9.0:compile
[INFO] | - org.codehaus.jackson:jackson-mapper-asl:jar:1.9.0:compile
[INFO] +- org.springframework:spring-jdbc:jar:4.3.11.RELEASE:compile
[INFO] | +- org.springframework:spring-beans:jar:4.3.11.RELEASE:compile
[INFO] | +- org.springframework:spring-core:jar:4.3.11.RELEASE:compile
[INFO] | | - commons-logging:commons-logging:jar:1.2:compile
[INFO] | - org.springframework:spring-tx:jar:4.3.11.RELEASE:compile
[INFO] +- net.sourceforge.jtds:jtds:jar:1.3.1:test
[INFO] +- commons-io:commons-io:jar:2.4:compile
[INFO] +- com.google.guava:guava:jar:19.0:compile
[INFO] +- org.apache.commons:commons-csv:jar:1.1:compile
[INFO] +- org.apache.commons:commons-email:jar:1.4:compile
[INFO] | +- com.sun.mail:javax.mail:jar:1.5.2:compile
[INFO] | - javax.activation:activation:jar:1.1.1:compile
[INFO] +- joda-time:joda-time:jar:1.6:compile
[INFO] +- commons-dbutils:commons-dbutils:jar:1.5:compile
[INFO] +- com.thoughtworks.xstream:xstream:jar:1.3.1:compile
[INFO] | - xpp3:xpp3_min:jar:1.1.4c:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.0:compile
[INFO] +- javax.ws.rs:javax.ws.rs-api:jar:2.0:compile
[INFO] +- org.apache.poi:poi-ooxml:jar:3.17:compile
[INFO] | +- org.apache.poi:poi:jar:3.17:compile
[INFO] | | +- commons-codec:commons-codec:jar:1.10:compile
[INFO] | | - org.apache.commons:commons-collections4:jar:4.1:compile
[INFO] | +- org.apache.poi:poi-ooxml-schemas:jar:3.17:compile
[INFO] | | - org.apache.xmlbeans:xmlbeans:jar:2.6.0:compile
[INFO] | | - stax:stax-api:jar:1.0.1:compile
[INFO] | - com.github.virtuald:curvesapi:jar:1.04:compile
[INFO] +- org.dom4j:dom4j:jar:2.0.1:compile
[INFO] | - jaxen:jaxen:jar:1.1.6:compile
[INFO] +- javax.servlet:javax.servlet-api:jar:3.1.0:provided
[INFO] +- org.whitesource:maven-dependency-tree-parser:jar:1.0.5:compile
[INFO] | - commons-lang:commons-lang:jar:2.4:compile
[INFO] +- org.apache.cxf:cxf-rt-frontend-jaxrs:bundle:3.1.7:provided
[INFO] | +- org.apache.cxf:cxf-core:jar:3.1.7:provided
[INFO] | | +- org.codehaus.woodstox:woodstox-core-asl:jar:4.4.1:provided
[INFO] | | | - org.codehaus.woodstox:stax2-api:jar:3.1.4:provided
[INFO] | | - org.apache.ws.xmlschema:xmlschema-core:jar:2.2.1:provided
[INFO] | +- javax.annotation:javax.annotation-api:jar:1.2:provided
[INFO] | - org.apache.cxf:cxf-rt-transports-http:jar:3.1.7:provided
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.0:test
[INFO] | - log4j:log4j:jar:1.2.17:test
[INFO] +- junit:junit:jar:4.12:test
[INFO] | - org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] - org.mockito:mockito-all:jar:1.10.19:test









share|improve this question
























  • Please check the dependency tree (e.g. using mvn dependency:tree), seems that there is another servlet dependency on the classpath.

    – Dennis Kieselhorst
    Nov 16 '18 at 11:58











  • @DennisKieselhorst thanks for your time! I checked this and the dependency tree shows only one servlet dependency.. I've updated my post with mvn dependency:tree output

    – Ruslan
    Nov 16 '18 at 17:39













0












0








0








Just want to use HttpServletRequest in my Rest service.
Get the follow error page when try to do GET request:



java.lang.LinkageError: loader constraint violation: loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoader) previously initiated loading for a different type with name "javax/servlet/http/HttpServletRequest"


I use apache-karaf-4.1.5 as a container, apache-cxf for JAX-RS implementation. And I marked javax.servlet-api as provided in pom.xml:



<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<version>3.1.7</version>
</dependency>


So.. any thoughts to avoid this error and makes this work properly ?



Thanks!



UPDATE mvn dependency:tree output:



[INFO] +- org.codehaus.jackson:jackson-jaxrs:jar:1.9.0:compile
[INFO] | +- org.codehaus.jackson:jackson-core-asl:jar:1.9.0:compile
[INFO] | - org.codehaus.jackson:jackson-mapper-asl:jar:1.9.0:compile
[INFO] +- org.springframework:spring-jdbc:jar:4.3.11.RELEASE:compile
[INFO] | +- org.springframework:spring-beans:jar:4.3.11.RELEASE:compile
[INFO] | +- org.springframework:spring-core:jar:4.3.11.RELEASE:compile
[INFO] | | - commons-logging:commons-logging:jar:1.2:compile
[INFO] | - org.springframework:spring-tx:jar:4.3.11.RELEASE:compile
[INFO] +- net.sourceforge.jtds:jtds:jar:1.3.1:test
[INFO] +- commons-io:commons-io:jar:2.4:compile
[INFO] +- com.google.guava:guava:jar:19.0:compile
[INFO] +- org.apache.commons:commons-csv:jar:1.1:compile
[INFO] +- org.apache.commons:commons-email:jar:1.4:compile
[INFO] | +- com.sun.mail:javax.mail:jar:1.5.2:compile
[INFO] | - javax.activation:activation:jar:1.1.1:compile
[INFO] +- joda-time:joda-time:jar:1.6:compile
[INFO] +- commons-dbutils:commons-dbutils:jar:1.5:compile
[INFO] +- com.thoughtworks.xstream:xstream:jar:1.3.1:compile
[INFO] | - xpp3:xpp3_min:jar:1.1.4c:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.0:compile
[INFO] +- javax.ws.rs:javax.ws.rs-api:jar:2.0:compile
[INFO] +- org.apache.poi:poi-ooxml:jar:3.17:compile
[INFO] | +- org.apache.poi:poi:jar:3.17:compile
[INFO] | | +- commons-codec:commons-codec:jar:1.10:compile
[INFO] | | - org.apache.commons:commons-collections4:jar:4.1:compile
[INFO] | +- org.apache.poi:poi-ooxml-schemas:jar:3.17:compile
[INFO] | | - org.apache.xmlbeans:xmlbeans:jar:2.6.0:compile
[INFO] | | - stax:stax-api:jar:1.0.1:compile
[INFO] | - com.github.virtuald:curvesapi:jar:1.04:compile
[INFO] +- org.dom4j:dom4j:jar:2.0.1:compile
[INFO] | - jaxen:jaxen:jar:1.1.6:compile
[INFO] +- javax.servlet:javax.servlet-api:jar:3.1.0:provided
[INFO] +- org.whitesource:maven-dependency-tree-parser:jar:1.0.5:compile
[INFO] | - commons-lang:commons-lang:jar:2.4:compile
[INFO] +- org.apache.cxf:cxf-rt-frontend-jaxrs:bundle:3.1.7:provided
[INFO] | +- org.apache.cxf:cxf-core:jar:3.1.7:provided
[INFO] | | +- org.codehaus.woodstox:woodstox-core-asl:jar:4.4.1:provided
[INFO] | | | - org.codehaus.woodstox:stax2-api:jar:3.1.4:provided
[INFO] | | - org.apache.ws.xmlschema:xmlschema-core:jar:2.2.1:provided
[INFO] | +- javax.annotation:javax.annotation-api:jar:1.2:provided
[INFO] | - org.apache.cxf:cxf-rt-transports-http:jar:3.1.7:provided
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.0:test
[INFO] | - log4j:log4j:jar:1.2.17:test
[INFO] +- junit:junit:jar:4.12:test
[INFO] | - org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] - org.mockito:mockito-all:jar:1.10.19:test









share|improve this question
















Just want to use HttpServletRequest in my Rest service.
Get the follow error page when try to do GET request:



java.lang.LinkageError: loader constraint violation: loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoader) previously initiated loading for a different type with name "javax/servlet/http/HttpServletRequest"


I use apache-karaf-4.1.5 as a container, apache-cxf for JAX-RS implementation. And I marked javax.servlet-api as provided in pom.xml:



<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<version>3.1.7</version>
</dependency>


So.. any thoughts to avoid this error and makes this work properly ?



Thanks!



UPDATE mvn dependency:tree output:



[INFO] +- org.codehaus.jackson:jackson-jaxrs:jar:1.9.0:compile
[INFO] | +- org.codehaus.jackson:jackson-core-asl:jar:1.9.0:compile
[INFO] | - org.codehaus.jackson:jackson-mapper-asl:jar:1.9.0:compile
[INFO] +- org.springframework:spring-jdbc:jar:4.3.11.RELEASE:compile
[INFO] | +- org.springframework:spring-beans:jar:4.3.11.RELEASE:compile
[INFO] | +- org.springframework:spring-core:jar:4.3.11.RELEASE:compile
[INFO] | | - commons-logging:commons-logging:jar:1.2:compile
[INFO] | - org.springframework:spring-tx:jar:4.3.11.RELEASE:compile
[INFO] +- net.sourceforge.jtds:jtds:jar:1.3.1:test
[INFO] +- commons-io:commons-io:jar:2.4:compile
[INFO] +- com.google.guava:guava:jar:19.0:compile
[INFO] +- org.apache.commons:commons-csv:jar:1.1:compile
[INFO] +- org.apache.commons:commons-email:jar:1.4:compile
[INFO] | +- com.sun.mail:javax.mail:jar:1.5.2:compile
[INFO] | - javax.activation:activation:jar:1.1.1:compile
[INFO] +- joda-time:joda-time:jar:1.6:compile
[INFO] +- commons-dbutils:commons-dbutils:jar:1.5:compile
[INFO] +- com.thoughtworks.xstream:xstream:jar:1.3.1:compile
[INFO] | - xpp3:xpp3_min:jar:1.1.4c:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.0:compile
[INFO] +- javax.ws.rs:javax.ws.rs-api:jar:2.0:compile
[INFO] +- org.apache.poi:poi-ooxml:jar:3.17:compile
[INFO] | +- org.apache.poi:poi:jar:3.17:compile
[INFO] | | +- commons-codec:commons-codec:jar:1.10:compile
[INFO] | | - org.apache.commons:commons-collections4:jar:4.1:compile
[INFO] | +- org.apache.poi:poi-ooxml-schemas:jar:3.17:compile
[INFO] | | - org.apache.xmlbeans:xmlbeans:jar:2.6.0:compile
[INFO] | | - stax:stax-api:jar:1.0.1:compile
[INFO] | - com.github.virtuald:curvesapi:jar:1.04:compile
[INFO] +- org.dom4j:dom4j:jar:2.0.1:compile
[INFO] | - jaxen:jaxen:jar:1.1.6:compile
[INFO] +- javax.servlet:javax.servlet-api:jar:3.1.0:provided
[INFO] +- org.whitesource:maven-dependency-tree-parser:jar:1.0.5:compile
[INFO] | - commons-lang:commons-lang:jar:2.4:compile
[INFO] +- org.apache.cxf:cxf-rt-frontend-jaxrs:bundle:3.1.7:provided
[INFO] | +- org.apache.cxf:cxf-core:jar:3.1.7:provided
[INFO] | | +- org.codehaus.woodstox:woodstox-core-asl:jar:4.4.1:provided
[INFO] | | | - org.codehaus.woodstox:stax2-api:jar:3.1.4:provided
[INFO] | | - org.apache.ws.xmlschema:xmlschema-core:jar:2.2.1:provided
[INFO] | +- javax.annotation:javax.annotation-api:jar:1.2:provided
[INFO] | - org.apache.cxf:cxf-rt-transports-http:jar:3.1.7:provided
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.0:test
[INFO] | - log4j:log4j:jar:1.2.17:test
[INFO] +- junit:junit:jar:4.12:test
[INFO] | - org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] - org.mockito:mockito-all:jar:1.10.19:test






java rest servlets cxf apache-karaf






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 17:36







Ruslan

















asked Nov 14 '18 at 22:10









RuslanRuslan

2,479822




2,479822












  • Please check the dependency tree (e.g. using mvn dependency:tree), seems that there is another servlet dependency on the classpath.

    – Dennis Kieselhorst
    Nov 16 '18 at 11:58











  • @DennisKieselhorst thanks for your time! I checked this and the dependency tree shows only one servlet dependency.. I've updated my post with mvn dependency:tree output

    – Ruslan
    Nov 16 '18 at 17:39

















  • Please check the dependency tree (e.g. using mvn dependency:tree), seems that there is another servlet dependency on the classpath.

    – Dennis Kieselhorst
    Nov 16 '18 at 11:58











  • @DennisKieselhorst thanks for your time! I checked this and the dependency tree shows only one servlet dependency.. I've updated my post with mvn dependency:tree output

    – Ruslan
    Nov 16 '18 at 17:39
















Please check the dependency tree (e.g. using mvn dependency:tree), seems that there is another servlet dependency on the classpath.

– Dennis Kieselhorst
Nov 16 '18 at 11:58





Please check the dependency tree (e.g. using mvn dependency:tree), seems that there is another servlet dependency on the classpath.

– Dennis Kieselhorst
Nov 16 '18 at 11:58













@DennisKieselhorst thanks for your time! I checked this and the dependency tree shows only one servlet dependency.. I've updated my post with mvn dependency:tree output

– Ruslan
Nov 16 '18 at 17:39





@DennisKieselhorst thanks for your time! I checked this and the dependency tree shows only one servlet dependency.. I've updated my post with mvn dependency:tree output

– Ruslan
Nov 16 '18 at 17:39












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53309483%2fjava-lang-linkageerror-loader-constraint-violation-previously-initiated-for-a%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53309483%2fjava-lang-linkageerror-loader-constraint-violation-previously-initiated-for-a%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3

Museum of Modern and Contemporary Art of Trento and Rovereto