Installation of the Joseki SPARQL Endpoint in front of Oracle on Ubuntu
Here’s one from my archives. It was a bitch to come by, so hopefully this will help some other poor soul tasked with setting up a HTTP interface to Oracle’s semantic store.
Preparation
First, install Oracle on Ubuntu. That’s a pain, and only partially covered elsewhere. My notes on that subject, however, are enough for an entire months worth of blog posts, so I’m saving them for next November.
Once you’re done with the first step, you’ll want to enable semantic support, install a semantic network, maybe create a model or two, populate them and then make them queryable with a shiny SPARQL web service endpoint.
To enable Oracle’s semantic support (from here):
sqlplus / as SYSDBA
@$ORACLE_HOME/md/admin/catsem.sql
To create a semantic network (from here):
CREATE TABLESPACE rdf_tblspace
DATAFILE '/u01/app/oracle/oradata/tseval/rdf_tblspace.dat' SIZE 1024M REUSE
AUTOEXTEND ON NEXT 256M MAXSIZE UNLIMITED
SEGMENT SPACE MANAGEMENT AUTO;
EXEC SEM_APIS.CREATE_SEM_NETWORK('rdf_tblspace');
Create a user in Oracle and grant them privileges:
create user rdfuser
identified by rdfuser
default tablespace users
temporary tablespace temp;
grant connect to rdfuser;
SPARQL Endpoint
Install Tomcat 6:
sudo apt-get install tomcat6
Download Joseki 3.4.0 and the latest Jena adaptor for Oracle (from here and here):
unzip joseki-3.4.0.zip
mv Joseki-3.4.0 joseki
mkdir jena_adaptor
cd jena_adaptor
unzip ../jena_adaptor_for_release11.2.zip
The Joseki web app must be carefully put together using files from each. Copy a directory from joseki as a starting directory to construct the web apps:
cp -R joseki/webapps/joseki joseki.war.d
cp -R joseki/lib joseki.war.d/WEB-INF
And copy away:
cp jena_adaptor/joseki/* joseki.war.d
cp jena_adaptor/web/* joseki.war.d/WEB-INF
cp jena_adaptor/jar/* joseki.war.d/WEB-INF/lib
The sdordfclient.jar
in the jena_adaptor has since been superceded and doesn’t work with Tomcat anyway (insert grumblings about WebLogic here). I got my hands on a copy of the latest version thanks to having sweet contacts inside the Oracle mothership, if you do too, you’ll want to put that in there. If you don’t, you should give up now and make something of your life.
The webapp needs Oracle’s sdordf.jar
from your installation:
cp $ORACLE_HOME/md/jlib/sdordf.jar joseki.war.d/WEB-INF/lib
cp $ORACLE_HOME/jdbc/lib/ojdbc6.jar joseki.war.d/WEB-INF/lib
And Joseki comes with a replacement for Tomcat’s default servlet-api jar:
rm joseki.war.d/WEB-INF/lib/servlet-api-2.5.jar
mv joseki.war.d/WEB-INF/lib/servlet-api-2.5-6.1.10.jar /usr/share/java
cd /usr/share/tomcat6/lib
rm servlet-api-2.5.jar
ln -s ../../java/servlet-api-2.5-6.1.10.jar servlet-api-2.5.jar
Next, add this file to make an Oracle datasource that Oracle’s Joseki service will look for:
joseki.war.d/META-INF/context.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Resource name="OracleSemDS"
auth="Container"
type="oracle.jdbc.pool.OracleDataSource"
factory="oracle.jdbc.pool.OracleDataSourceFactory"
user=""
password=""
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521/orcl"
validationQuery="select 1 from dual"
maxActive="30"
maxIdle="10"
maxWait="-1"/>
</Context>
Also, I’d bump up the number of connections in Joseki’s connection pool
joseki.war.d/joseki-config.ttl
:
<#oracle> rdf:type oracle:Dataset;
joseki:poolSize 30 ; ## Number of concurrent connections allowed to this dataset.
oracle:connection
[ a oracle:OracleConnection ;
];
oracle:defaultModel [ oracle:firstModel "M1" ] .
Verify that your directory structure looks like so:
./joseki.war.d:
application.xml
crossdomain.xml
index.html
joseki-config.ttl
META-INF
query.html
robots.txt
sparqler-details.html
sparql.html
StyleSheets
update.html
validator.html
WEB-INF
xml-to-html.xsl
./joseki.war.d/META-INF:
context.xml
./joseki.war.d/StyleSheets:
joseki.css
./joseki.war.d/WEB-INF:
lib
web.xml
./joseki.war.d/WEB-INF/lib:
arq-2.8.0.jar
arq-2.8.0-tests.jar
icu4j-3.4.4.jar
iri-0.7.jar
jena-2.6.0.jar
jenatest-2.6.0.jar
jetty-6.1.10.jar
jetty-util-6.1.10.jar
joseki-3.4.0.jar
junit-4.5.jar
log4j-1.2.12.jar
lucene-core-2.3.1.jar
ojdbc5.jar
sdordfclient.jar
sdordf.jar
slf4j-api-1.5.6.jar
slf4j-log4j12-1.5.6.jar
stax-api-1.0.1.jar
wstx-asl-3.2.9.jar
xercesImpl-2.7.1.jar
Create the joseki war file:
cd joseki.war.d
jar cvf ../joseki.war .
Deploy it:
mv joseki.war /var/lib/tomcat6/webapps
Goodluck and Godspeed.
1 comment