Re: Apache Jackrabbit and basic Java interfacing

Stefan Rinner <[email protected]>
Newsgroups gmane.comp.java.helma.general
Message-ID <[email protected]>
On Jul 11, 2007, at 11:56 PM, Joshua Paine wrote:

> I'm building a content management system (isn't everyone?) and it  
> looks
> like using Apache Jackrabbit <http://jackrabbit.apache.org/> for a lot
> of the backend would save a lot of work and give me a pretty powerful
> platform to work from.
>
> Anyone tried making this work with Helma?

yes

> I would happily compose an
> honorary poem to anyone who could share working code.

here's some code - it's quite old (autumn 2005) so be aware of  
potential API changes
this code is basically just a ripoff of http://www.ibm.com/ 
developerworks/java/library/j-jcr/

var repositoryName;
var repositoryPath;
var repositoryConfigFile;

var env = new java.util.Hashtable();
var jackrabbit = Packages.org.apache.jackrabbit;
var repository = null;

env.put( Packages.javax.naming.Context.INITIAL_CONTEXT_FACTORY,  
"org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory" );
env.put( Packages.javax.naming.Context.PROVIDER_URL, "localhost" );
var context = new Packages.javax.naming.InitialContext( env );
try {
	jackrabbit.core.jndi.RegistryHelper.registerRepository( context,  
repositoryName, repositoryConfigFile, repositoryPath, true );
}
catch( e ) {
	writeln( e );
}
repository = context.lookup( repositoryName );

var session = repository.login( new  
Packages.javax.jcr.SimpleCredentials( "userid", new java.lang.String 
( "" ).toCharArray() ) );

var rootNode = session.getRootNode();

var someotherNode = rootNode.getNode( "someNode" );

to be able to use objects returned from Jackrabbit in a more  
comfortable way (and e.g. to be able to skin them) it's best if you  
map them to a Helma Prototype via the class.properties file.
http://helma.org/docs/guide/properties/class.properties/ and http:// 
helma.org/pipermail/helma-user/2001-September/003865.html

> More basic: I'm still trying to get to where I can instantiate a given
> Java class in Helma. I have successfully done built-in Java  
> classes, but
> I haven't been able to instantiate any from JARs yet. I'm sure it's
> because I'm missing some critical and obvious step. I've tried putting
> the jars in lib/ext, and Helma says its adding them to the classpath
> when it starts up, but I don't seem to be accessing anything real via
> Packages.org.apache.jackrabbit...


after putting all necessary jars into lib/ext it should work

stefan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.