Thread: Postgresql and J2ee

Postgresql and J2ee

From
"philippe.mayre"
Date:
dear support,

I would like to use two PostgreSql 7.3 XA Databases rather than XACloudscape with my j2ee application but when I deploy it on the server, this one throws the following exception :

java.lang.ClassCastException
        at com.sun.enterprise.resource.SystemJdbc20XaAllocator.createResource(SystemJdbc20XaAllocator.java:39)
        at com.sun.enterprise.resource.PoolManagerImpl.getResourceFromPool(PoolManagerImpl.java:177)
        at com.sun.enterprise.resource.SystemJdbcDataSource.internalGetConnection(SystemJdbcDataSource.java:72)
        at com.sun.enterprise.resource.SystemJdbcDataSource.getConnection(SystemJdbcDataSource.java:50)
        at com.sun.ejb.persistence.PersistenceManagerImpl.getConnection(PersistenceManagerImpl.java:588)
        at com.sun.ejb.persistence.PersistenceManagerImpl.getConnection(PersistenceManagerImpl.java:573)
        at com.sun.ejb.persistence.PMDeployerImpl.createTable(PMDeployerImpl.java:201)
        at com.sun.ejb.persistence.PMDeployerImpl.ejbJarDeployed(PMDeployerImpl.java:68)
        at com.sun.enterprise.tools.deployment.backend.JarManagerImpl.loadJar(JarManagerImpl.java:141)
        at com.sun.enterprise.tools.deployment.backend.JarInstallerImpl.deployEjbs(JarInstallerImpl.java:727)
        at com.sun.enterprise.tools.deployment.backend.JarInstallerImpl.deployApplication(JarInstallerImpl.java:221)
        at org.omg.stub.com.sun.enterprise.tools.deployment.backend._JarInstallerImpl_Tie._invoke(Unknown Source)
        at com.sun.corba.ee.internal.corba.ServerDelegate.dispatch(ServerDelegate.java:355)
        at com.sun.corba.ee.internal.iiop.ORB.process(ORB.java:255)
        at com.sun.corba.ee.internal.iiop.RequestProcessor.process(RequestProcessor.java:84)
        at com.sun.corba.ee.internal.orbutil.ThreadPool$PooledThread.run(ThreadPool.java:99)


I use j2ee 1.3 with j2sdk 1.4 .1

the features on my linux system are :

in .bash_profile export CLASSPATH=.:$JAVA_HOME/lib/j2ee.jar:/usr/share/pgsql/pg73jdbc3.jar

in $J2EE_HOME/bin/userconfig.sh export J2EE_CLASSPATH=/usr/share/pgsql/pg73jdbc3.jar

in $J2EE_HOME/bin/cloudscape file I change COM.cloudscape.core.JDBCDriver by org.postgresql.Driver for setting the good class in DriverManager

then I launch the following command

./j2eeadmin -addJdbcXADatasource jdbc/name org.postgresql.jdbc3.Jdbc3ConnectionPool -props serverName=myServer portNumber=5432 databaseName=nameDB user=myPostgresqlUser

when I start the server I haven't any problems but after .....


Do you know if I can use this driver and how I must declare my databases


Thank you in advance


phMayre

Re: Postgresql and J2ee

From
Barry Lind
Date:
Philippe,

The Postgres database doesn't support two-phase commits and therefore
also doesn't support the XA protocol.  Thus the jdbc driver can't expose
functionality that doesn't exist in the database.

--Barry

philippe.mayre wrote:
>   dear support,
>
> I would like to use two PostgreSql 7.3 XA Databases rather than
> XACloudscape with my j2ee application but when I deploy it on the
> server, this one throws the following exception :
>
> * java.lang.ClassCastException
>         at
> com.sun.enterprise.resource.SystemJdbc20XaAllocator.createResource(SystemJdbc20XaAllocator.java:39)
>         at
> com.sun.enterprise.resource.PoolManagerImpl.getResourceFromPool(PoolManagerImpl.java:177)
>         at
> com.sun.enterprise.resource.SystemJdbcDataSource.internalGetConnection(SystemJdbcDataSource.java:72)
>         at
> com.sun.enterprise.resource.SystemJdbcDataSource.getConnection(SystemJdbcDataSource.java:50)
>         at
> com.sun.ejb.persistence.PersistenceManagerImpl.getConnection(PersistenceManagerImpl.java:588)
>         at
> com.sun.ejb.persistence.PersistenceManagerImpl.getConnection(PersistenceManagerImpl.java:573)
>         at
> com.sun.ejb.persistence.PMDeployerImpl.createTable(PMDeployerImpl.java:201)
>         at
> com.sun.ejb.persistence.PMDeployerImpl.ejbJarDeployed(PMDeployerImpl.java:68)
>         at
> com.sun.enterprise.tools.deployment.backend.JarManagerImpl.loadJar(JarManagerImpl.java:141)
>         at
> com.sun.enterprise.tools.deployment.backend.JarInstallerImpl.deployEjbs(JarInstallerImpl.java:727)
>         at
> com.sun.enterprise.tools.deployment.backend.JarInstallerImpl.deployApplication(JarInstallerImpl.java:221)
>         at
> org.omg.stub.com.sun.enterprise.tools.deployment.backend._JarInstallerImpl_Tie._invoke(Unknown
> Source)
>         at
> com.sun.corba.ee.internal.corba.ServerDelegate.dispatch(ServerDelegate.java:355)
>         at com.sun.corba.ee.internal.iiop.ORB.process(ORB.java:255)
>         at
> com.sun.corba.ee.internal.iiop.RequestProcessor.process(RequestProcessor.java:84)
>         at
> com.sun.corba.ee.internal.orbutil.ThreadPool$PooledThread.run(ThreadPool.java:99)*
>
> * I use j2ee 1.3 with j2sdk 1.4 .1*
>
> the features on my linux system are :
>
> in .bash_profile *export
> CLASSPATH=.:$JAVA_HOME/lib/j2ee.jar:/usr/share/pgsql/pg73jdbc3.jar*
>
> in $J2EE_HOME/bin/userconfig.sh export
> *J2EE_CLASSPATH=/usr/share/pgsql/pg73jdbc3.jar*
>
> in $J2EE_HOME/bin/cloudscape file I change
> *COM.cloudscape.core.JDBCDriver* by *org.postgresql.Driver* for setting
> the good class in DriverManager
>
> then I launch the following command
>
> *./j2eeadmin -addJdbcXADatasource jdbc/name
> org.postgresql.jdbc3.Jdbc3ConnectionPool -props serverName=myServer
> portNumber=5432 databaseName=nameDB user=myPostgresqlUser
> *
> when I start the server I haven't any problems but after .....
>
>
> Do you know if I can use this driver and how I must declare my databases
>
>
> Thank you in advance
>
>
> phMayre


Re: Postgresql and J2ee

From
"philippe.mayre"
Date:
  Barry Lind wrote:

> Philippe,
>
> The Postgres database doesn't support two-phase commits and therefore
> also doesn't support the XA protocol.  Thus the jdbc driver can't
> expose functionality that doesn't exist in the database.
>
> --Barry
>
> philippe.mayre wrote:
>
>>   dear support,
>>
>> I would like to use two PostgreSql 7.3 XA Databases rather than
>> XACloudscape with my j2ee application but when I deploy it on the
>> server, this one throws the following exception :
>>
>> * java.lang.ClassCastException
>>         at
>> com.sun.enterprise.resource.SystemJdbc20XaAllocator.createResource(SystemJdbc20XaAllocator.java:39)
>>
>>         at
>> com.sun.enterprise.resource.PoolManagerImpl.getResourceFromPool(PoolManagerImpl.java:177)
>>
>>         at
>> com.sun.enterprise.resource.SystemJdbcDataSource.internalGetConnection(SystemJdbcDataSource.java:72)
>>
>>         at
>> com.sun.enterprise.resource.SystemJdbcDataSource.getConnection(SystemJdbcDataSource.java:50)
>>
>>         at
>> com.sun.ejb.persistence.PersistenceManagerImpl.getConnection(PersistenceManagerImpl.java:588)
>>
>>         at
>> com.sun.ejb.persistence.PersistenceManagerImpl.getConnection(PersistenceManagerImpl.java:573)
>>
>>         at
>> com.sun.ejb.persistence.PMDeployerImpl.createTable(PMDeployerImpl.java:201)
>>
>>         at
>> com.sun.ejb.persistence.PMDeployerImpl.ejbJarDeployed(PMDeployerImpl.java:68)
>>
>>         at
>> com.sun.enterprise.tools.deployment.backend.JarManagerImpl.loadJar(JarManagerImpl.java:141)
>>
>>         at
>> com.sun.enterprise.tools.deployment.backend.JarInstallerImpl.deployEjbs(JarInstallerImpl.java:727)
>>
>>         at
>> com.sun.enterprise.tools.deployment.backend.JarInstallerImpl.deployApplication(JarInstallerImpl.java:221)
>>
>>         at
>> org.omg.stub.com.sun.enterprise.tools.deployment.backend._JarInstallerImpl_Tie._invoke(Unknown
>> Source)
>>         at
>> com.sun.corba.ee.internal.corba.ServerDelegate.dispatch(ServerDelegate.java:355)
>>
>>         at com.sun.corba.ee.internal.iiop.ORB.process(ORB.java:255)
>>         at
>> com.sun.corba.ee.internal.iiop.RequestProcessor.process(RequestProcessor.java:84)
>>
>>         at
>> com.sun.corba.ee.internal.orbutil.ThreadPool$PooledThread.run(ThreadPool.java:99)*
>>
>>
>> * I use j2ee 1.3 with j2sdk 1.4 .1*
>>
>> the features on my linux system are :
>>
>> in .bash_profile *export
>> CLASSPATH=.:$JAVA_HOME/lib/j2ee.jar:/usr/share/pgsql/pg73jdbc3.jar*
>>
>> in $J2EE_HOME/bin/userconfig.sh export
>> *J2EE_CLASSPATH=/usr/share/pgsql/pg73jdbc3.jar*
>>
>> in $J2EE_HOME/bin/cloudscape file I change
>> *COM.cloudscape.core.JDBCDriver* by *org.postgresql.Driver* for
>> setting the good class in DriverManager
>>
>> then I launch the following command
>>
>> *./j2eeadmin -addJdbcXADatasource jdbc/name
>> org.postgresql.jdbc3.Jdbc3ConnectionPool -props serverName=myServer
>> portNumber=5432 databaseName=nameDB user=myPostgresqlUser
>> *
>> when I start the server I haven't any problems but after .....
>>
>>
>> Do you know if I can use this driver and how I must declare my databases
>>
>>
>> Thank you in advance
>>
>>
>> phMayre
>
>
>
>
Barry and Chris thank you so much for your answer,

In fact, my application contains two ejbs and each other inserts some
data in two databases during the same transaction. I tried to use the
same database for all and its ok .....

Here is what I done :

I declared the database as follow on my server

j2eeadmin jdbc/name jdbc:posgresql://host:5432/nameDB

then I changed the ressource in the runtime descriptor of my application.

regards

Philippe