You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Martin Pietsch <mp...@gmx.de> on 2008/07/31 01:36:12 UTC

Webdav access using the same repository as the applicationContext bean

Hi,

i am using Appfuse (Spring 2.5) and tried to set up a Jackrabbit
repository which should be available as a bean in the
applicationContext. I used springmodules and the following configuration
in the applicationContext.xml:

<bean id="repository"
class="org.springmodules.jcr.jackrabbit.RepositoryFactoryBean">
<property name="configuration" value="/WEB-INF/repository.xml" />
<property name="homeDir" value="/tmp/repo"/> </bean>

<bean id="jcrSessionFactory"
class="org.springmodules.jcr.jackrabbit.JackrabbitSessionFactory">
<property name="repository" ref="repository" /> </bean>

<bean id="jcrTemplate" class="org.springmodules.jcr.JcrTemplate">
<property name="sessionFactory" ref="jcrSessionFactory" /> <property
name="allowCreate" value="true" /> </bean>

Exactly the same repository should be available via WebDAV to store
files on it. Thus I tried to set up the Jackrabbit WebDavServlet
(web.xml) without success. It just gives me an empty page but no error
messages / exceptions. Thus it seems not to be connected to the
repository. I think my repository.xml is OK so far because I am able to
store data in the repository via the bean.

Has anyone configuration suggestions for that purpose? On the web I've
found examples for Spring integration as well as for WebDAV access, but
not for both of them working together.

I know the description of my error is vague, but I think my concern is
clear.

Find below the relevant part of the web.xml.

Thanks in advance,

Martin



<!-- W E B D A V  S E R V L E T -->

<servlet> <servlet-name>Webdav</servlet-name>

<servlet-class>org.apache.jackrabbit.j2ee.SimpleWebdavServlet</servlet-
class>

<init-param> <param-name>resource-path-prefix</param-name>
<param-value>/repository</param-value> </init-param>

<init-param> <param-name>missing-auth-mapping</param-name>
<param-value>anonymous:anonymous</param-value> </init-param>

<init-param> <param-name>resource-config</param-name>
<param-value>/WEB-INF/webdav-config.xml</param-value> </init-param>
<load-on-startup>4</load-on-startup> </servlet>

<!-- R E P O S I T O R Y S T A R T U P  S E R V L E T -->

<servlet> <servlet-name>RepositoryStartup</servlet-name>

<servlet-class>org.apache.jackrabbit.j2ee.RepositoryStartupServlet</
servlet-class>

<init-param> <param-name>repository-config</param-name>
<param-value>/WEB-INF/repository.xml</param-value> </init-param>

<load-on-startup>2</load-on-startup> </servlet>

<!-- R E P O S I T O R Y S E R V L E T -->

<servlet> <servlet-name>Repository</servlet-name>

<servlet-class>org.apache.jackrabbit.j2ee.RepositoryAccessServlet</
servlet-class>

<init-param> <param-name>repository.context.attribute.name</param-name>
<param-value>javax.jcr.Repository</param-value> </init-param>

<load-on-startup>3</load-on-startup> </servlet>

<!-- W E B D A V  S E R V E R  S E R V L E T -->

<servlet> <servlet-name>JCRWebdavServer</servlet-name>

<servlet-class>org.apache.jackrabbit.j2ee.JCRWebdavServerServlet</
servlet-class>

<init-param> <param-name>resource-path-prefix</param-name>
<param-value>/server</param-value> </init-param>
<load-on-startup>5</load-on-startup> </servlet>

<!-- R M I B I N D I N G S E R V L E T -->

<servlet> <servlet-name>RMI</servlet-name>

<servlet-class>org.apache.jackrabbit.servlet.remote.RemoteBindingServlet
</servlet-class> </servlet>

<servlet-mapping> <servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern> </servlet-mapping>

<servlet-mapping> <servlet-name>xfire</servlet-name>
<url-pattern>/services/*</url-pattern> </servlet-mapping>

<!-- S E R V L E T M A P P I N G -->

<servlet-mapping> <servlet-name>Webdav</servlet-name>
<url-pattern>/repository/*</url-pattern> </servlet-mapping>
<servlet-mapping> <servlet-name>JCRWebdavServer</servlet-name>
<url-pattern>/server/*</url-pattern> </servlet-mapping>
<servlet-mapping> <servlet-name>RMI</servlet-name>
<url-pattern>/rmi</url-pattern> </servlet-mapping>








Re: Webdav access using the same repository as the applicationContext bean [solved]

Posted by Martin Pietsch <mp...@gmx.de>.
Hi Alex,

your suggestion hit the mark -- Thank you!

Again for everybody else: The problem was that there were two instances 
of the repository (one for the springmodules WebDAVServlet and one for 
the Spring Bean and I was not able to configure the WebDAVServlet to use 
the Spring Bean defined in the applicationContext.xml. Using RMI for 
that connection seemed to be overkill since I do not want to share the 
repository across different machines. Nor JNDI worked since I was not 
able to register the  Spring bean via JNDI from within the 
applicationContext.xml.

Solution:

With the following lines in the Spring's applicationContext.xml you can 
register the repository as a servlet context attribute (which was that 
little piece of information I needed ;-)):

-----

<bean 
class="org.springframework.web.context.support.ServletContextAttributeExporter">
     <property name="attributes">
         <map>
             <entry key="javax.jcr.Repository" value-ref="repository"/>
         </map>
     </property>
</bean>

-----

Then you can get rid of (need not to define) the 
RepositoryStartupServlet since you already started the servlet in the 
Spring's applicationContext.xml. The RepositoryAccessServlet will then 
look for the "javax.jcr.Repository" attribute in the servlet context 
(and find it). The rest of the configuration remains unchanged.

-----

<servlet>
     <servlet-name>Repository</servlet-name>
     <servlet-class>
       org.apache.jackrabbit.j2ee.RepositoryAccessServlet
     </servlet-class>

     <init-param>
       <param-name>repository.context.attribute.name</param-name>
       <param-value>javax.jcr.Repository</param-value>
       <description>
         If this is set, the RepositoryAccessServlet expects a
         Repository in the ServletContext attribute having this name.
         This allows servlets of this module to be used with
         repositories intialized by the jackrabbit-jcr-servlet module
         utilities.
       </description>
     </init-param>

     <load-on-startup>3</load-on-startup>
</servlet>

-----

Thanks for your help, Alex!

Best,
Martin

Alexander Klimetschek schrieb:
> What you probably want is to have the repository (of which there
> should be only one instance in your server) handled by Spring and
> provide access to it via the webdav servlets. The "repository" bean
> gives you a single repository already. Now you should turn of the
> RepositoryStartupServlet, which tries to start another repository (all
> the servlets in your current config have no knowledge about the Spring
> config) with the same settings (repository.xml and home directory). To
> access the repository created by Spring, you can put the the
> repository instance returned from the RepositoryFactoryBean
> "repository" into the servlet context attribute
> "javax.jcr.Repository". This way the RepositoryAccessServlet finds
> them (you can configure the name of the context attribute in the
> servlet config for this servlet).
> 
> Regards,
> Alex
> 
> 
> On Thu, Jul 31, 2008 at 1:36 AM, Martin Pietsch <mp...@gmx.de> wrote:
>> Hi,
>>
>> i am using Appfuse (Spring 2.5) and tried to set up a Jackrabbit
>> repository which should be available as a bean in the
>> applicationContext. I used springmodules and the following configuration
>> in the applicationContext.xml:
>>
>> <bean id="repository"
>> class="org.springmodules.jcr.jackrabbit.RepositoryFactoryBean">
>> <property name="configuration" value="/WEB-INF/repository.xml" />
>> <property name="homeDir" value="/tmp/repo"/> </bean>
>>
>> <bean id="jcrSessionFactory"
>> class="org.springmodules.jcr.jackrabbit.JackrabbitSessionFactory">
>> <property name="repository" ref="repository" /> </bean>
>>
>> <bean id="jcrTemplate" class="org.springmodules.jcr.JcrTemplate">
>> <property name="sessionFactory" ref="jcrSessionFactory" /> <property
>> name="allowCreate" value="true" /> </bean>
>>
>> Exactly the same repository should be available via WebDAV to store
>> files on it. Thus I tried to set up the Jackrabbit WebDavServlet
>> (web.xml) without success. It just gives me an empty page but no error
>> messages / exceptions. Thus it seems not to be connected to the
>> repository. I think my repository.xml is OK so far because I am able to
>> store data in the repository via the bean.
>>
>> Has anyone configuration suggestions for that purpose? On the web I've
>> found examples for Spring integration as well as for WebDAV access, but
>> not for both of them working together.
>>
>> I know the description of my error is vague, but I think my concern is
>> clear.
>>
>> Find below the relevant part of the web.xml.
>>
>> Thanks in advance,
>>
>> Martin
[...]


Re: Webdav access using the same repository as the applicationContext bean

Posted by Alexander Klimetschek <ak...@day.com>.
What you probably want is to have the repository (of which there
should be only one instance in your server) handled by Spring and
provide access to it via the webdav servlets. The "repository" bean
gives you a single repository already. Now you should turn of the
RepositoryStartupServlet, which tries to start another repository (all
the servlets in your current config have no knowledge about the Spring
config) with the same settings (repository.xml and home directory). To
access the repository created by Spring, you can put the the
repository instance returned from the RepositoryFactoryBean
"repository" into the servlet context attribute
"javax.jcr.Repository". This way the RepositoryAccessServlet finds
them (you can configure the name of the context attribute in the
servlet config for this servlet).

Regards,
Alex


On Thu, Jul 31, 2008 at 1:36 AM, Martin Pietsch <mp...@gmx.de> wrote:
> Hi,
>
> i am using Appfuse (Spring 2.5) and tried to set up a Jackrabbit
> repository which should be available as a bean in the
> applicationContext. I used springmodules and the following configuration
> in the applicationContext.xml:
>
> <bean id="repository"
> class="org.springmodules.jcr.jackrabbit.RepositoryFactoryBean">
> <property name="configuration" value="/WEB-INF/repository.xml" />
> <property name="homeDir" value="/tmp/repo"/> </bean>
>
> <bean id="jcrSessionFactory"
> class="org.springmodules.jcr.jackrabbit.JackrabbitSessionFactory">
> <property name="repository" ref="repository" /> </bean>
>
> <bean id="jcrTemplate" class="org.springmodules.jcr.JcrTemplate">
> <property name="sessionFactory" ref="jcrSessionFactory" /> <property
> name="allowCreate" value="true" /> </bean>
>
> Exactly the same repository should be available via WebDAV to store
> files on it. Thus I tried to set up the Jackrabbit WebDavServlet
> (web.xml) without success. It just gives me an empty page but no error
> messages / exceptions. Thus it seems not to be connected to the
> repository. I think my repository.xml is OK so far because I am able to
> store data in the repository via the bean.
>
> Has anyone configuration suggestions for that purpose? On the web I've
> found examples for Spring integration as well as for WebDAV access, but
> not for both of them working together.
>
> I know the description of my error is vague, but I think my concern is
> clear.
>
> Find below the relevant part of the web.xml.
>
> Thanks in advance,
>
> Martin
>
>
>
> <!-- W E B D A V  S E R V L E T -->
>
> <servlet> <servlet-name>Webdav</servlet-name>
>
> <servlet-class>org.apache.jackrabbit.j2ee.SimpleWebdavServlet</servlet-
> class>
>
> <init-param> <param-name>resource-path-prefix</param-name>
> <param-value>/repository</param-value> </init-param>
>
> <init-param> <param-name>missing-auth-mapping</param-name>
> <param-value>anonymous:anonymous</param-value> </init-param>
>
> <init-param> <param-name>resource-config</param-name>
> <param-value>/WEB-INF/webdav-config.xml</param-value> </init-param>
> <load-on-startup>4</load-on-startup> </servlet>
>
> <!-- R E P O S I T O R Y S T A R T U P  S E R V L E T -->
>
> <servlet> <servlet-name>RepositoryStartup</servlet-name>
>
> <servlet-class>org.apache.jackrabbit.j2ee.RepositoryStartupServlet</
> servlet-class>
>
> <init-param> <param-name>repository-config</param-name>
> <param-value>/WEB-INF/repository.xml</param-value> </init-param>
>
> <load-on-startup>2</load-on-startup> </servlet>
>
> <!-- R E P O S I T O R Y S E R V L E T -->
>
> <servlet> <servlet-name>Repository</servlet-name>
>
> <servlet-class>org.apache.jackrabbit.j2ee.RepositoryAccessServlet</
> servlet-class>
>
> <init-param> <param-name>repository.context.attribute.name</param-name>
> <param-value>javax.jcr.Repository</param-value> </init-param>
>
> <load-on-startup>3</load-on-startup> </servlet>
>
> <!-- W E B D A V  S E R V E R  S E R V L E T -->
>
> <servlet> <servlet-name>JCRWebdavServer</servlet-name>
>
> <servlet-class>org.apache.jackrabbit.j2ee.JCRWebdavServerServlet</
> servlet-class>
>
> <init-param> <param-name>resource-path-prefix</param-name>
> <param-value>/server</param-value> </init-param>
> <load-on-startup>5</load-on-startup> </servlet>
>
> <!-- R M I B I N D I N G S E R V L E T -->
>
> <servlet> <servlet-name>RMI</servlet-name>
>
> <servlet-class>org.apache.jackrabbit.servlet.remote.RemoteBindingServlet
> </servlet-class> </servlet>
>
> <servlet-mapping> <servlet-name>dwr-invoker</servlet-name>
> <url-pattern>/dwr/*</url-pattern> </servlet-mapping>
>
> <servlet-mapping> <servlet-name>xfire</servlet-name>
> <url-pattern>/services/*</url-pattern> </servlet-mapping>
>
> <!-- S E R V L E T M A P P I N G -->
>
> <servlet-mapping> <servlet-name>Webdav</servlet-name>
> <url-pattern>/repository/*</url-pattern> </servlet-mapping>
> <servlet-mapping> <servlet-name>JCRWebdavServer</servlet-name>
> <url-pattern>/server/*</url-pattern> </servlet-mapping>
> <servlet-mapping> <servlet-name>RMI</servlet-name>
> <url-pattern>/rmi</url-pattern> </servlet-mapping>
>
>
>
>
>
>
>
>



-- 
Alexander Klimetschek
alexander.klimetschek@day.com