JBoss AS6 installation - cannot get repository reference
bwallis42 May 14, 2012 8:15 PMI've downloaded the JBoss AS6 kit for ModeShape 2.8.1 and deployed it by copying the contents of the lib, deploy and conf directories over an existing server/default directory in a clean jboss AS 6.1.0.Final installation.
I've changed the modeshape-config.xml file in modeshape-services.jar to the following:
{code}<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns:mode="http://www.modeshape.org/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0">
<!-- Define the JCR repositories -->
<mode:repositories>
<mode:repository jcr:name="DocumentStore"
mode:source="JPA Store">
<mode:options jcr:primaryType="mode:options">
<mode:option jcr:name="projectNodeTypes" mode:value="true" />
<systemSourceName jcr:primaryType="mode:option"
mode:value="system@JPA Store" />
<queryIndexDirectory jcr:primaryType="mode:option"
mode:value="${jboss.server.data.dir}/modeshape/repositories/store/indexes" />
<mode:option jcr:name="queryIndexesRebuiltSynchronously"
mode:value="false" />
<!-- specifies the strategy (always or ifMissing) used to determine which
query indexes need to be rebuilt when the repository restarts -->
<mode:option jcr:name="rebuildQueryIndexOnStartup"
mode:value="ifMissing" />
</mode:options>
</mode:repository>
</mode:repositories>
<!-- Define the sources used by the repository (or repositories) to store
and access the content -->
<mode:sources jcr:primaryType="nt:unstructured">
<!-- The 'IMR Store' repository is an in-memory source with a single default
workspace (though others could be created, too). -->
<mode:source jcr:name="IMR Store"
mode:classname="org.modeshape.graph.connector.inmemory.InMemoryRepositorySource"
mode:description="The repository for our content"
mode:defaultWorkspaceName="default">
<!-- <mode:predefinedWorkspaceNames>staging </mode:predefinedWorkspaceNames>
<mode:predefinedWorkspaceNames>dev</mode:predefinedWorkspaceNames> -->
</mode:source>
<mode:source jcr:name="JPA Store"
mode:classname="org.modeshape.connector.store.jpa.JpaSource"
mode:dataSourceJndiName="java:jdbc/DocumentStoreDS"
mode:model="Simple"
mode:dialect="org.hibernate.dialect.PostgreSQLDialect"
mode:referentialIntegrityEnforced="true"
mode:largeValueSizeInBytes="10000"
mode:retryLimit="3"
mode:compressData="false"
mode:predefinedWorkspaceNames="default,system"
mode:showSql="false"
mode:autoGenerateSchema="validate"
mode:creatingWorkspacesAllowed="true"
mode:defaultWorkspaceName="default">
</mode:source>
</mode:sources>
<mode:sequencers>
</mode:sequencers>
</configuration>{code}
and also updated the modeshape-jdbc-ds.xml file to reference my repository (not that I'm using jdbc at the moment)
{code}
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>ModeShapeDS</jndi-name>
<connection-url>jdbc:jcr:jndi:jcr/local?repositoryName=DocumentStore</connection-url>
<driver-class>org.modeshape.jdbc.LocalJcrDriver</driver-class>
<user-name>admin</user-name>
<password>admin</password>
<metadata>
<type-mapping>jcrrepo</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
{code}
I have a singleton session bean that trys to get a reference to the repository defined in modeshape-config.xml (DocumentStore) but I always end up with a null pointer.
I had a read of the post at https://community.jboss.org/thread/171222 and tried various forms of URL to lookup the repository but no luck.
{code}
Repository repository=null;
String configUrl = "jndi:jcr/local/DocumentStore"; // Note this URL!
Map<String, String> parameters = Collections.singletonMap("org.modeshape.jcr.URL", configUrl);
for (RepositoryFactory factory : ServiceLoader.load(RepositoryFactory.class)) {
repository = factory.getRepository(parameters);
if (repository != null) break;
}{code}
I also tried the seam injection with the org.jboss.seam.jcr package like so
{code}
@Inject @JcrConfiguration(name="org.modeshape.jcr.URL",
value="jndi:jcr/local?repositoryName=DocumentStore")
Repository repository;{code}
but I assume it probably does the same thing under the covers and I just get a null pointer anyway.
So, what have I missed?
thanks