3 Replies Latest reply on Jul 6, 2010 12:02 PM by van.halbert

    Access ModeShape repository via JNDI with JBoss

    jbrelet

      Hello,

       

      I'm currently trying to configure a ModeShape JCR repository on JBoss AS 5.1.

      I would like to have my repository accessed as a JNDI resource by web application. The ModeShape documentation describes the way to do it with Tomcat, using a context resource (in conf/context.xml) pointing to the JndiRepositoryFactory.

      I tried to do it the same way with JBoss, using JBoss Web context.xml to declare a JNDI resource, as described here : http://www.ncvvo.hr/docs/jndi-resources-howto.html

       

      I tried different formats, but I keep getting parsing errors at deploy time :

      11:15:56,687 ERROR [JBossContextConfig] XML error parsing: WEB-INF/context.xml
      org.jboss.xb.binding.JBossXBException: Failed to parse source: Resource not found as a child of Context in unordered_sequence: Listener* Parameters* Valve* SessionCookie? Loader? Manager? Realm? attributes? InstanceListener* Resources?

       

      And I can't find good examples about how to configure it properly...

      Any help is welcome.

        • 1. Re: Access ModeShape repository via JNDI with JBoss
          bcarothers

          I may be way off-base here, but the error message looks like you either have the wrong config setting in the right file, or the right config setting in the wrong file.  Could you please attach your config file?  Also, what's the path to the file from JBOSS_HOME?

           

          Thanks!

          • 2. Re: Access ModeShape repository via JNDI with JBoss
            van.halbert

            The reference above, http://www.ncvvo.hr/docs/jndi-resources-howto.html talks about putting the context.xml into the META-INF directory.  However, this;  http://community.jboss.org/wiki/UsingContextDotXML says to place it into the WEB-INF directory.    When I placed the context.xml in the META-INF directory, with the web-xml and jboss-web.xml changes, there we no parsing errors, but the jndi name was never bound.  I couldn't see it in the logs or using JNDIView.    However, when I placed it in the WEB-INF directory, I got the same parsing error.   I'm still searching for the answer for this type of deployment.

            • 3. Re: Access ModeShape repository via JNDI with JBoss
              van.halbert

              Here's snippit from the jboss-beans.xml that performs jndi binding:

               

              <deployment xmlns="urn:jboss:bean-deployer:2.0">

               

                 <interceptor xmlns="urn:jboss:aop-beans:1.0" name="JndiAspect" class="org.jboss.aop.microcontainer.aspects.jndi.JndiIntroduction">

                    <property name="env">

                         <map class="java.util.Properties"  keyClass="java.lang.String" valueClass="java.lang.String">

                            <entry><key>java.naming.factory.initial</key><value>org.jnp.interfaces.NamingContextFactory</value></entry>

                         </map>

                    </property>

                 </interceptor>

               

                 <introduction xmlns="urn:jboss:aop-beans:1.0" class="@org.jboss.aop.microcontainer.aspects.jndi.JndiBinding">

                    <interfaces>org.jboss.kernel.spi.dependency.KernelControllerContextAware</interfaces>

                 </introduction>

               

                 <bind xmlns="urn:jboss:aop-beans:1.0" pointcut="execution(* $instanceof{org.jboss.kernel.spi.dependency.KernelControllerContextAware}->$implements{org.jboss.kernel.spi.dependency.KernelControllerContextAware}(..))">

                    <interceptor-ref name="JndiAspect"/>

                 </bind>

               

                <bean name="<yourname>"  class="<yourclass>" >

                      <annotation>@org.jboss.aop.microcontainer.aspects.jndi.JndiBinding(name="<jndiname>")</annotation>

                  </bean>