Jpa repository with jboss as 6 final
riboriori Jul 1, 2011 8:26 AMHi all, i'm new to modeshape, and i'm experimenting it with jboss as 6 (i've downloaded the jboss as kit).
I have a seam 3 application packaged as an ear under jboss 6 as.
Once i've downloaded modeshape, i've configured it by modifying modeshape-config.xml, located under
$JBOSS_HOME/server/$PROFILE/deploy/modeshape-services.jar/modeshape-config.xml.
My repository definition:
<mode:repository jcr:name="JPA Repository" mode:source="JPA Store">
<mode:options jcr:primaryType="mode:options">
<mode:option jcr:name="systemSourceName" mode:value="dev@JPA Store"/>
<mode:option jcr:name="jaasLoginConfigName" mode:value="modeshape-jcr"/>
<mode:option jcr:name="queryExecutionEnabled" mode:value="true"/>
<mode:option jcr:name="projectNodeTypes" mode:value="true"/>
<mode:option jcr:name="jaasLoginConfigName" mode:value="modeshape"/>
<mode:option jcr:name="anonymousUserRoles" mode:value="" />
<mode:initialContent mode:workspaces="dev" mode:applyToNewWorkspaces="true" mode:content="modeshape-initial-content.xml"/>
</mode:options>
</mode:repository>
I dont use a datasource, i use all parameters connection on repository deinition. Follows my source:
<mode:source jcr:name="JPA Store"
mode:classname="org.modeshape.connector.store.jpa.JpaSource"
mode:description="The database store for our content"
mode:defaultWorkspaceName="default"
mode:showSql="true"
mode:username="MODESHAPE"
mode:password="modeshape"
mode:dialect="org.hibernate.dialect.Oracle10gDialect"
mode:url="jdbc:oracle:thin:@localhost:1521:XE"
mode:maximumConnectionsInPool="15"
mode:minimumConnectionsInPool="1"
mode:driverClassloaderName="oracle.jdbc.driver.OracleDriver"
mode:autoGenerateSchema="validate"/>
I use oracle XE.
In my seam 3 ear packaged application, in a controller i use following code:
JcrConfiguration config = new JcrConfiguration();
try {
URL url = ModeShapeExample.class.getClassLoader().getResource("JPA_modeshape-config.xml");
config.loadFrom(url);
} catch (SAXException e) {
//System.err.println("Failed to read the configuration file" + e.getMessage());
e.printStackTrace();
} catch (IOException e) {
//System.err.println("Failed to load the configuration file" + e.getMessage());
e.printStackTrace();
}
catch(Exception e){
e.printStackTrace();
}
// Create and start the engine ...
JcrEngine engine = config.build();
if (engine.getProblems().hasErrors()) {
System.err.println("Problems starting the engine.");
System.err.println(engine.getProblems());
System.exit(-1);
}
// Start the engine
engine.start();
Repository repository = null;
Session session = null;
try {
// Get the repository
repository = engine.getRepository("JPA Repository");
}
catch(RepositoryException e){
e.printStackTRace();
}
The problem is in the code line:
repository = engine.getRepository("JPA Repository");
It throws a NPE.
If indeed i use a FileSystem repository all works fine. The problem appears when i get a jpa based repository.
The schema and database tables i use, are generated by the batch script (for test i use windows) supplied by modeshape team.
Can anyone help me please? i want use modeshape also on database based repositories.
Best regards.