More BEA WebLogic Woes. ClassCastException: weblogic.jdbc.wrapper.Struct_oracle_sql_STRUCT

3 messages Options
Embed this post
Permalink
Davis Ford

More BEA WebLogic Woes. ClassCastException: weblogic.jdbc.wrapper.Struct_oracle_sql_STRUCT

Reply Threaded More More options
Print post
Permalink
Now, we hit this stacktrace:

Error
java.lang.ClassCastException: weblogic.jdbc.wrapper.Struct_oracle_sql_STRUCT
 at org.hibernatespatial.oracle.SDOGeometryType.convert2JTS(SDOGeometryType.java:418)
 at org.hibernatespatial.AbstractDBGeometryType.nullSafeGet(AbstractDBGeometryType.java:127)

It seems weblogic also wraps the STRUCT type.  It happens on this line
of SDOGeometryType.java

SDO_GEOMETRY sdoGeom = SDO_GEOMETRY.load((STRUCT) struct);

Where struct is cast to oracle.sql.STRUCT.  I think I can fix it via
using reflection to get at the vendor object (see here
http://objectmix.com/weblogic/533349-weblogic-jdbc-vendor-oracle-oraclestruct-oracle-sql-struct.html
)

Karel -- do you have any other ideas?  If I supply a patch that fixes
it, can you integrate it?

Regards,
Davis


--
Zeno Consulting, Inc.
home: http://www.zenoconsulting.biz
blog: http://zenoconsulting.wikidot.com
p: 248.894.4922
f: 313.884.2977
_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Davis Ford

Re: More BEA WebLogic Woes. ClassCastException: weblogic.jdbc.wrapper.Struct_oracle_sql_STRUCT

Reply Threaded More More options
Print post
Permalink
Problem summary:

In AbstractDBGeometryType.java ->

final Object geomObj = rs.getObject(names[0]);

returns weblogic.jdbc.wrapper.Struct_oracle_sql_STRUCT.  This cannot
be cast to oracle.sql.STRUCT.  The code in SdoGeometryType later casts
this to oracle.sql.STRUCT and it blows up with ClassCastException.

I can confirm that we have successfully implemented the
OracleConnectionFinder and it is in place.  We still see this problem.
I am not 100% sure why, but the attached patches fix it.
Unfortunately, I didn't see a better solution without somehow getting
the Connection object to the SdoGeometryType, and that meant changing
the interface on the abstract class.  This is not a perfect solution,
but I'm hoping Karel can take it and evolve it into something cleaner
that will work for everyone.

Regards,
Davis

Index: AbstractDBGeometryType.java
===================================================================
--- AbstractDBGeometryType.java (revision 127)
+++ AbstractDBGeometryType.java (working copy)
@@ -123,8 +123,9 @@
  */
  public Object nullSafeGet(ResultSet rs, String[] names, Object owner)
  throws HibernateException, SQLException {
- Object geomObj = rs.getObject(names[0]);
- return convert2JTS(geomObj);
+ final Object geomObj = rs.getObject(names[0]);
+ final Connection con = rs.getStatement().getConnection();
+ return convert2JTS(geomObj, con);
  }

  /**
@@ -136,7 +137,7 @@
  *            native database geometry object
  * @return JTS Geometry
  */
- public abstract Geometry convert2JTS(Object geomObj);
+ public abstract Geometry convert2JTS(Object geomObj, Connection con);

  /*
  * (non-Javadoc)

Index: SDOGeometryType.java
===================================================================
--- SDOGeometryType.java (revision 127)
+++ SDOGeometryType.java (working copy)
@@ -411,12 +411,34 @@
  }

  @Override
- public Geometry convert2JTS(Object struct) {
+ public Geometry convert2JTS(Object struct, Connection con) {
  if (struct == null) {
  return null;
  }
+    /*
+     * Fix for BEA WebLogic; BEA wraps ResultSet#getObject()
+     * returning a STRUCT as a dynamicially generated proxy
+     * (weblogic.jdbc.wrapper.Struct_oracle_sql_STRUCT);
+     * This cannot be cast to oracle.sql.STRUCT so we
+     * have to create oracle.sql.STRUCT explicitly.
+ */
+ OracleConnection oracleCon = null;

- SDO_GEOMETRY sdoGeom = SDO_GEOMETRY.load((STRUCT) struct);
+ java.sql.Struct sqlStruct = (java.sql.Struct) struct;
+ STRUCT oracleStruct = null;
+ SDO_GEOMETRY sdoGeom = null;
+
+ try {
+        oracleCon = getConnectionFinder().find(con);
+        StructDescriptor structDescriptor =
StructDescriptor.createDescriptor(sqlStruct.getSQLTypeName(),
oracleCon);
+        oracleStruct = new STRUCT(structDescriptor, oracleCon,
sqlStruct.getAttributes());
+        sdoGeom = SDO_GEOMETRY.load(oracleStruct);
+     } catch (FinderException e) {
+        throw new HibernateException(e);
+     } catch (SQLException e) {
+        throw new HibernateException(e);
+     }
+
  return convert2JTS(sdoGeom);
  }



On Mon, Feb 16, 2009 at 11:05 AM, Davis Ford
<[hidden email]> wrote:

> Now, we hit this stacktrace:
>
> Error
> java.lang.ClassCastException: weblogic.jdbc.wrapper.Struct_oracle_sql_STRUCT
>  at org.hibernatespatial.oracle.SDOGeometryType.convert2JTS(SDOGeometryType.java:418)
>  at org.hibernatespatial.AbstractDBGeometryType.nullSafeGet(AbstractDBGeometryType.java:127)
>
> It seems weblogic also wraps the STRUCT type.  It happens on this line
> of SDOGeometryType.java
>
> SDO_GEOMETRY sdoGeom = SDO_GEOMETRY.load((STRUCT) struct);
>
> Where struct is cast to oracle.sql.STRUCT.  I think I can fix it via
> using reflection to get at the vendor object (see here
> http://objectmix.com/weblogic/533349-weblogic-jdbc-vendor-oracle-oraclestruct-oracle-sql-struct.html
> )
>
> Karel -- do you have any other ideas?  If I supply a patch that fixes
> it, can you integrate it?
>
> Regards,
> Davis
>
>
> --
> Zeno Consulting, Inc.
> home: http://www.zenoconsulting.biz
> blog: http://zenoconsulting.wikidot.com
> p: 248.894.4922
> f: 313.884.2977
>



--
Zeno Consulting, Inc.
home: http://www.zenoconsulting.biz
blog: http://zenoconsulting.wikidot.com
p: 248.894.4922
f: 313.884.2977
_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Karel Maesen

Re: More BEA WebLogic Woes. ClassCastException: weblogic.jdbc.wrapper.Struct_oracle_sql_STRUCT

Reply Threaded More More options
Print post
Permalink
Hi,

I created an issue for this in JIRA: http://www.hibernatespatial.org/ 
jira/browse/HIBSPA-27

Regards,

Karel Maesen

On 16 Feb 2009, at 22:38, Davis Ford wrote:

> Problem summary:
>
> In AbstractDBGeometryType.java ->
>
> final Object geomObj = rs.getObject(names[0]);
>
> returns weblogic.jdbc.wrapper.Struct_oracle_sql_STRUCT.  This cannot
> be cast to oracle.sql.STRUCT.  The code in SdoGeometryType later casts
> this to oracle.sql.STRUCT and it blows up with ClassCastException.
>
> I can confirm that we have successfully implemented the
> OracleConnectionFinder and it is in place.  We still see this problem.
> I am not 100% sure why, but the attached patches fix it.
> Unfortunately, I didn't see a better solution without somehow getting
> the Connection object to the SdoGeometryType, and that meant changing
> the interface on the abstract class.  This is not a perfect solution,
> but I'm hoping Karel can take it and evolve it into something cleaner
> that will work for everyone.
>
> Regards,
> Davis
>
> Index: AbstractDBGeometryType.java
> ===================================================================
> --- AbstractDBGeometryType.java (revision 127)
> +++ AbstractDBGeometryType.java (working copy)
> @@ -123,8 +123,9 @@
>   */
>   public Object nullSafeGet(ResultSet rs, String[] names, Object  
> owner)
>   throws HibernateException, SQLException {
> - Object geomObj = rs.getObject(names[0]);
> - return convert2JTS(geomObj);
> + final Object geomObj = rs.getObject(names[0]);
> + final Connection con = rs.getStatement().getConnection();
> + return convert2JTS(geomObj, con);
>   }
>
>   /**
> @@ -136,7 +137,7 @@
>   *            native database geometry object
>   * @return JTS Geometry
>   */
> - public abstract Geometry convert2JTS(Object geomObj);
> + public abstract Geometry convert2JTS(Object geomObj, Connection  
> con);
>
>   /*
>   * (non-Javadoc)
>
> Index: SDOGeometryType.java
> ===================================================================
> --- SDOGeometryType.java (revision 127)
> +++ SDOGeometryType.java (working copy)
> @@ -411,12 +411,34 @@
>   }
>
>   @Override
> - public Geometry convert2JTS(Object struct) {
> + public Geometry convert2JTS(Object struct, Connection con) {
>   if (struct == null) {
>   return null;
>   }
> +    /*
> +     * Fix for BEA WebLogic; BEA wraps ResultSet#getObject()
> +     * returning a STRUCT as a dynamicially generated proxy
> +     * (weblogic.jdbc.wrapper.Struct_oracle_sql_STRUCT);
> +     * This cannot be cast to oracle.sql.STRUCT so we
> +     * have to create oracle.sql.STRUCT explicitly.
> + */
> + OracleConnection oracleCon = null;
>
> - SDO_GEOMETRY sdoGeom = SDO_GEOMETRY.load((STRUCT) struct);
> + java.sql.Struct sqlStruct = (java.sql.Struct) struct;
> + STRUCT oracleStruct = null;
> + SDO_GEOMETRY sdoGeom = null;
> +
> + try {
> +        oracleCon = getConnectionFinder().find(con);
> +        StructDescriptor structDescriptor =
> StructDescriptor.createDescriptor(sqlStruct.getSQLTypeName(),
> oracleCon);
> +        oracleStruct = new STRUCT(structDescriptor, oracleCon,
> sqlStruct.getAttributes());
> +        sdoGeom = SDO_GEOMETRY.load(oracleStruct);
> +     } catch (FinderException e) {
> +        throw new HibernateException(e);
> +     } catch (SQLException e) {
> +        throw new HibernateException(e);
> +     }
> +
>   return convert2JTS(sdoGeom);
>   }
>
>
>
> On Mon, Feb 16, 2009 at 11:05 AM, Davis Ford
> <[hidden email]> wrote:
>> Now, we hit this stacktrace:
>>
>> Error
>> java.lang.ClassCastException:  
>> weblogic.jdbc.wrapper.Struct_oracle_sql_STRUCT
>>  at org.hibernatespatial.oracle.SDOGeometryType.convert2JTS
>> (SDOGeometryType.java:418)
>>  at org.hibernatespatial.AbstractDBGeometryType.nullSafeGet
>> (AbstractDBGeometryType.java:127)
>>
>> It seems weblogic also wraps the STRUCT type.  It happens on this  
>> line
>> of SDOGeometryType.java
>>
>> SDO_GEOMETRY sdoGeom = SDO_GEOMETRY.load((STRUCT) struct);
>>
>> Where struct is cast to oracle.sql.STRUCT.  I think I can fix it via
>> using reflection to get at the vendor object (see here
>> http://objectmix.com/weblogic/533349-weblogic-jdbc-vendor-oracle- 
>> oraclestruct-oracle-sql-struct.html
>> )
>>
>> Karel -- do you have any other ideas?  If I supply a patch that fixes
>> it, can you integrate it?
>>
>> Regards,
>> Davis
>>
>>
>> --
>> Zeno Consulting, Inc.
>> home: http://www.zenoconsulting.biz
>> blog: http://zenoconsulting.wikidot.com
>> p: 248.894.4922
>> f: 313.884.2977
>>
>
>
>
> --
> Zeno Consulting, Inc.
> home: http://www.zenoconsulting.biz
> blog: http://zenoconsulting.wikidot.com
> p: 248.894.4922
> f: 313.884.2977
> _______________________________________________
> hibernatespatial-users mailing list
> [hidden email]
> http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/ 
> hibernatespatial-users

_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users