3 Replies Latest reply on Sep 25, 2012 12:51 PM by pkutrhari

    Modeshape 2.8.3/Tomcat 7 JNDI issue

    pkutrhari

      Hi - I am trying to create a jndi resource for a filesystem repository in Tomcat 7. My server.xml has -

      <Resource auth="Container" configFile="/<somefolder>/configuration.xml" factory="org.modeshape.jcr.JndiRepositoryFactory" name="jcr/abc" repositoryName="ABC Repository Source" type="javax.jcr.Repository"/>

       

      The configuration.xml looks like -

      <?xml version="1.0" encoding="UTF-8"?>

      <configuration xmlns:mode="http://www.modeshape.org/1.0"

                xmlns:jcr="http://www.jcp.org/jcr/1.0">

                <mode:repositories>

                          <mode:repository jcr:name="abc" mode:source="abc">

                                    <mode:options jcr:primaryType="mode:options">

                                              <jaasLoginConfigName jcr:primaryType="mode:option"

                                                        mode:value="modeshape-jcr" />

                                    </mode:options>

                          </mode:repository>

                </mode:repositories>

                <mode:sources jcr:primaryType="nt:unstructured">

                          <mode:source jcr:name="abc"

                                    mode:classname="org.modeshape.connector.filesystem.FileSystemSource"

                                    mode:retryLimit="3" mode:workspaceRootPath="../abc"

                                    mode:defaultWorkspaceName="abc" mode:updatesAllowed="true">

                          </mode:source>

                </mode:sources>

                <mode:mimeTypeDetectors>

                          <mode:mimeTypeDetector jcr:name="Detector"

                                    mode:description="Standard extension-based MIME type detector" />

                </mode:mimeTypeDetectors>

      </configuration>

       

       

      I don't have any app deployed in this tomcat instace yet. I'm getting the following exception on startup -

       

      WARNING: Unexpected exception resolving reference

      java.lang.NullPointerException

                at org.modeshape.common.i18n.ClasspathLocalizationRepository.getLocalizationBundle(ClasspathLocalizationRepository.java:75)

                at org.modeshape.common.i18n.I18n.localize(I18n.java:243)

                at org.modeshape.common.i18n.I18n.rawText(I18n.java:400)

                at org.modeshape.common.i18n.I18n.text(I18n.java:432)

                at org.modeshape.common.util.log.JdkLoggerImpl.info(JdkLoggerImpl.java:125)

                at org.modeshape.jcr.JndiRepositoryFactory.initializeEngine(JndiRepositoryFactory.java:82)

                at org.modeshape.jcr.JndiRepositoryFactory.getObjectInstance(JndiRepositoryFactory.java:155)

                at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:143)

                at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)

                at org.apache.naming.NamingContext.lookup(NamingContext.java:843)

                at org.apache.naming.NamingContext.lookup(NamingContext.java:154)

                at org.apache.naming.NamingContextBindingsEnumeration.nextElementInternal(NamingContextBindingsEnumeration.java:119)

                at org.apache.naming.NamingContextBindingsEnumeration.next(NamingContextBindingsEnumeration.java:73)

                at org.apache.naming.NamingContextBindingsEnumeration.next(NamingContextBindingsEnumeration.java:36)

                at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:140)

                at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:147)

                at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:112)

                at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.lifecycleEvent(GlobalResourcesLifecycleListener.java:84)

                at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)

                at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)

                at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:401)

                at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:346)

                at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:725)

                at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

                at org.apache.catalina.startup.Catalina.start(Catalina.java:684)

                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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)

                at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:451)

      Sep 24, 2012 5:35:49 PM org.apache.catalina.mbeans.GlobalResourcesLifecycleListener createMBeans

      SEVERE: Exception processing Global JNDI Resources

      javax.naming.NamingException

                at org.apache.naming.NamingContext.lookup(NamingContext.java:860)

                at org.apache.naming.NamingContext.lookup(NamingContext.java:154)

                at org.apache.naming.NamingContextBindingsEnumeration.nextElementInternal(NamingContextBindingsEnumeration.java:119)

                at org.apache.naming.NamingContextBindingsEnumeration.next(NamingContextBindingsEnumeration.java:73)

                at org.apache.naming.NamingContextBindingsEnumeration.next(NamingContextBindingsEnumeration.java:36)

                at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:140)

                at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:147)

                at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:112)

                at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.lifecycleEvent(GlobalResourcesLifecycleListener.java:84)

                at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)

                at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)

                at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:401)

                at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:346)

                at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:725)

                at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

                at org.apache.catalina.startup.Catalina.start(Catalina.java:684)

                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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)

                at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:451)

      Sep 24, 2012 5:35:49 PM org.apache.catalina.core.StandardService startInternal

       

      Is Modeshape expecting a default localization file somewhere in the classpath?

       

      Thanks.

      Praveen

        • 1. Re: Modeshape 2.8.3/Tomcat 7 JNDI issue
          hchiorean

          Hi Praveen,

           

          Looking at the stacktrace, the NPE can only be caused if this.getClass().getClassLoader(), where "this" is an instance of ClasspathLocalizationRepository from modeshape-common. I assume you have both modeshape-common.jar and modeshape-jcr.jar in your web application's /lib.

          So this looks like a class loading issue to me. Do you have all of ModeShape's jars in your webapp (at least modeshape-common, modeshape-jcr-api, modeshape-jcr, modeshape-graph and modeshape-repository) ?

           

          As a side note, do you define the JNDI resource in your web.xml file ? (for more information see: https://docs.jboss.org/author/display/MODE28/Using+ModeShape)

          • 2. Re: Modeshape 2.8.3/Tomcat 7 JNDI issue
            pkutrhari

            Hi Horia - I am configuring Modeshape at the app server level so that the web apps don't have to deal with any of this (all they have to do is use the jndi to get the repo context). I have the Resource set up in the tomcat server.xml as per the documentation. I haven't deployed the web app yet (where I have the resource info in the web.xml and context.xml).

             

            I have all the modeshape jars that you mentioned in the tomcat classpath.

             

            Thanks.

            Praveen

            • 3. Re: Modeshape 2.8.3/Tomcat 7 JNDI issue
              pkutrhari

              I was able to resolve this by putting just one jar file modeshape-jcr-2.8.3.Final-jar-with-dependencies in the Tomcat classpath.

               

              Thanks.

              Praveen