java.lang.LinkageError using spring and gradle -


i'm trying deploy spring mvc project on tomcat 8.0.22 . user gradle project builder. when try lunch project have error code 500.

this how project :

build.gradle file :

buildscript {     ext {         springbootversion = '1.2.3.release'     }     repositories {         mavencentral()     }     dependencies {         classpath("org.springframework.boot:spring-boot-gradle-plugin:${springbootversion}")          classpath("io.spring.gradle:dependency-management-plugin:0.5.1.release")     } }  apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'idea' apply plugin: 'spring-boot'  apply plugin: 'io.spring.dependency-management'   jar {     basename = 'demo'     version = '0.0.1-snapshot' } sourcecompatibility = 1.7 targetcompatibility = 1.7  repositories {     mavencentral() }   dependencies {     compile("org.springframework.boot:spring-boot-starter-web")     testcompile("org.springframework.boot:spring-boot-starter-test")      compile 'org.springframework:spring-context:4.1.6.release'     compile 'org.springframework:spring-core:4.1.6.release'     compile 'org.springframework:spring-webmvc:4.1.6.release' }   eclipse {     classpath {          containers.remove('org.eclipse.jdt.launching.jre_container')          containers 'org.eclipse.jdt.launching.jre_container/org.eclipse.jdt.internal.debug.ui.launcher.standardvmtype/javase-1.7'     } }  task wrapper(type: wrapper) {     gradleversion = '2.3' } 

web.xml file :

<?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"     xmlns="http://xmlns.jcp.org/xml/ns/javaee"     xsi:schemalocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"     id="webapp_id" version="3.1">      <display-name>livelizard-frontend</display-name>     <servlet>         <servlet-name>springmvcdispatcher</servlet-name>         <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class>     </servlet>     <servlet-mapping>         <servlet-name>springmvcdispatcher</servlet-name>         <url-pattern>/</url-pattern>     </servlet-mapping>     <listener>         <listener-class>org.springframework.web.context.contextloaderlistener</listener-class>     </listener>     <listener>         <listener-class>org.springframework.web.context.request.requestcontextlistener</listener-class>     </listener>     <context-param>         <param-name>contextconfiglocation</param-name>         <param-value>             /web-inf/springmvcdispatcher-servlet.xml         </param-value>     </context-param>  </web-app> 

spring dispatcher (springmvcdispatcher-servlet.xml) file :

<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans"     xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:context="http://www.springframework.org/schema/context"     xmlns:mvc="http://www.springframework.org/schema/mvc"     xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd         http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">      <context:component-scan base-package="com.nostatikmedia.livelizard.controller"></context:component-scan>     <context:annotation-config />     <bean         class="org.springframework.web.servlet.mvc.method.annotation.requestmappinghandlermapping"></bean>     <bean         class="org.springframework.web.servlet.view.internalresourceviewresolver">         <property name="prefix" value="/web-inf/view/"></property>         <property name="suffix" value=".jsp"></property>     </bean>     <mvc:annotation-driven />  </beans> 

my controller (maincontroller.java) :

package com.nostatikmedia.livelizard.controller;  import org.springframework.stereotype.controller; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.requestmethod;  @controller @requestmapping("/") public class maincontroller {      @requestmapping(method=requestmethod.get)     public string index(){         return "authenticate";     }  } 

and here view (authenticate.jsp) :

<%@ page language="java" contenttype="text/html; charset=utf-8"     pageencoding="utf-8"%> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>insert title here</title> </head> <body>     <h1>hellow !</h1> </body> </html> 

when lunch project on tomcat v8.0.22 have error :

grave: "servlet.service()" pour la servlet jsp lancé une exception java.lang.linkageerror: loader constraint violation: when resolving method "org.apache.jasper.runtime.instancemanagerfactory.getinstancemanager(ljavax/servlet/servletconfig;)lorg/apache/tomcat/instancemanager;" class loader (instance of org/apache/jasper/servlet/jasperloader) of current class, org/apache/jsp/web_002dinf/view/authenticate_jsp, , class loader (instance of java/net/urlclassloader) resolved class, org/apache/jasper/runtime/instancemanagerfactory, have different class objects type .getinstancemanager(ljavax/servlet/servletconfig;)lorg/apache/tomcat/instancemanager; used in signature     @ org.apache.jsp.web_002dinf.view.authenticate_jsp._jspinit(authenticate_jsp.java:53)     @ org.apache.jasper.runtime.httpjspbase.init(httpjspbase.java:49)     @ org.apache.jasper.servlet.jspservletwrapper.getservlet(jspservletwrapper.java:179)     @ org.apache.jasper.servlet.jspservletwrapper.service(jspservletwrapper.java:375)     @ org.apache.jasper.servlet.jspservlet.servicejspfile(jspservlet.java:396)     @ org.apache.jasper.servlet.jspservlet.service(jspservlet.java:340)     @ javax.servlet.http.httpservlet.service(httpservlet.java:729)     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:291)     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206)     @ org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52)     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:239)     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206)     @ org.apache.catalina.core.applicationdispatcher.invoke(applicationdispatcher.java:721)     @ org.apache.catalina.core.applicationdispatcher.processrequest(applicationdispatcher.java:466)     @ org.apache.catalina.core.applicationdispatcher.doforward(applicationdispatcher.java:391)     @ org.apache.catalina.core.applicationdispatcher.forward(applicationdispatcher.java:318)     @ org.springframework.web.servlet.view.internalresourceview.rendermergedoutputmodel(internalresourceview.java:168)     @ org.springframework.web.servlet.view.abstractview.render(abstractview.java:303)     @ org.springframework.web.servlet.dispatcherservlet.render(dispatcherservlet.java:1244)     @ org.springframework.web.servlet.dispatcherservlet.processdispatchresult(dispatcherservlet.java:1027)     @ org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:971)     @ org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:893)     @ org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:966)     @ org.springframework.web.servlet.frameworkservlet.doget(frameworkservlet.java:857)     @ javax.servlet.http.httpservlet.service(httpservlet.java:622)     @ org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:842)     @ javax.servlet.http.httpservlet.service(httpservlet.java:729)     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:291)     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206)     @ org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52)     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:239)     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206)     @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:219)     @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:106)     @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:502)     @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:142)     @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:79)     @ org.apache.catalina.valves.abstractaccesslogvalve.invoke(abstractaccesslogvalve.java:617)     @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:88)     @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:518)     @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1091)     @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:668)     @ org.apache.tomcat.util.net.nioendpoint$socketprocessor.dorun(nioendpoint.java:1521)     @ org.apache.tomcat.util.net.nioendpoint$socketprocessor.run(nioendpoint.java:1478)     @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145)     @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615)     @ org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread.java:61)     @ java.lang.thread.run(thread.java:745) 

this happening because packaging spring-boot-starter-tomcat (embedded tomcat) dependency war.

basically need in order package deployable war apply war plugin, , set dependency scope providedruntime.

apply plugin: 'war' ... dependencies {     compile("org.springframework.boot:spring-boot-starter-web")     providedruntime("org.springframework.boot:spring-boot-starter-tomcat")     ... } 

for more, see spring boot gradle plugin,

especially section 59.4 packaging executable jar , war files

this link: create deployable war file, maybe useful.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -