Social Icons

twitterfacebookgoogle pluslinkedinrss feedemail

Pages

Monday, March 18, 2013

GeoServer 2.2.5 + JBoss 7.1.1 and Oracle

As I posted some time ago, I'm using GeoServer version 2.2.5 on a JBoss 7.1.1 installation; now I'm working with an Oracle Database so I've added the Oracle extension. And added it in the "$WAR/WEB-INF/lib/" the jar that is downloaded as a separate package (mind to download the same version for the GeoServer you are using).

I had this problem accessing oracle tables:


09:23:34,911 ERROR [org.geoserver.ows] (http--10.20.1.50-8280-17) : java.lang.NoClassDefFoundError: oracle/jdbc/OracleConnection
at org.geotools.data.oracle.OracleDialect.unwrapConnection(OracleDialect.java:544) [gt-jdbc-oracle-8.7.jar:]
at org.geotools.data.oracle.OracleDialect.setGeometryValue(OracleDialect.java:517) [gt-jdbc-oracle-8.7.jar:]
at org.geotools.jdbc.JDBCDataStore.setPreparedFilterValues(JDBCDataStore.java:3168) [gt-jdbc-8.7.jar:]
at org.geotools.jdbc.JDBCDataStore.setPreparedFilterValues(JDBCDataStore.java:3147) [gt-jdbc-8.7.jar:]
at org.geotools.jdbc.JDBCDataStore.selectAggregateSQLPS(JDBCDataStore.java:3372) [gt-jdbc-8.7.jar:]
at org.geotools.jdbc.JDBCDataStore.getAggregateValue(JDBCDataStore.java:1292) [gt-jdbc-8.7.jar:]
at org.geotools.jdbc.JDBCDataStore.getCount(JDBCDataStore.java:1250) [gt-jdbc-8.7.jar:]
at org.geotools.jdbc.JDBCFeatureSource.getCountInternal(JDBCFeatureSource.java:432) [gt-jdbc-8.7.jar:]
at org.geotools.data.store.ContentFeatureSource.getCount(ContentFeatureSource.java:451) [gt-data-8.7.jar:]
at org.geotools.jdbc.JDBCFeatureStore.getCountInternal(JDBCFeatureStore.java:183) [gt-jdbc-8.7.jar:]
at org.geotools.data.store.ContentFeatureSource.getCount(ContentFeatureSource.java:451) [gt-data-8.7.jar:]
at org.geotools.data.store.ContentFeatureCollection.size(ContentFeatureCollection.java:356) [gt-data-8.7.jar:]
at org.geoserver.wms.GetFeatureInfo.execute(GetFeatureInfo.java:297) [wms-2.2.5.jar:2.2.5]
at org.geoserver.wms.GetFeatureInfo.execute(GetFeatureInfo.java:168) [wms-2.2.5.jar:2.2.5]
at org.geoserver.wms.GetFeatureInfo.run(GetFeatureInfo.java:117) [wms-2.2.5.jar:2.2.5]
at org.geoserver.wms.DefaultWebMapService.getFeatureInfo(DefaultWebMapService.java:374) [wms-2.2.5.jar:2.2.5]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_25]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [rt.jar:1.6.0_25]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [rt.jar:1.6.0_25]
at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_25]
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318) [spring-aop-3.1.1.RELEASE.jar:3.1.1.RELEASE]


The problem is due to a classloading mechanism of the AS.



The solution is to create the oracle module containing the "ojdbc6.jar" (in this case)

Step1)
Create a Oracle Driver module as following:


    JBossAS7.1.1/modules/
                    └── com
                         └── oracle
                               └── main
                                     ├── module.xml
                                     ├── ojdbc6.jar


Step2)
Than either to add this line to the "$WAR/META-INF/MANIFEST.MF" file:


Dependencies: com.oracle, org.jboss.ironjacamar.jdbcadapters


or in

jboss-deployment-structure.xml

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
    <deployment>
        <dependencies>
            <system>
                <paths>
                    <path name="com/sun/imageio/spi"/>
                    <path name="com/sun/imageio/plugins/common"/>
                </paths>
            </system>
            <module name="com.oracle" />
            <module name="org.jboss.ironjacamar.jdbcadapters" />
        </dependencies>
    </deployment>
</jboss-deployment-structure>



Mind that the com.oracle has to be the same declared as name of the module (you have to provide this one)


<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.oracle">
    <resources>
      <resource-root path="ojdbc6.jar"/>
    </resources>

    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
    </dependencies>
</module>


The org.jboss.ironjacamar.jdbcadapters is something you find bundled with JBoss.