Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WNn9G-0002us-9F for pgsql-jdbc@arkaria.postgresql.org; Wed, 12 Mar 2014 17:40:58 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WNn9F-0006TI-Ll for pgsql-jdbc@arkaria.postgresql.org; Wed, 12 Mar 2014 17:40:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WNn9E-0006T4-DZ; Wed, 12 Mar 2014 17:40:56 +0000 Received: from mail-pa0-x234.google.com ([2607:f8b0:400e:c03::234]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WNn99-0005Fp-PW; Wed, 12 Mar 2014 17:40:55 +0000 Received: by mail-pa0-f52.google.com with SMTP id rd3so1423039pab.11 for ; Wed, 12 Mar 2014 10:40:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=ErjBPhpD72B36L/xkUpCidzIBrE1crSMtwFbH3b2R7I=; b=eyVsyrmTXl27Ji4i8Xfmf1DbHTLFYkA/goum5OnaY7YBelTrsHnxvT8AIE7n6Rn4JU vSdODDaR0o1FnrQOTK+RvsPxg1QyqSXUMd4XU2UOWP6Q32IOE+WH7P/+tpmY5fYRlw5T +yM8NRAnh3M9sZpFwZJsH03sQ7paMxhCDogi+FCaAo5wsD++ZXmRDZokrgkW/ych0LeF 3JqTNruGw6G2Q5S4AzPo85WFQgFx5u+hLCGMsxncue/1CzBdenIh0gss621rEOTmYKm2 /6ZyPaCmdiIx3gwG+O3RXQKd2PZ10jJv8D9podHt/IRT/9Co2LWh5t25HqGOAWkVj3Fm VfNQ== X-Received: by 10.68.163.197 with SMTP id yk5mr6521476pbb.57.1394646048967; Wed, 12 Mar 2014 10:40:48 -0700 (PDT) Received: from [10.1.10.36] (c-98-248-36-48.hsd1.ca.comcast.net. [98.248.36.48]) by mx.google.com with ESMTPSA id ei4sm9051402pbb.42.2014.03.12.10.40.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Mar 2014 10:40:48 -0700 (PDT) Content-Type: multipart/alternative; boundary=Apple-Mail-A3217A6F-9721-4278-B1F8-30ACF142C989 Mime-Version: 1.0 (1.0) Subject: Re: Cannot insert to 'path' field using EclipseLink From: Steven Schlansker X-Mailer: iPhone Mail (11D167) In-Reply-To: Date: Wed, 12 Mar 2014 10:40:46 -0700 Cc: "pgsql-general@postgresql.org" , "pgsql-jdbc@postgresql.org" , "pgsql-novice@postgresql.org" Content-Transfer-Encoding: 7bit Message-Id: <9C61BFB9-E3C8-4CCC-AEB3-21D9B67A9642@gmail.com> References: To: Daryl Foster X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org --Apple-Mail-A3217A6F-9721-4278-B1F8-30ACF142C989 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable > On Mar 12, 2014, at 10:12 AM, Daryl Foster wro= te: >=20 > java.lang.ClassCastException: org.postgresql.geometric.PGpath cannot be ca= st to org.postgresql.geometric.PGpath >=20 That's a sure sign of ClassLoader confusion. Make sure there is only one cop= y of the driver jar in your application or the JBoss container, but never bo= th.=20 >=20 >> On Wed, Mar 12, 2014 at 7:37 AM, Daryl Foster = wrote: >> I have a java app running in JBoss that uses EclipseLink to persist to a P= ostgres database. I've added a field with a 'path' datatype to one of the ta= bles but I keep getting the following exception when I try to insert data: >>=20 >> org.postgresql.util.PSQLException: Can't infer the SQL type to use for an= instance of org.postgresql.geometric.PGpath. Use setObject() with an explic= it Types value to specify the type to use. >>=20 >> Here's the table definition: >>=20 >> CREATE TABLE schema.table_name >> ( >> item_id uuid NOT NULL, >> item_path path NOT NULL >> ) >>=20 >> The java entity is representing the item_path field as a List obje= ct, and I'm using a converter to map from the List object to a PGpath= object: >>=20 >> import org.eclipse.persistence.mappings.DatabaseMapping; >> import org.eclipse.persistence.mappings.converters.Converter; >> import org.eclipse.persistence.sessions.Session; >> import org.postgresql.geometric.PGpath; >> import java.awt.Point; >> import java.util.ArrayList; >> import java.util.List; >> import static java.sql.Types.OTHER; >>=20 >> public class PgPathConverter implements Converter >> { >> @Override >> public boolean isMutable () >> { >> return false; >> } >>=20 >> @Override >> public List convertDataValueToObjectValue (Object value, S= ession session) >> { >> // Code that converts PGpath to List >> } >>=20 >> @Override >> public PGpath convertObjectValueToDataValue (Object value, Sessio= n session) >> { >> // Code that converts List to PGpath >> } >>=20 >> @Override >> public void initialize (DatabaseMapping mapping, Session session)= >> { >> mapping.getField ().setSqlType (OTHER); >> } >> } >>=20 >> The entity class is defined as follows: >>=20 >> @Entity >> @Table ( >> name =3D "table_name", >> schema =3D "schema" >> ) >> @Converter ( >> name =3D "path", >> converterClass =3D PgPathConverter.class >> ) >> public class TableName >> { >> public TableName () {} >> private static final long serialVersionUID =3D 1L; >>=20 >> @Column (name =3D "item_path") >> @Convert ("path") >> private List m_ItemPath; >>=20 >> @Id >> @Column ( >> name =3D "item_id", >> unique =3D true, >> nullable =3D false >> ) >> private UUID m_ItemId; >>=20 >> public UUID getItemId () >> { >> return m_ItemId; >> } >>=20 >> public List getItemPath () >> { >> return m_InkPath; >> } >>=20 >> public void setItemId (UUID itemId) >> { >> m_ItemId =3D itemId; >> } >>=20 >> public void setInkPath (List itemPath) >> { >> m_ItemPath =3D itemPath; >> } >> } >>=20 >> Finally, here's the exception I get when I call `EntityManager.persist (e= ntity)`: >>=20 >> 18:10:33,789 ERROR [org.jboss.as.ejb3] (http-/0.0.0.0:8080-1) javax.e= jb.EJBTransactionRolledbackException: Exception [EclipseLink-4002] (Eclipse P= ersistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exce= ptions.DatabaseException >> Internal Exception: org.postgresql.util.PSQLException: Can't infer th= e SQL type to use for an instance of org.postgresql.geometric.PGpath. Use se= tObject() with an explicit Types value to specify the type to use. >> Error Code: 0 >> Call: INSERT INTO schema.table_name (item_id, item_path) VALUES (?, ?= ) >> bind =3D> [2 parameters bound] >> 18:10:33,789 ERROR [org.jboss.as.ejb3.invocation] (http-/0.0.0.0:8080= -1) JBAS014134: EJB Invocation failed on component TableNameRepository for m= ethod public void com.mycompany.myproject.data.Repository.flush() throws jav= ax.persistence.TransactionRequiredException,javax.persistence.PersistenceExc= eption: javax.ejb.EJBTransactionRolledbackException: Exception [EclipseLink-= 4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.= persistence.exceptions.DatabaseException >> Internal Exception: org.postgresql.util.PSQLException: Can't infer th= e SQL type to use for an instance of org.postgresql.geometric.PGpath. Use se= tObject() with an explicit Types value to specify the type to use. >> Error Code: 0 >> Call: INSERT INTO schema.table_name (item_id, item_path VALUES (?, ?)= >> bind =3D> [2 parameters bound] >> at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleInCallerTx(CMTTxIn= terceptor.java:138) [jboss-as-ejb3-7.2.0.Final-redhat-8.jar:7.2.0.Final-redh= at-8] >> at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxIn= terceptor.java:228) [jboss-as-ejb3-7.2.0.Final-redhat-8.jar:7.2.0.Final-redh= at-8] >> at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.= java:317) [jboss-as-ejb3-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8] >> at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInt= erceptor.java:214) [jboss-as-ejb3-7.2.0.Final-redhat-8.jar:7.2.0.Final-redha= t-8] >> at org.jboss.invocation.InterceptorContext.proceed(InterceptorConte= xt.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2= ] >> at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContex= tInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [= jboss-as-ejb3-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8] >> at org.jboss.invocation.InterceptorContext.proceed(InterceptorConte= xt.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2= ] >> at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFact= ory$1.processInvocation(ShutDownInterceptorFactory.java:64) [jboss-as-ejb3-7= .2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8] >> at org.jboss.invocation.InterceptorContext.proceed(InterceptorConte= xt.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2= ] >> at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.proc= essInvocation(LoggingInterceptor.java:59) [jboss-as-ejb3-7.2.0.Final-redhat-= 8.jar:7.2.0.Final-redhat-8] >> at org.jboss.invocation.InterceptorContext.proceed(InterceptorConte= xt.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2= ] >> at org.jboss.as.ee.component.NamespaceContextInterceptor.processInv= ocation(NamespaceContextInterceptor.java:50) [jboss-as-ee-7.2.0.Final-redhat= -8.jar:7.2.0.Final-redhat-8] >> at org.jboss.invocation.InterceptorContext.proceed(InterceptorConte= xt.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2= ] >> at org.jboss.as.ejb3.component.interceptors.AdditionalSetupIntercep= tor.processInvocation(AdditionalSetupInterceptor.java:55) [jboss-as-ejb3-7.2= .0.Final-redhat-8.jar:7.2.0.Final-redhat-8] >> at org.jboss.invocation.InterceptorContext.proceed(InterceptorConte= xt.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2= ] >> at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCL= Interceptor.java:45) [jboss-as-ee-7.2.0.Final-redhat-8.jar:7.2.0.Final-redha= t-8] >> at org.jboss.invocation.InterceptorContext.proceed(InterceptorConte= xt.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2= ] >> at org.jboss.invocation.ChainedInterceptor.processInvocation(Chaine= dInterceptor.java:61) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final= -redhat-2] >> at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.ja= va:165) [jboss-as-ee-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8] >> at org.jboss.as.ee.component.ViewDescription$1.processInvocation(Vi= ewDescription.java:182) [jboss-as-ee-7.2.0.Final-redhat-8.jar:7.2.0.Final-re= dhat-8] >> at org.jboss.invocation.InterceptorContext.proceed(InterceptorConte= xt.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2= ] >> at org.jboss.invocation.ChainedInterceptor.processInvocation(Chaine= dInterceptor.java:61) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final= -redhat-2] >> at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInv= ocationHandler.java:72) [jboss-as-ee-7.2.0.Final-redhat-8.jar:7.2.0.Final-re= dhat-8] >> ... >> --=20 >> Sincerely, >> Daryl Foster >=20 >=20 >=20 > --=20 > Sincerely, > Daryl Foster > Software Engineer > On Center Software, Inc. >=20 > P: 281.210.0177 > F: 281.297.9001 > W: www.oncenter.com --Apple-Mail-A3217A6F-9721-4278-B1F8-30ACF142C989 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit


On Mar 12, 2014, at 10:12 AM, Daryl Foster <daryl.foster@oncenter.com> wrote:

java.lang.ClassCastException: org.postgresql.geometric.PGpath cannot be cast to org.postgresql.geometric.PGpath


That's a sure sign of ClassLoader confusion. Make sure there is only one copy of the driver jar in your application or the JBoss container, but never both. 


On Wed, Mar 12, 2014 at 7:37 AM, Daryl Foster <daryl.foster@oncenter.com> wrote:
I have a java app running in JBoss that uses EclipseLink to persist to a Postgres database. I've added a field with a 'path' datatype to one of the tables but I keep getting the following exception when I try to insert data:

org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of org.postgresql.geometric.PGpath. Use setObject() with an explicit Types value to specify the type to use.

Here's the table definition:

    CREATE TABLE schema.table_name
    (
        item_id    uuid NOT NULL,
        item_path  path NOT NULL
    )

The java entity is representing the item_path field as a List<Point> object, and I'm using a converter to map from the List<Point> object to a PGpath object:

    import org.eclipse.persistence.mappings.DatabaseMapping;
    import org.eclipse.persistence.mappings.converters.Converter;
    import org.eclipse.persistence.sessions.Session;
    import org.postgresql.geometric.PGpath;
    import java.awt.Point;
    import java.util.ArrayList;
    import java.util.List;
    import static java.sql.Types.OTHER;

    public class PgPathConverter implements Converter
    {
        @Override
        public boolean isMutable ()
        {
            return false;
        }

        @Override
        public List<Point> convertDataValueToObjectValue (Object value, Session session)
        {
            // Code that converts PGpath to List<Point>
        }

        @Override
        public PGpath convertObjectValueToDataValue (Object value, Session session)
        {
            // Code that converts List<Point> to PGpath
        }

        @Override
        public void initialize (DatabaseMapping mapping, Session session)
        {
            mapping.getField ().setSqlType (OTHER);
        }
    }

The entity class is defined as follows:

    @Entity
    @Table (
        name           = "table_name",
        schema         = "schema"
    )
    @Converter (
        name           = "path",
        converterClass = PgPathConverter.class
    )
    public class TableName
    {
        public TableName () {}
        private static final long serialVersionUID = 1L;

        @Column (name = "item_path")
        @Convert ("path")
        private List<Point> m_ItemPath;

        @Id
        @Column (
            name     = "item_id",
            unique   = true,
            nullable = false
        )
        private UUID        m_ItemId;

        public UUID getItemId ()
        {
            return m_ItemId;
        }

        public List<Point> getItemPath ()
        {
            return m_InkPath;
        }

        public void setItemId (UUID itemId)
        {
            m_ItemId = itemId;
        }

        public void setInkPath (List<Point> itemPath)
        {
             m_ItemPath = itemPath;
        }
    }

Finally, here's the exception I get when I call `EntityManager.persist (entity)`:

    18:10:33,789 ERROR [org.jboss.as.ejb3] (http-/0.0.0.0:8080-1) javax.ejb.EJBTransactionRolledbackException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
    Internal Exception: org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of org.postgresql.geometric.PGpath. Use setObject() with an explicit Types value to specify the type to use.
    Error Code: 0
    Call: INSERT INTO schema.table_name (item_id, item_path) VALUES (?, ?)
bind => [2 parameters bound]
    18:10:33,789 ERROR [org.jboss.as.ejb3.invocation] (http-/0.0.0.0:8080-1) JBAS014134: EJB Invocation failed on component TableNameRepository for method public void com.mycompany.myproject.data.Repository.flush() throws javax.persistence.TransactionRequiredException,javax.persistence.PersistenceException: javax.ejb.EJBTransactionRolledbackException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
    Internal Exception: org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of org.postgresql.geometric.PGpath. Use setObject() with an explicit Types value to specify the type to use.
    Error Code: 0
    Call: INSERT INTO schema.table_name (item_id, item_path VALUES (?, ?)
bind => [2 parameters bound]
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleInCallerTx(CMTTxInterceptor.java:138) [jboss-as-ejb3-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:228) [jboss-as-ejb3-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:317) [jboss-as-ejb3-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:214) [jboss-as-ejb3-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]
at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [jboss-as-ejb3-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]
at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64) [jboss-as-ejb3-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]
at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59) [jboss-as-ejb3-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]
at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) [jboss-as-ee-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]
at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:55) [jboss-as-ejb3-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]
at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) [jboss-as-ee-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]
at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165) [jboss-as-ee-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:182) [jboss-as-ee-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]
at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72) [jboss-as-ee-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
...
--

Sincerely,

Daryl Foster




--

Sincerely,

Daryl Foster
Software Engineer

On Center Software, Inc.

P: 281.210.0177

F: 281.297.9001
W: www.oncenter.com
--Apple-Mail-A3217A6F-9721-4278-B1F8-30ACF142C989--