6 Replies Latest reply on Nov 1, 2012 1:14 AM by Bond Chan

    Jboss 5.1.0: java.lang.LinkageError: loader constraint violation for class javax.sql.DataSource

    Bond Chan Novice

      Hi,

       

      have read quite a lot about this error, the reason is 1) more than one jar containing this class have been include into the classpath, 2)include the jar twice or more,

      but in my case, this class is jdk class, and I have search no this class have been found under my application.

       

      any clue would be very helpful.

       

      exception stack:

       

       

      2012-10-31 14:09:58,319 WARN  [org.jboss.detailed.classloader.ClassLoaderManager] (http-0.0.0.0-8080-1:) Unexpected error during load of:javax.sql.DataSource

      java.lang.LinkageError: loader constraint violation: loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) previously initiated loading for a different type with name "javax/sql/DataSource"

                at java.lang.ClassLoader.defineClass1(Native Method)

                at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)

                at java.lang.ClassLoader.defineClass(ClassLoader.java:615)

                at org.jboss.classloader.spi.base.BaseClassLoader.access$200(BaseClassLoader.java:67)

                at org.jboss.classloader.spi.base.BaseClassLoader$2.run(BaseClassLoader.java:633)

                at org.jboss.classloader.spi.base.BaseClassLoader$2.run(BaseClassLoader.java:592)

                at java.security.AccessController.doPrivileged(Native Method)

                at org.jboss.classloader.spi.base.BaseClassLoader.loadClassLocally(BaseClassLoader.java:591)

                at org.jboss.classloader.spi.base.BaseClassLoader.loadClassLocally(BaseClassLoader.java:568)

                at org.jboss.classloader.spi.base.BaseDelegateLoader.loadClass(BaseDelegateLoader.java:135)

                at org.jboss.classloader.spi.filter.FilteredDelegateLoader.loadClass(FilteredDelegateLoader.java:131)

                at org.jboss.classloader.spi.base.ClassLoadingTask$ThreadTask.run(ClassLoadingTask.java:455)

                at org.jboss.classloader.spi.base.ClassLoaderManager.nextTask(ClassLoaderManager.java:267)

                at org.jboss.classloader.spi.base.ClassLoaderManager.process(ClassLoaderManager.java:166)

                at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:287)

                at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:1163)

                at org.jboss.classloader.spi.base.BaseClassLoader.loadClassFromDomain(BaseClassLoader.java:862)

                at org.jboss.classloader.spi.base.BaseClassLoader.doLoadClass(BaseClassLoader.java:502)

                at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:447)

                at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

                at com.lombardrisk.webgui.dwr.ajax_search.UmbrellaNettingFundsSearch.getBranchesByAgreementId(UmbrellaNettingFundsSearch.java:199)

                at com.lombardrisk.webgui.dwr.ajax_search.UmbrellaNettingFundsSearch.buildConditionOfPrinAndCpty(UmbrellaNettingFundsSearch.java:177)

                at com.lombardrisk.webgui.dwr.ajax_search.UmbrellaNettingFundsSearch.getFunds(UmbrellaNettingFundsSearch.java:58)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                at java.lang.reflect.Method.invoke(Method.java:597)

                at org.directwebremoting.impl.ExecuteAjaxFilter.doFilter(ExecuteAjaxFilter.java:34)

                at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:428)

                at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:431)

                at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:283)

                at org.directwebremoting.servlet.PlainCallHandler.handle(PlainCallHandler.java:52)

                at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:101)

                at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:146)

                at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)

                at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

                at com.lombardrisk.webgui.filter.ValidRequestFilter.doFilter(ValidRequestFilter.java:41)

                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

                at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)

                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

                at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:183)

                at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)

                at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:95)

                at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)

                at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)

                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

                at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)

                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

                at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.internalProcess(ActiveRequestResponseCacheValve.java:74)

                at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:47)

                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)

                at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)

                at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:599)

                at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:451)

                at java.lang.Thread.run(Thread.java:662)

        • 3. Re: Jboss 5.1.0: java.lang.LinkageError: loader constraint violation for class javax.sql.DataSource
          Bond Chan Novice

          If do have this class somewhere in the app, as none search result about the conflicts on this class, so should not be bring from jboss, rather should be by me. but

          1) I have checked all jar files in the deployed app no this class found

          2) there is another occurence of using this class(javax.sql.DataSource) in another class is OK, which is under the same package, see the code below:

           

          having problems in classA:

           


          static {


          try{



          log.info("inited ds");



          ds = (new F3Services()).getTxDataSource();



          osr = OrganisationBeanFactory.createOrgService();



          log.info("ds:" + ds.toString());




          c = ds.getConnection();



          log.info("connection ="+ c.toString());



          log.info("end of static block");


          }catch(Exception e){



          log.error("get datasource failed");


          }

          }

           

          have no problem in classB which is under same package as ClassA

           

           


          static {


          try {



          log.info("ds: initing");



          ds = (new F3Services()).getTxDataSource();



          log.info("ds: inited");


          } catch (Exception e) {



          log.error("error in initialize of data source");



          log.error(e);


          }

          }
          • 4. Re: Jboss 5.1.0: java.lang.LinkageError: loader constraint violation for class javax.sql.DataSource
            Bond Chan Novice

            error log:

             

            ClassB:StatementSetSearch

            ClassA:UmbrellaNettingFundsSearch

             

            10:26:41,638 INFO  [UmbrellaNettingFundsSearch] ds:org.jboss.resource.adapter.jdbc.WrapperDataSource@88e718

            10:26:41,638 WARN  [ClassLoaderManager] Unexpected error during load of:javax.sql.DataSource

            java.lang.LinkageError: loader constraint violation: loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) previously initiated loading for a different type with name "java

            x/sql/DataSource"

                    at java.lang.ClassLoader.defineClass1(Native Method)

                    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)

                    at java.lang.ClassLoader.defineClass(ClassLoader.java:615)

                    at org.jboss.classloader.spi.base.BaseClassLoader.access$200(BaseClassLoader.java:67)

                    at org.jboss.classloader.spi.base.BaseClassLoader$2.run(BaseClassLoader.java:633)

                    at org.jboss.classloader.spi.base.BaseClassLoader$2.run(BaseClassLoader.java:592)

                    at java.security.AccessController.doPrivileged(Native Method)

                    at org.jboss.classloader.spi.base.BaseClassLoader.loadClassLocally(BaseClassLoader.java:591)

                    at org.jboss.classloader.spi.base.BaseClassLoader.loadClassLocally(BaseClassLoader.java:568)

                    at org.jboss.classloader.spi.base.BaseDelegateLoader.loadClass(BaseDelegateLoader.java:135)

                    at org.jboss.classloader.spi.filter.FilteredDelegateLoader.loadClass(FilteredDelegateLoader.java:131)

                    at org.jboss.classloader.spi.base.ClassLoadingTask$ThreadTask.run(ClassLoadingTask.java:455)

                    at org.jboss.classloader.spi.base.ClassLoaderManager.nextTask(ClassLoaderManager.java:267)

                    at org.jboss.classloader.spi.base.ClassLoaderManager.process(ClassLoaderManager.java:166)

                    at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:287)

                    at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:1163)

                    at org.jboss.classloader.spi.base.BaseClassLoader.loadClassFromDomain(BaseClassLoader.java:862)

                    at org.jboss.classloader.spi.base.BaseClassLoader.doLoadClass(BaseClassLoader.java:502)

                    at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:447)

                    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

                    at com.lombardrisk.webgui.dwr.ajax_search.UmbrellaNettingFundsSearch.<clinit>(UmbrellaNettingFundsSearch.java:45)

                    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

                    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

                    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

                    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

                    at java.lang.Class.newInstance0(Class.java:355)

                    at java.lang.Class.newInstance(Class.java:308)

                    at org.directwebremoting.create.NewCreator.getInstance(NewCreator.java:65)

                    at org.directwebremoting.impl.DefaultCreatorManager.addCreator(DefaultCreatorManager.java:146)

                    at org.directwebremoting.impl.DefaultCreatorManager.addCreator(DefaultCreatorManager.java:100)

                    at org.directwebremoting.impl.DwrXmlConfigurator.loadCreate(DwrXmlConfigurator.java:274)

                    at org.directwebremoting.impl.DwrXmlConfigurator.loadAllows(DwrXmlConfigurator.java:224)

                    at org.directwebremoting.impl.DwrXmlConfigurator.configure(DwrXmlConfigurator.java:170)

                    at org.directwebremoting.impl.ContainerUtil.configureFromDefaultDwrXml(ContainerUtil.java:264)

                    at org.directwebremoting.impl.ContainerUtil.configureContainerFully(ContainerUtil.java:421)

                    at org.directwebremoting.servlet.DwrServlet.init(DwrServlet.java:79)

                    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1048)

                    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:950)

                    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4122)

                    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4417)

                    at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:313)

                    at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:145)

                    at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:461)

                    at org.jboss.web.deployers.WebModule.startModule(WebModule.java:122)

                    at org.jboss.web.deployers.WebModule.start(WebModule.java:97)

                    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                    at java.lang.reflect.Method.invoke(Method.java:597)

                    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)

                    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)

                    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)

                    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)

                    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)

                    at org.jboss.system.server.jmx.LazyMBeanServer.invoke(LazyMBeanServer.java:283)

                    at org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206)

                    at $Proxy38.start(Unknown Source)

                    at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:42)

                    at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:37)

                    at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)

                    at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)

                    at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)

                    at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)

                    at org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:297)

                    at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1652)

                    at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:938)

                    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)

                    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:988)

                    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:826)

                    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:556)

                    at org.jboss.system.ServiceController.doChange(ServiceController.java:688)

                    at org.jboss.system.ServiceController.start(ServiceController.java:460)

                    at org.jboss.system.deployers.ServiceDeployer.start(ServiceDeployer.java:163)

                    at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:99)

                    at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:46)

                    at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)

                    at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:55)

                    at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:179)

                    at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1454)

                    at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1172)

                    at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1193)

                    at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1113)

                    at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)

                    at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1652)

                    at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:938)

                    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)

                    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:988)

                    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:826)

                    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:556)

                    at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:789)

                    at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:699)

                    at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)

                    at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)

                    at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)

                    at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:403)

                    at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)

                    at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1652)

                    at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:938)

                    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)

                    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:988)

                    at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:778)

                    at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:543)

                    at org.jboss.system.server.profileservice.repository.AbstractProfileService.registerProfile(AbstractProfileService.java:308)

                    at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:256)

                    at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)

                    at org.jboss.Main.boot(Main.java:221)

                    at org.jboss.Main$1.run(Main.java:556)

                    at java.lang.Thread.run(Thread.java:662)

            10:26:41,685 INFO  [StatementSetSearch] ds: initing

            10:26:41,685 INFO  [StatementSetSearch] ds: inited

            • 5. Re: Jboss 5.1.0: java.lang.LinkageError: loader constraint violation for class javax.sql.DataSource
              Stephen Coy Master

              Please list all the jars in your WEB-INF/lib directory. I'm assuming this is just a WAR deployment.

              • 6. Re: Jboss 5.1.0: java.lang.LinkageError: loader constraint violation for class javax.sql.DataSource
                Bond Chan Novice

                Thanks !!!

                 

                this issue be solved

                 

                there do have another jar(jdbc2_0-stdext.jar) containing this class, and is bring to app by us.

                 

                class B is OK because the statment  con = ds.getConnection is call in another  X.jar, whereas class A is called inside it self Y.war,  and this jdbc2_0-stdext.jar is package in Y.war

                 

                 

                Thanks!!!