Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Unable to insert an oracle XMLType field

I found a solution adding the following attribute

factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"

in the <Resource> tag defining my database connection in server.xml configuration file of tomcat.
Now it's working. Is it a good solution? Or is better to add a ServerPlatform as you suggest?
And, do you know if there is any plan to add a specific ServerPlatform for Tomcat in some future release of eclipselink?

Best regards

Alberto

On Thu, 2012-10-25 at 08:28 -0400, Tom Ware wrote:
> Hi Alberto,
> 
>    In order for EclipseLink to be able to use Oracle specific JDBC 
> functionality, we need to be able to get a hold of the actual Oracle connection 
> rather than the WebContainer/Server's wrapper of the connection.  The way we do 
> that is through something called a ServerPlatform.  EclipseLink provides a 
> ServerPlatform for many of the popular application servers, but it appears as 
> though you are on TomCat - a Web Container there is no current ServerPlatform 
> implementation for.
> 
>    Fortunately, it should be fairly easy to write your own subclass of 
> ServerPlatform and enable it.  To do so, you will want to write a class that 
> extends org.eclipse.persistence.platform.server.ServerPlatformBase and overrides 
> the unwrapConnection(java.sql.Connection connection) method.
> 
>    For sample code, take a look at classes like: 
> org.eclipse.persistence.platform.server.glassfish.GlassfishPlatform, 
> org.eclipse.persistence.platform.server.wls.WebLogicPlatform and other 
> subclasses of ServerPlatformBase in our source jar.  You will simply have to 
> write equivalent code for TomCat.
> 
>    To enable your ServerPlatform, use the following persistence unit property:
> 
> eclipselink.target-server=<fully qualified classname of your ServerPlatform>
> 
> -Tom
> 
> 
> On 25/10/2012 3:15 AM, Alberto Brosich wrote:
> >
> > Hi,
> >
> > I'm using eclipselink 2.4.1 in a RESTful web service deployed on tomcat
> > 7.0.32 where I have to deal with an oracle 11gR1 table with an XMLType
> > field.
> > I created a class implementing DescriptorCustomizer interface as
> > described in several examples I found. After some troubles with the
> > oracle libraries (no problems with xdb6.jar but with xmlparserv2.jar
> > version 11.2.0.3.0 (the last one) I have no output and no logs, I had to
> > use version 11.1.1.3.0 (I suppose a jar conflicts)) I can read from the
> > XMLType field.
> > But persisting the object I have the following exception that I don't
> > know how to face.
> > Create an XMLType field require to deal directly with an
> > oracle.jdbc.OracleConnection connection and obviously
> > DirectToXMLTypeMapping class doesn't do it. How can I handle that?
> >
> >
> > java.lang.ClassCastException:
> > org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper
> > cannot be cast to oracle.jdbc.OracleConnection
> > 	oracle.sql.OpaqueDescriptor.createDescriptor(OpaqueDescriptor.java:151)
> > 	oracle.xdb.XMLType.&lt;init&gt;(XMLType.java:951)
> > 	oracle.xdb.XMLType.createXML(XMLType.java:1082)
> > 	oracle.xdb.XMLType.createXML(XMLType.java:1072)
> >
> > org.eclipse.persistence.internal.platform.database.oracle.xdb.XMLTypeBindCallCustomParameter.set(XMLTypeBindCallCustomParameter.java:51)	org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.setParameterValueInDatabaseCall(DatabasePlatform.java:2256)	org.eclipse.persistence.platform.database.oracle.Oracle9Platform.setParameterValueInDatabaseCall(Oracle9Platform.java:478)	org.eclipse.persistence.internal.databaseaccess.DatabaseCall.prepareStatement(DatabaseCall.java:724)
> > ...more
> >
> >
> > Best regards
> >
> > Alberto
> >
> > _______________________________________________
> > eclipselink-users mailing list
> > eclipselink-users@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> >
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users




Back to the top