jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Bauer <peter.ba...@apus.co.at>
Subject Configuration of Jackrabbit 1.4 with Tomcat 5.5
Date Thu, 12 Jun 2008 05:37:36 GMT

Hi all,

i am trying to get Jackrabbit Model 1 Installation on Tomcat 5.5 with PostgreSQL 8.3 to work
for some days no. I appended the current configuration. With this configuration, the custom
servlet JCRServlet can access the Repository from the "javax.jcr.Repository" Attribute of
the ServletContext, login and change the repository content.
Since i found no tutorial or example which uses the ServletContext to get the Repository handle,
im not sure if this is the right/preferred way to do this, but no other method worked for
me.
What i still need to get going is some kind of Repository Browser or Explorer. I installed
the JCR Browser and Day's Eclipse Plugin which connect via RMI, and the JCR Explorer Web Application
which wants to use JNDI. So i have to get either RMI or JNDI to work. With the Day Plugin
i am able to see the repository name when i enter the hostname of the Tomcat Machine, but
Eclipse just hangs for some time when the connection should be established. Same with the
JCR Browser Plugin. Any hints for getting the JCR Explorer (JNDI) to work are welcome.

thx,
Peter

--------------------------------------------------
web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
  -->

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
    <display-name>Jackrabbit JCR Server</display-name>

    <!-- ====================================================================== -->
    <!-- L O G G I N G   S E R V L E T                                          -->
    <!-- ====================================================================== -->
    <servlet>
        <servlet-name>Logging</servlet-name>
        <description>The logging servlet configures the Log4J logging facility.</description>
        <servlet-class>org.apache.jackrabbit.j2ee.LoggingServlet</servlet-class>

        <init-param>
            <param-name>log4j-config</param-name>
            <param-value>/WEB-INF/log4j.xml</param-value>
            <description>initial log4j configuration</description>
        </init-param>

        <load-on-startup>1</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>
        <description>
            Repository servlet that starts the repository and registers it to JNDI ans RMI.
            If you already have the repository registered in this appservers JNDI context,
            or if its accessible via RMI, you do not need to use this servlet.
        </description>
        <servlet-class>org.apache.jackrabbit.j2ee.RepositoryStartupServlet</servlet-class>

        <init-param>
            <param-name>bootstrap-config</param-name>
            <param-value>/WEB-INF/repository/bootstrap.properties</param-value>
            <description>
                Property file that hold the same initialization properties than
                the init-params below. If a parameter is specified in both
                places the one in the bootstrap-config wins.
            </description>
        </init-param>

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

        <init-param>
            <param-name>repository-home</param-name>
	    <param-value>/opt/jackrabbit/repository/home</param-value>
            <description>the repository home</description>
        </init-param>

        <init-param>
            <param-name>repository-name</param-name>
            <param-value>cc.repository</param-value>
            <description>Repository Name under which the repository is registered via
JNDI/RMI</description>
        </init-param>

        <!--
            the following 3 parameters deal with registering the repository to
            a RMI registry. if all parameters are omitted, the repository will
            not be registered.
        -->
        <init-param>
            <param-name>rmi-port</param-name>
            <param-value>1099</param-value>
            <description>
                The RMI port for registering the repository in the RMI Registry.
                If equals 0, the default port is used.
            </description>
        </init-param>
        <init-param>
            <param-name>rmi-host</param-name>
            <param-value>193.1.1.14</param-value>
            <description>
                The RMI host for registering the repository in the RMI Registry.
                If equals "" or missing, the default host is used.
            </description>
        </init-param>
        <!--
        <init-param>
            <param-name>rmi-uri</param-name>
            <param-value></param-value>
            <description>
                The RMI uri for registering the repository in the RMI Registry.
                If missing, the uri is composed using the other rmi parameters
                and will have the format: //{rmi-host}:{rmi-port}/{repository-name}
            </description>
        </init-param>
        -->
        <!--
            JNDI environment variables for creating the initial context
            (all init parameters starting with java.naming.* will be added to the initial
context environment).
        -->
        <init-param>
            <param-name>java.naming.provider.url</param-name>
            <param-value>http://www.apache.org/jackrabbit</param-value>
        </init-param>
        <init-param>
            <param-name>java.naming.factory.initial</param-name>
            <param-value>org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory</param-value>
        </init-param>
        
	<load-on-startup>2</load-on-startup>
    </servlet>
    
    <servlet>
      <servlet-name>JCRServlet</servlet-name>
      <servlet-class>at.apus.cc.webapp.JCRServlet</servlet-class>
      <load-on-startup>4</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.RMIRemoteBindingServlet</servlet-class>
      <load-on-startup>5</load-on-startup>
    </servlet>

    <!-- ====================================================================== -->
    <!-- S E R V L E T   M A P P I N G                                          -->
    <!-- ====================================================================== -->
    <servlet-mapping>
        <servlet-name>RepositoryStartup</servlet-name>
        <url-pattern>/admin/*</url-pattern>
    </servlet-mapping>
    
    <servlet-mapping>
        <servlet-name>JCRServlet</servlet-name>
        <url-pattern>/jcrservlet/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>RMI</servlet-name>
        <url-pattern>/rmi</url-pattern>
    </servlet-mapping>

    <!-- ====================================================================== -->
    <!-- W E L C O M E   F I L E S                                              -->
    <!-- ====================================================================== -->
    <welcome-file-list>
      <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

    <error-page>
        <exception-type>org.apache.jackrabbit.j2ee.JcrApiNotFoundException</exception-type>
        <location>/error/classpath.jsp</location>
    </error-page>

</web-app>

repository.xml:

<?xml version="1.0"?>

<Repository>
	<!-- Database File System (Cluster Configuration) -->
	    
	    <FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
		    <param name="driver" value="org.postgresql.Driver"/>
		    <param name="url" value="jdbc:postgresql://localhost:5432/jcr" />
		    <param name="user" value="jcr" />
		    <param name="password" value="jcr" />
		    <param name="schema" value="postgresql"/>
		    <param name="schemaObjectPrefix" value="J_R_FS_"/>
	    </FileSystem>
	    
	    <Security appName="Jackrabbit">
		    <AccessManager class="org.apache.jackrabbit.core.security.SimpleAccessManager" />
		    <LoginModule class="org.apache.jackrabbit.core.security.SimpleLoginModule">
			    <param name="anonymousId" value="anonymous" />
		    </LoginModule>
	    </Security>
	    <Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="defaultws" />
	    <Workspace name="${wsp.name}">			
			<!-- Database File System and Persistence (Cluster Configuration) -->
			
			<PersistenceManager class="org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager">
				<param name="driver" value="org.postgresql.Driver"/>
				<param name="url" value="jdbc:postgresql://localhost:5432/jcr" />
				<param name="user" value="jcr" />
				<param name="password" value="jcr" />
				<param name="schema" value="postgresql"/>
				<param name="schemaObjectPrefix" value="J_PM_${wsp.name}_" />
				<param name="externalBLOBs" value="false" />
			</PersistenceManager>
			<FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
				<param name="driver" value="org.postgresql.Driver"/>
				<param name="url" value="jdbc:postgresql://localhost:5432/jcr" />
				<param name="user" value="jcr" />
				<param name="password" value="jcr" />
				<param name="schema" value="postgresql"/>
				<param name="schemaObjectPrefix" value="J_FS_${wsp.name}_"/>
			</FileSystem>
		</Workspace>
		<Versioning rootPath="${rep.home}/version">
			    <!-- Database File System and Persistence (Cluster Configuration) -->
			    
			    <FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
				    <param name="driver" value="org.postgresql.Driver"/>
				    <param name="url" value="jdbc:postgresql://localhost:5432/jcr" />
				    <param name="user" value="jcr" />
				    <param name="password" value="jcr" />
				    <param name="schema" value="postgresql"/>
				    <param name="schemaObjectPrefix" value="J_V_FS_"/>
			    </FileSystem>
			    <PersistenceManager class="org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager">
				    <param name="driver" value="org.postgresql.Driver"/>
				    <param name="url" value="jdbc:postgresql://localhost:5432/jcr" />
				    <param name="user" value="jcr" />
				    <param name="password" value="jcr" />
				    <param name="schema" value="postgresql"/>
				    <param name="schemaObjectPrefix" value="J_V_PM_" />
				    <param name="externalBLOBs" value="false" />
			    </PersistenceManager>
		</Versioning>
</Repository> 



JCRServlet.java:

package at.apus.cc.webapp;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.MalformedURLException;
import java.rmi.AlreadyBoundException;
import java.rmi.Naming;
import java.rmi.RemoteException;

import javax.jcr.LoginException;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
import javax.jcr.Workspace;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.jackrabbit.rmi.remote.RemoteRepository;
import org.apache.jackrabbit.rmi.server.RemoteAdapterFactory;
import org.apache.jackrabbit.rmi.server.ServerAdapterFactory;

public class JCRServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	Repository repository_;
	
	@Override
	public void destroy() {
		super.destroy();
	}

	@Override
	public void init(ServletConfig config) throws ServletException {
		super.init(config);
		ServletContext ctx = getServletContext();		
		repository_ = (Repository) ctx.getAttribute("javax.jcr.Repository");		

		try {
			SimpleCredentials credentials = new SimpleCredentials("userid", "".toCharArray());
			repository_.login(credentials);
			Session session = repository_.login(credentials, null);
			Workspace ws = session.getWorkspace();
			Node rn = session.getRootNode();			
			rn.addNode("myfirstnode");			
			rn.save();						
		} catch (LoginException e) {
			e.printStackTrace();
		} catch (RepositoryException e) {
			e.printStackTrace();
		}
	}

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,
IOException {

	}
}


Mime
View raw message