ModeShape 2.7 and Tomcat 7 - JNDI
stedud.1 Jan 2, 2012 1:05 PMHi,
I had a look at several threads about this, but I'm still not able to use ModeShape on Tomcat with JNDI.
My configuration is the following :
- Tomcat 7
- Modeshape 2.7
- context.xml:
<Resource name="jcr/local"
auth="Container"
type="org.modeshape.jcr.api.Repositories"
factory="org.modeshape.jcr.JndiRepositoryFactory"
configFile="C:\Users\stedud\Documents\eclipse_workspace\JCR_ModeShape\WebContent\configRepository.xml"/>
- web.xml:
<resource-env-ref>
<description>ModeShape Engine</description>
<resource-env-ref-name>jcr/local</resource-env-ref-name>
<resource-env-ref-type>org.modeshape.jcr.api.Repositories</resource-env-ref-type>
</resource-env-ref>
- configRepository.xml
<?xml version="1.0" encoding="UTF-8"?>
- configRepository.xml
<configuration xmlns:mode="http://www.modeshape.org/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0">
<mode:repositories>
<mode:repository jcr:name="Documents" mode:source="Documents">
<mode:options jcr:primaryType="mode:options">
<jaasLoginConfigName jcr:primaryType="mode:option" mode:value="modeshape-jcr"/>
</mode:options>
</mode:repository>
</mode:repositories>
<mode:sources jcr:primaryType="nt:unstructured">
<mode:source jcr:name="Documents"
mode:classname="org.modeshape.graph.connector.inmemory.InMemoryRepositorySource"
mode:retryLimit="3" mode:defaultWorkspaceName="workspace1">
<predefinedWorkspaceNames>system</predefinedWorkspaceNames>
</mode:source>
</mode:sources>
<mode:mimeTypeDetectors>
<mode:mimeTypeDetector jcr:name="Detector"
mode:description="Standard extension-based MIME type detector"/>
</mode:mimeTypeDetectors>
</configuration>
- Retrieving the repository:
String configUrl = "jndi:jcr/local?repositoryName=Documents";
Repository repository = null;
Map<String, String> parameters = Collections.singletonMap("org.modeshape.jcr.URL", configUrl);
for (RepositoryFactory factory : ServiceLoader.load(RepositoryFactory.class)) {
try
{
repository = factory.getRepository(parameters);
}
catch (RepositoryException e)
{ e.printStackTrace(); }
if (repository != null) { break; }
}
System.out.println("Repository : " + repository);
I'm using Eclipse to develop, here is the message I have in the log :
**********************************
(...)
2 janv. 2012 19:02:17 org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
2 janv. 2012 19:02:17 org.apache.catalina.startup.Catalina start
INFO: Server startup in 8249 ms
2 janv. 2012 19:02:17 com.vaadin.terminal.gwt.server.AbstractApplicationServlet checkProductionMode
(...)
19:02:19.056 ["http-bio-9090"-exec-4] DEBUG o.modeshape.jcr.JcrRepositoryFactory - Trying to load ModeShape JCR Repository with parameters: {org.modeshape.jcr.URL=jndi:jcr/local?repositoryName=Documents}
19:02:19.064 ["http-bio-9090"-exec-4] DEBUG o.modeshape.jcr.JcrRepositoryFactory - Could not load engine from URL: jndi:jcr/local?repositoryName=Documents
Repository : null
**********************************
I tried more or less all the configurations I found in ModeShape forums (including JCR 1.0 mode) : nothing to do, my repository is always null.
Thanks per advance to anybody who could help me finding where I'm wrong...
Regards,
//Stéphane