I've got my servlet working now, without resorting to using a Context
element inside the server.xml. I found that putting the Context in
$TOMCAT_HOME/conf/Catalina/localhost/jackrabbit_config_test.xml works
fine.
Context
Resource name=jcr/model1Repository
auth=Container
type=javax.jcr.Repository
factory=org.apache.jackrabbit.core.jndi.BindableRepositoryFactory
configFilePath=conf/repository_model1.xml
repHomeDir=shared/jackrabbit_model1 /
ResourceLink
name=sharedJCRRepository global=jcr/model2Repository
type=javax.jcr.Repository /
Environment name=testNum value=10
type=java.lang.Integer override=false/
/Context
And then in my web app, I have these lines:
resource-ref
descriptionJackrabbit Model 1 Repository/description
res-ref-namejcr/model1Repository/res-ref-name
res-typejavax.jcr.Repository/res-type
res-authContainer/res-auth
/resource-ref
resource-env-ref
descriptionJackrabbit Model 2 Repository/description
resource-env-ref-namesharedJCRRepository/resource-env-ref-
name
resource-env-ref-typejavax.jcr.Repository/resource-env-
ref-type
/resource-env-ref
resource-ref
descriptionTest Number/description
res-ref-nametestNum/res-ref-name
res-typejava.lang.Integer/res-type
res-authContainer/res-auth
/resource-ref
I also finally realized that the ResourceLink's name attribute
can't be the same as the the global attribute. That took care of the
null pointer I was getting trying to access that object.
So, while this works acceptably (the context information for the
webapp is not included in server.xml), I would *much* prefer to use
the WEB-INF/context.xml the Tomcat docs say I can (the fourth bullet
on this page - http://tomcat.apache.org/tomcat-5.5-doc/config/
context.html). If someone could explain why that doesn't work, I'd be
really appreciative. Is this possibly a known issue?
Thanks,
Mark
On Feb 13, 2006, at 9:40 PM, Mark Slater wrote:
I've solved part of the problem... or at least made it less
complicated (I hope). The ClassNotFound exception mentioned at the
bottom is due to the jackrabbit jars being located in server/lib as
opposed to common/lib. I'd placed them in server lib on the advice
of someone more familiar with jackrabbit than I. I'd assumed that,
as long as the jar was included in the web app, this would not be a
problem; obviously that was incorrect. So after putting jackrabbit
and its dependencies in common/lib, here's what I've got:
If the context for web-app only resources and environment variables
(jcr/model1Repository and testNum in the code below) are placed in
HostContext in $TOMCAT_HOME/conf/server.xml, the web app is
able to find them.
If they are placed in the web-app's WEB-INF/context.xml, an
exception is thrown (javax.naming.NamingException: Cannot create
resource instance).
As the latter is definitely the preferred option (by tomcat
documentation and myself), I'd really like to get that to work.
I've also confirmed that I get the same errors on a newly
downloaded and configured Tomcat 5.5.15.
Mark
On Feb 13, 2006, at 6:23 PM, Mark Slater wrote:
I'm running Tomcat 5.5.9 with JVM 1.5.0_05-83 on MacOS X 10.4.4.
I'm trying to build an example webapp that shows the configuration
for two Jackrabbit resources: one configured as an embedded
resource for that web app and another configured as a shared
resource for the entire host. I've tried to define the resources
in a variety of places and haven't been able to get any of them to
work.
My context files are defined like this
$TOMCAT_HOME/conf/context.xml:
Context
WatchedResourceWEB-INF/web.xml/WatchedResource
/Context
webapp/WEB-INF/context.xml:
Context docBase=jackrabbit_config_test reloadable=false
Resource name=jcr/model1Repository
auth=Container
type=javax.jcr.Repository
factory=org.apache.jackrabbit.core.jndi.BindableRepositoryFactory
configFilePath=conf/repository_model1.xml
repHomeDir=shared/jackrabbit_model1 /
Environment name=testNum value=10
type=java.lang.Integer override=false/
/Context
I've got the following setup in server.xml:
GlobalNamingResources
...
Resource name=jcr/model2Repository
auth=Container
type=javax.jcr.Repository
factory=org.apache.jackrabbit.core.jndi.BindableRepositoryFactory
configFilePath=conf/repository_model2.xml
repHomeDir=shared/jackrabbit_model2 /
/GlobalNamingResources
And in my web.xml, I've got the following references:
web-app
...
resource-ref
descriptionJackrabbit Model 1 Repository/description
res-ref-namejcr/model1Repository/res-ref-name
res-typejavax.jcr.Repository/res-type
res-authContainer/res-auth
/resource-ref
resource-env-ref