1 2 Previous Next 22 Replies Latest reply on Oct 25, 2007 9:52 AM by jaikiran pai

    Overriding universal classloader, JBoss 4.2.1GA

    Janne Mattila Newbie

      How can I override JBoss's universal classloader, and use my own jars from my war's WEB-INF/lib, instead of ones in server/xxx/lib?

      I have hibernate jars inside my war. I know one option is to remove them from war, but assume for now that I need to be able to select hibernate version freely and include it in the war. I tried to change the classloading to use the files from war based on

      http://wiki.jboss.org/wiki/Wiki.jsp?page=ClassLoadingConfiguration

      so, I added this jboss-web.xml in WAR's WEB-INF:

      <jboss-web>
      <class-loading java2ClassLoadingCompliance="false">
      <loader-repository>
      com.example.loaderrepository:loader=somename-webapp.war
      <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
      </loader-repository>
      </class-loading>
      </jboss-web>

      but I did not notice any effect - JBoss still seems to load the hibernate jars that are bundled in the server installation.

      I do not know if the wiki page is relevant for 4.2.1GA, since it starts with prior to version 3.2... There is some mention of 4.0 using Servlet classloader (instead of universal classloader?), but I remember reading somewhere that this was once again changed in 4.1? Confusing. What should I do with 4.2.1GA?

      Simply, what do I need to configure so that I can use my own libraries from the war file in 4.2.1GA?

        • 1. Re: Overriding universal classloader, JBoss 4.2.1GA
          Martin Schmitz Newbie

          Hi jimpo,

          I have the same problem with my own implementation of LogFactory. I am using 4.2.1GA too. With 4.0.2 everything works fine.

          I also have tried whyt you mentioned before, but it do not work.

          Sometimes I think about switching to another appserver.

          I hope there is a solution for this.

          Bye
          Martin

          • 2. Re: Overriding universal classloader, JBoss 4.2.1GA
            Janne Mattila Newbie

            *bump*

            This should be a common question, no?

            • 3. Re: Overriding universal classloader, JBoss 4.2.1GA
              jaikiran pai Master

              Worked for me. This is what i tried (as a sample try):

              - JBoss 4.2.1 ships with Hibernate-3.2.4SP1 and Quartz-1.5.2 (these jars are present in the server/< serverName>/lib folder of JBoss).

              - I created a simple web-application, with just one JSP which was meant to print out the Hibernate and Quartz versions. In the lib folder of my web-application, i placed Hibernate-3.1.2 and Quartz-1.4.5 version jars. Also, i placed a jboss-web.xml in the WEB-INF folder of my application, with the following contents:

              <jboss-web>
               <context-root>/</context-root>
               <class-loading java2ClassLoadingCompliance="false">
               <loader-repository>
               org.myapp:loader=hibernatetestclassloader
               <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
               </loader-repository>
               </class-loading>
              </jboss-web>


              - The jsp contents are simple:

              <%@ page import="
              java.util.*,
              javax.naming.*,
              javax.sql.*,
              java.sql.*,
              org.hibernate.cfg.*,
              org.quartz.helpers.*"
              
              
              %>
              
              
              <html>
              <body>
              <%
               try {
              
              
               System.out.println("Hibernate version: " + Environment.VERSION);
               String args[] = new String[] {"abc","xyz"};
               System.out.println("Quartz version: ");
               VersionPrinter.main(args);
               } catch(Exception e) {
               e.printStackTrace();
               }
              
              %>
              </body>
              </html>
              


              - Started JBoss and accessed the jsp. Here's the output:

              2007-10-09 19:22:52,833 INFO [STDOUT] Hibernate version: 3.1.2
              2007-10-09 19:22:52,833 INFO [STDOUT] Quartz version:
              2007-10-09 19:22:52,833 INFO [STDOUT] Quartz version: 1.4.5


              This shows that the libraries of my application(and not the ones shipped by JBoss) are being used.

              P.S: Hibernate and Quartz libraries were considered as an example for simplicity.


              • 4. Re: Overriding universal classloader, JBoss 4.2.1GA
                Janne Mattila Newbie

                I guess you are right, after modifying the jboss-web.xml the original classloading the original classcastexception disappeared. However I am still getting classloading -related problems:

                1. I got 'org.apache.commons.logging.impl.Log4JLogger' cannot be found exceptions. I have log4j.jar and commons-logging.jar inside my war. To try a quick solution, I removed them from my war, and this seemed to solve the problem.

                2. XML parsers. Now I am getting

                11:41:59,296 ERROR [FacesConfigRuleSet] Cannot configure DescriptionTextRule for pattern 'faces-config/managed-bean/description'
                java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
                 at javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown Source)
                 at org.apache.commons.digester.NodeCreateRule.<init>(NodeCreateRule.java:363)
                 at com.sun.faces.config.rules.DescriptionTextRule.<init>(DescriptionTextRule.java:42)
                 at com.sun.faces.config.rules.FacesConfigRuleSet.addFeatureRules(FacesConfigRuleSet.java:376)
                 at com.sun.faces.config.rules.FacesConfigRuleSet.addRuleInstances(FacesConfigRuleSet.java:200)
                 at org.apache.commons.digester.Digester.addRuleSet(Digester.java:1663)
                 at com.sun.faces.config.ConfigureListener.digester(ConfigureListener.java:973)
                 at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:270)
                 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3854)
                 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4359)
                 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:761)
                 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:741)
                 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)
                 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:585)
                 at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
                 at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
                 at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                 at org.apache.catalina.core.StandardContext.init(StandardContext.java:5310)
                 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:585)
                 at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
                 at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
                 at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                 at org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(TomcatDeployer.java:301)
                 at org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.java:104)
                 at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:375)
                 at org.jboss.web.WebModule.startModule(WebModule.java:83)
                 at org.jboss.web.WebModule.startService(WebModule.java:61)
                 at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
                 at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
                 at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                 at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                 at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                 at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                 at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                 at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
                 at $Proxy0.start(Unknown Source)
                 at org.jboss.system.ServiceController.start(ServiceController.java:417)
                 at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                 at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                 at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                 at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                 at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                 at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                 at $Proxy45.start(Unknown Source)
                 at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:466)
                 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:585)
                 at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                 at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                 at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
                 at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                 at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
                 at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
                 at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
                 at org.jboss.ws.integration.jboss42.DeployerInterceptor.start(DeployerInterceptor.java:93)
                 at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
                 at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
                 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:659)
                 at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                 at $Proxy46.start(Unknown Source)
                 at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
                 at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
                 at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
                 at sun.reflect.GeneratedMethodAccessor18.invoke(Unknown Source)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                 at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                 at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
                 at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                 at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
                 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:659)
                 at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                 at $Proxy9.deploy(Unknown Source)
                 at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
                 at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
                 at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
                 at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:336)
                 at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
                 at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
                 at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                 at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                 at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                 at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                 at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                 at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
                 at $Proxy0.start(Unknown Source)
                 at org.jboss.system.ServiceController.start(ServiceController.java:417)
                 at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                 at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                 at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                 at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                 at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                 at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                 at $Proxy4.start(Unknown Source)
                 at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
                 at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
                 at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
                 at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
                 at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)
                 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:585)
                 at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                 at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                 at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
                 at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                 at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
                 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:659)
                 at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                 at $Proxy5.deploy(Unknown Source)
                 at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
                 at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
                 at org.jboss.Main.boot(Main.java:200)
                 at org.jboss.Main$1.run(Main.java:508)
                 at java.lang.Thread.run(Thread.java:595)
                


                I don't have xerces*.jar in my war, or in my JBoss folders as far as I can tell. I have jdom.jar, dom4j.jar ja xml-apis.jar in my war. I have tried removing the jars from JBoss lib, etc. solutions.

                What is going on, and how could I fix this issue?

                • 5. Re: Overriding universal classloader, JBoss 4.2.1GA
                  jaikiran pai Master

                   

                  java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl


                  Have a look at http://wiki.jboss.org/wiki/Wiki.jsp?page=ClassCastExceptions, specifically the jmx-console method mentioned over there. That will tell you which jar(and how many jars) is being picked up for this class.


                  • 6. Re: Overriding universal classloader, JBoss 4.2.1GA
                    Janne Mattila Newbie

                     

                    "jaikiran" wrote:
                    java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl


                    Have a look at http://wiki.jboss.org/wiki/Wiki.jsp?page=ClassCastExceptions, specifically the jmx-console method mentioned over there. That will tell you which jar(and how many jars) is being picked up for this class.


                    Hmmm. I try it for org.apache.xerces.jaxp.SAXParserFactoryImpl, and get

                    org.apache.xerces.jaxp.SAXParserFactoryImpl Information
                    Repository cache version:
                    org.apache.xerces.jaxp.SAXParserFactoryImpl(d73c3c).ClassLoader=null
                    ++++Null CodeSource
                    Implemented Interfaces:

                    ### Instance0 via UCL: org.jboss.system.server.NoAnnotationURLClassLoader@5d173

                    Null CodeSource? Does this mean the class exists or not?

                    The war I am trying to deploy to JBoss deploys fine on a standalone Tomcat.

                    • 7. Re: Overriding universal classloader, JBoss 4.2.1GA
                      jaikiran pai Master

                       

                      I try it for org.apache.xerces.jaxp.SAXParserFactoryImpl


                      The exception was thrown for org.apache.xerces.jaxp.DocumentBuilderFactoryImpl. So you should be trying the jmx-console method for this class and not org.apache.xerces.jaxp.SAXParserFactoryImpl

                      • 8. Re: Overriding universal classloader, JBoss 4.2.1GA
                        Janne Mattila Newbie

                         

                        "jimpo" wrote:
                        "jaikiran" wrote:
                        java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl


                        Have a look at http://wiki.jboss.org/wiki/Wiki.jsp?page=ClassCastExceptions, specifically the jmx-console method mentioned over there. That will tell you which jar(and how many jars) is being picked up for this class.


                        Hmmm. I try it for org.apache.xerces.jaxp.SAXParserFactoryImpl, and get

                        org.apache.xerces.jaxp.SAXParserFactoryImpl Information
                        Repository cache version:
                        org.apache.xerces.jaxp.SAXParserFactoryImpl(d73c3c).ClassLoader=null
                        ++++Null CodeSource
                        Implemented Interfaces:

                        ### Instance0 via UCL: org.jboss.system.server.NoAnnotationURLClassLoader@5d173

                        Null CodeSource? Does this mean the class exists or not?

                        The war I am trying to deploy to JBoss deploys fine on a standalone Tomcat.


                        I see you latest comment, but the same error for DocumentBuilderFactorImpl:

                        org.apache.xerces.jaxp.DocumentBuilderFactoryImpl Information
                        Repository cache version:
                        org.apache.xerces.jaxp.DocumentBuilderFactoryImpl(12fa617).ClassLoader=null
                        ++++Null CodeSource
                        Implemented Interfaces:

                        ### Instance0 via UCL: org.jboss.system.server.NoAnnotationURLClassLoader@5d173


                        I guess it means the class is loaded, since searching for com.foo.BarClass results in different message: "Not loaded in repository cache".

                        But where is this class loaded from?

                        ----------------------------------------

                        I am guessing the problem is something along the lines:
                        - JBoss starts up and loads it's own xmls using xerces parser
                        - This causes some JRE-wide setting that makes all DocumentBuilderFactories use xerces parser (not sure about what goes on behind the scenes here)
                        - my application is loaded, it starts to initialize Spring (spring.jar inside my war)
                        - Spring tries to load the xml files for configuration
                        - Because of the setting in the seconds step, it tries to use xerces parser
                        - My war classloader does not see the xerces parser (why?)
                        - OR my war classloader sees the xerces parser but for some reason the code expects a different type....ok, I'm a bit lost here...

                        Question regarding the jboss-web.xml "tweak" - my war classloader still sees the universal classloader classes, if those classes do not exist in the war, right? It has to, otherwise I would have to for example include servlet API.jar in my war?

                        Thousand thanks fot the fast replies :) I have to go to a meeting now but will be back to fighting with this problem later.

                        • 9. Re: Overriding universal classloader, JBoss 4.2.1GA
                          jaikiran pai Master

                          The xerces jars are present in the lib/endorsed folder of JBoss. These will be picked up by JBoss when its booting. The current version of xerces that is being shipped with JBoss is XercesJ-2.7.1.

                          Does it work when you add a xercesImpl.jar (appropriate version) in your application's WEB-INF/lib folder? At this point, i am just guessing the possible reasons for the ClasscastException and am not yet sure what is causing this.

                          • 10. Re: Overriding universal classloader, JBoss 4.2.1GA
                            jaikiran pai Master

                            I believe, you are sure that there are no other xerces related jars in the classpath, because at this point i dont see why a ClassCastException will be thrown.

                            • 11. Re: Overriding universal classloader, JBoss 4.2.1GA
                              Janne Mattila Newbie

                              I guess I found out the culprit for the xerces problems. My WEB-INF/lib had xml-apis.jar. Once I removed that, I stopped getting the xerces related problems.

                              But no such luck. Once I got rid of that problem, my application could start initializing itself, and this is where the hibernate -related classcastproblem once again happens.

                              14:24:58,640 ERROR [[/]] Exception sending context initialized event to listener instance of class com.xyz.listener.StartupListener
                              org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.interceptor.TransactionAttributeSou
                              rceAdvisor': Cannot create inner bean '(inner bean)' of type [org.springframework.transaction.interceptor.TransactionInterceptor] while setting bean proper
                              ty 'transactionInterceptor'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Can
                              not resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.
                              BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [applicationContext-dao.xml]: Cannot resolve refer
                              ence to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationE
                              xception: Error creating bean with name 'entityManagerFactory' defined in class path resource [applicationContext-dao.xml]: Invocation of init method faile
                              d; nested exception is java.lang.ClassCastException: org.hibernate.search.event.FullTextIndexEventListener
                              Caused by:
                              org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Cannot resolve reference to bean 'transactionManager
                              ' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with n
                              ame 'transactionManager' defined in class path resource [applicationContext-dao.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting
                               bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityMa
                              nagerFactory' defined in class path resource [applicationContext-dao.xml]: Invocation of init method failed; nested exception is java.lang.ClassCastExcepti
                              on: org.hibernate.search.event.FullTextIndexEventListener
                              Caused by:
                              org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [applicationCont
                              ext-dao.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springfra
                              mework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [applicationContext-dao.xml
                              ]: Invocation of init method failed; nested exception is java.lang.ClassCastException: org.hibernate.search.event.FullTextIndexEventListener
                              Caused by:
                              org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [applicationCo
                              ntext-dao.xml]: Invocation of init method failed; nested exception is java.lang.ClassCastException: org.hibernate.search.event.FullTextIndexEventListener
                              Caused by:
                              java.lang.ClassCastException: org.hibernate.search.event.FullTextIndexEventListener
                               at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:856)
                               at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:730)
                               at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:127)
                               at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:
                              218)
                               at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:251)
                               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1201)
                               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1171)
                               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425)
                               at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
                               at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
                               at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
                               at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
                               at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:261)
                               at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:109)
                               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1099)
                               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:861)
                               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:421)
                               at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
                               at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
                               at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
                               at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
                               at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:261)
                               at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:109)
                               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1099)
                               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:861)
                               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:421)
                               at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:215)
                               at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:127)
                               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1099)
                               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:861)
                               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:421)
                               at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
                               at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
                               at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
                               at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
                               at org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:87)
                               at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:96)
                               at org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.findCandidateAdvisors(AnnotationAwareAspectJAutoProxyCreator.j
                              ava:83)
                               at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:83)
                               at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:66
                              )
                               at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:296)
                               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableB
                              eanFactory.java:312)
                               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1180)
                               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425)
                               at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
                               at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
                               at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
                               at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
                               at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:733)
                               at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:511)
                               at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:337)
                               at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244)
                               at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187)
                               at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
                               at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3854)
                               at org.apache.catalina.core.StandardContext.start(StandardContext.java:4359)
                               at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:761)
                               at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:741)
                               at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)
                               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:585)
                               at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
                               at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
                               at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                               at org.apache.catalina.core.StandardContext.init(StandardContext.java:5310)
                               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:585)
                               at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
                               at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
                               at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                               at org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(TomcatDeployer.java:301)
                               at org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.java:104)
                               at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:375)
                               at org.jboss.web.WebModule.startModule(WebModule.java:83)
                               at org.jboss.web.WebModule.startService(WebModule.java:61)
                               at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
                               at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
                               at sun.reflect.GeneratedMethodAccessor133.invoke(Unknown Source)
                               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                               at java.lang.reflect.Method.invoke(Method.java:585)
                               at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                               at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                               at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                               at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                               at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                               at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
                               at $Proxy0.start(Unknown Source)
                               at org.jboss.system.ServiceController.start(ServiceController.java:417)
                               at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
                               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                               at java.lang.reflect.Method.invoke(Method.java:585)
                               at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                               at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                               at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                               at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                               at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                               at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                               at $Proxy45.start(Unknown Source)
                               at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:466)
                               at sun.reflect.GeneratedMethodAccessor95.invoke(Unknown Source)
                               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                               at java.lang.reflect.Method.invoke(Method.java:585)
                               at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                               at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                               at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
                               at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                               at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
                               at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
                               at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
                               at org.jboss.ws.integration.jboss42.DeployerInterceptor.start(DeployerInterceptor.java:93)
                               at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
                               at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
                               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:659)
                               at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                               at $Proxy46.start(Unknown Source)
                               at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
                               at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
                               at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
                               at sun.reflect.GeneratedMethodAccessor18.invoke(Unknown Source)
                               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                               at java.lang.reflect.Method.invoke(Method.java:585)
                               at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                               at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                               at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
                               at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                               at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
                               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:659)
                               at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                               at $Proxy9.deploy(Unknown Source)
                               at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
                               at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:610)
                               at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
                               at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
                               at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
                              14:24:59,281 ERROR [StandardContext] Error listenerStart
                              14:24:59,281 ERROR [StandardContext] Context [] startup failed due to previous errors
                              14:24:59,281 INFO [[/]] Closing Spring root WebApplicationContext


                              Although I have verified using the JSP-version-printing method that a JSP page loads the correct hibernate version (!= JBoss hibernate version), it seems that the initialization part loads up wrong classes still. I don't know why this is. Does the server startup process not use the classloading settings from jboss-web.xml?

                              I guess you can reproduce this by setting up a Spring application that initializes some hibernate -related beans in it's config.xml during application startup. I can't really think of a simpler way.

                              • 12. Re: Overriding universal classloader, JBoss 4.2.1GA
                                Janne Mattila Newbie

                                BY THE WAY,

                                I just tested the same app with JBoss 4.0.3 SP1 and everything works. No problems, at all. For me it seems that the java2ParentDelegation trick works for 4.0 as expected, and for 4.2 it for some reason does not work during the startup. Frustrating, that there is no documentation of this (at least easily found).

                                So it definately seems that the classloading scheme and how you can affect it with jboss-web.xml has changed from 4.0 to 4.2.

                                Now I just need to try to dig up the information about the differences between 4.0 and 4.2 to see if I can use 4.0 instead. No more fighting with 4.2, thankyouverymuch...

                                Thanks jaikiran for all the help

                                • 13. Re: Overriding universal classloader, JBoss 4.2.1GA
                                  jaikiran pai Master

                                   

                                  Caused by:
                                  java.lang.ClassCastException: org.hibernate.search.event.FullTextIndexEventListener


                                  I remember seeing this specific class, running into ClassCastException, in quite a number of posts. And incidentally, all those posts seem to complain that the same application works fine on 4.0.x and starts throwing exceptions on 4.2.x.

                                  I looked for this class in the hibernate jars and found that this specific class is located in the hibernate-annotations.jar. This jar is located in the server/< serverName>/lib folder. I *think* i am some what understanding what the problem might be. I believe, you do not have this hibernate-annotations.jar in the WEB-INF/lib folder. I would recommend that you include this hibernate-annotations.jar in the WEB-INF/lib folder of your application. At this point, i cant say which version of hibernate-annotations.jar should be included in your lib folder. It will depend on the version of hibernate your application is using. Currently JBoss-4.2.x ships with Version: 3.2.1.GA of this jar.

                                  If including the (appropriate) version of hibernate-annotations.jar works for you (i.e. the classcast for FullTextIndexEventListener goes away) and in case you run into some other hibernate related classcast exception, then even include the (appropriate) version of hibernate-entitymanager.jar (again i found this jar in the server/< serverName>/lib folder) in the WEB-INF/lib folder of your app.

                                  Hopefully, if things go well and you are able to get the application working in 4.2.1, then i guess i will be able to explain the reason why you are running into this exception.

                                  I guess you can reproduce this by setting up a Spring application that initializes some hibernate -related beans in it's config.xml during application startup.


                                  I would love to try this out on my setup, but at this point i dont have a ready Spring application (actually i never have worked on Spring) which can be used. Well, i could download a sample application from somewhere but presently with other things at hand, its really hard. Maybe if you have a small app with can reproduce this problem, you can just mail it to jai_forums2005 AT yahoo DOT co DOT in



                                  • 14. Re: Overriding universal classloader, JBoss 4.2.1GA
                                    Janne Mattila Newbie

                                     

                                    "jaikiran" wrote:

                                    I looked for this class in the hibernate jars and found that this specific class is located in the hibernate-annotations.jar. This jar is located in the server/< serverName>/lib folder. I *think* i am some what understanding what the problem might be. I believe, you do not have this hibernate-annotations.jar in the WEB-INF/lib folder. I would recommend that you include this hibernate-annotations.jar in the WEB-INF/lib folder of your application. At this point, i cant say which version of hibernate-annotations.jar should be included in your lib folder. It will depend on the version of hibernate your application is using. Currently JBoss-4.2.x ships with Version: 3.2.1.GA of this jar.


                                    Actually I did have hibernate-annotations (3.3.0.GA) in my WEB-INF/lib.

                                    I'll try to find some time to hack up a simple demo app that uses Spring and has this problem with 4.2.1. My current app has tens of jars and has too much confusing details that are not relevant to this problem. I'm afraid I will not have time to do this right away, but I'll try not to leave it hanging. I'm curious to what is going on (other than "4.2.1 classloading is weird").

                                    1 2 Previous Next