I alter the example "modeshape-examples\modeshape-jdbc-store-example" which I got from github. ModeShape version 4.0.0.Alpha2.
Infinispan's config:
<persistence passivation="false">
<stringKeyedJdbcStore xmlns="urn:infinispan:config:jdbc:6.0"
fetchPersistentState="false"
ignoreModifications="false"
purgeOnStartup="false">
<connectionPool
connectionUrl="jdbc:sqlserver://localhost:1433;databaseName=ModeShape;DB_CLOSE_DELAY=-1"
driverClass="com.microsoft.sqlserver.jdbc.SQLServerDriver"
username="mcis"
password="admin"/>
<stringKeyedTable
prefix="ISPN_STRING_TABLE"
createOnStart="true"
dropOnExit="false">
<idColumn name="ID_COLUMN" type="VARCHAR(255)"/>
<dataColumn name="DATA_COLUMN" type="VARBINARY(MAX)"/>
<timestampColumn name="TIMESTAMP_COLUMN" type="BIGINT"/>
</stringKeyedTable>
</stringKeyedJdbcStore>
</persistence>
It worked for once.
Then :
java.lang.NullPointerException
at org.modeshape.jcr.SystemContent.first(SystemContent.java:880)
at org.modeshape.jcr.SystemContent.first(SystemContent.java:874)
at org.modeshape.jcr.SystemContent.readNodeTypeDefinition(SystemContent.java:766)
at org.modeshape.jcr.SystemContent.readAllNodeTypes(SystemContent.java:737)
......and a lot more......
By tracking down the source code, I find out something goes wrong when SystemContent tries to do this:
SessionCache system;
for (ChildReference ref : nodeType.getChildReferences(system)) {
CachedNode itemDefn = system.getNode(ref);
}
A correct ref should looks like this: jcr:primaryType (key=a7ca237317f1e7/jcr:system/jcr:nodeTypes/nt:base/jcr:primaryType/Name/1)
But when there's a ref goes like: (key=a7ca237317f1e7/jcr:system/jcr:nodeTypes/nt:unstructured//undefined/*)
system.getNode(ref) returns null, then you got a NullPointerException.
You need to make the ID_COLUMN in Infinispan NVARCHAR not VARCHAR, because Unicode support is required. See Re: Modeshape with MS SQL Server 2008 \ 2010 for the similar issue.