Wild Rabbits: A Question about Jackrabbit and Wildfly
arenger Jul 29, 2014 9:08 AMHey Everyone, I promise I have scoured this forum and others -- for days -- and I'm out of ideas. I think I'm close to getting this working, and I would be very grateful for any suggestions. My goal is to get Jackrabbit deployed within Wildfly 8.1.0.Final using an Oracle DB on the backside. I have successfully deployed jackrabbit-jca-2.8.0.rar, but cannot get my simple webapp to connect to it. It seems like a simple JNDI "wiring" problem, but I don't know, of course. Shown below are the exact steps I've taken and the error I receive.
Starting with a fresh wildfly-8.1.0.Final.tar.gz (md5 46caf74201245742a99f8a3eaac7e647), I added the jcr module. Here's where I put it, and the contents of the module file:
$ pwd
/media/homespace/wildfly-8.1.0.Final/modules
$ find javax -type f
javax/jcr/main/jcr-2.0.jar
javax/jcr/main/module.xml
$ cat javax/jcr/main/module.xml
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="javax.jcr">
<resources>
<resource-root path="jcr-2.0.jar"/>
</resources>
<dependencies>
<module name="javax.transaction.api" export="true"/>
</dependencies>
</module>
$
I then added a module for ojdbc:
$ find com -type f
com/oracle/db/main/ojdbc6.jar
com/oracle/db/main/module.xml
$ cat com/oracle/db/main/module.xml
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.oracle.db">
<resources>
<resource-root path="ojdbc6.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
$
I used jboss-cli to register ojdbc as a core module:
[standalone@localhost:9990 /] /subsystem=datasources/jdbc-driver=oracle:add(driver-name=oracle,driver-module-name=com.oracle.db,driver-xa-datasource-class-name=oracle.jdbc.xa.client.OracleXADataSource)
{"outcome" => "success"}
[standalone@localhost:9990 /]
I then added an admin user and made the following modifications to standalone/configuration/standalone.xml via the html console/ui (to ensure up-to-date syntax, etc). First, I added a new datasource and tested it. All good. Here's the subsystem configuration:
<subsystem xmlns="urn:jboss:domain:datasources:2.0">
<datasources>
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
<datasource jta="false" jndi-name="java:/jdbc/DocumentStoreDS" pool-name="DocumentStoreDS" enabled="true" use-ccm="false">
<connection-url>jdbc:oracle:thin:@10.0.0.5:1521:xe</connection-url>
<driver-class>oracle.jdbc.OracleDriver</driver-class>
<driver>oracle</driver>
<security>
<user-name>rabbit</user-name>
<password>rabbit</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name="oracle" module="com.oracle.db">
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
I then disabled JCA validation:
<subsystem xmlns="urn:jboss:domain:jca:2.0">
<archive-validation enabled="false" fail-on-error="true" fail-on-wa
<bean-validation enabled="true"/>
...
I then added the resource adapter:
<subsystem xmlns="urn:jboss:domain:resource-adapters:2.0">
<resource-adapters>
<resource-adapter id="jackrabbit-jca-2.8.0.rar">
<archive>
jackrabbit-jca-2.8.0.rar
</archive>
<transaction-support>XATransaction</transaction-support>
<connection-definitions>
<connection-definition class-name="org.apache.jackrabbit.jca.JCAManagedConnectionFactory" jndi-name="java:/jca/DocumentStore" enabled="true" pool-name="RabbitAdapter">
<config-property name="ConfigFile">
/media/homespace/field/repository.xml
</config-property>
<config-property name="HomeDir">
/media/homespace/field
</config-property>
<security>
<application/>
</security>
<validation>
<background-validation>false</background-validation>
</validation>
</connection-definition>
</connection-definitions>
</resource-adapter>
</resource-adapters>
</subsystem>
I've attached a copy of my repository.xml file. I had to make the same modifications to jackrabbit-jca-2.8.0.rar, as described in the helpful post by Brian Wallis. That is, I removed the two logging jars, and added the dependencies line to MANIFEST.MF. At this point if I deploy jackrabbit-jca-2.8.0.rar, it complains about being unable to find the oracle driver. After wrestling with that for a bit I gave up and just put the ojdbc6.jar inside the rar file to make it happy. I know that's a hack but I'll come back to that later. My main question is about deploying a simple webapp that uses the adapter. With the ojdbc6 jar thrown in there, jackrabbit-jca-2.8.0.rar now deploys fine, connects to my oracle database, and creates all the tables and such without error.
Here's the web.xml for my simple webapp, dubbed conejo:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<resource-env-ref>
<description>Content Repository</description>
<resource-env-ref-name>jcr/repository</resource-env-ref-name>
<resource-env-ref-type>javax.jcr.Repository</resource-env-ref-type>
</resource-env-ref>
</web-app>
And here's the code snippet that attempts to obtain a connection to the repository:
InitialContext context = new InitialContext();
Context environment = (Context) context.lookup("java:comp/env");
repository = (Repository) environment.lookup("jcr/repository");
Finally, here's the error that shows up in server.log upon depoyment of my conejo.war file:
2014-07-28 15:48:29,647 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 2) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "conejo.war")]) - failure description: {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.conejo.conejo.env.jcr.repository is missing [jboss.naming.context.java.jboss.resources.jcr.repository]"]}
2014-07-28 15:48:29,679 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "conejo.war" (runtime-name : "conejo.war")
2014-07-28 15:48:29,680 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014775: New missing/unsatisfied dependencies:
service jboss.naming.context.java.jboss.resources.jcr.repository (missing) dependents: [service jboss.naming.context.java.module.conejo.conejo.env.jcr.repository]
I'll buy you pizza if you can tell me what's wrong here! OK not really, but I'll be very thankful.
Alex
-
repository.xml 4.0 KB
-
server.log.gz 4.7 KB