Norrie,
I tried to do a similar thing a while ago - same deal, postgres/CMP - with
a similar (if not identical) result. From memory this is caused by
postgres weirdness. Someone correct me if I'm wrong, but its got
something to do with postgres requiring a new? transaction for
reading/writing blobs (byte[]).
Anyway, a workaround suggested to me, which I've been using successfully
for a few months now is to encode the data as Byte64 and store it as plain
text.
hope this helps,
cheesr
dim
On Thu, 19 Jul 2001 [EMAIL PROTECTED] wrote:
>
>
> I have a simple entity bean which is used to hold serialized objects. It
> worked
> fine with InstantDB but fails with postgresql. I tried upgrading to
> postgresql
> 7.1.2 from 6.5.3 but that did not fix the problem. I have written a
> small bean
> to reproduce the problem which is listed below.
>
> Any help or pointers would be much appreciated.
>
> Thanks
>
> Norrie
>
> -----
>
> The client catches the following exception when doing the create
>
> java.lang.reflect.UndeclaredThrowableException:
> javax.transaction.HeuristicRollbackException
> at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:229)
> at
> org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker_Stub.invokeHome(Unknown
> Source)
> at
> org.jboss.ejb.plugins.jrmp.interfaces.HomeProxy.invoke(HomeProxy.java:248)
> at $Proxy0.create(Unknown Source)
> at proftest.Client.main(Client.java:19)
>
> postgres postmaster produces:
>
> pq_recvbuf: recv() failed: Broken pipe
>
> The JBoss server log file contains:
>
> [JAWS] FastPath protocol error: Z
> [JAWS] at postgresql.fastpath.Fastpath.fastpath(Fastpath.java:159)
> [JAWS] at postgresql.fastpath.Fastpath.fastpath(Fastpath.java:188)
> [JAWS] at postgresql.fastpath.Fastpath.getInteger(Fastpath.java:200)
> [JAWS] at
> postgresql.largeobject.LargeObjectManager.create(LargeObjectManager.java:162)
> [JAWS] at
> postgresql.jdbc2.PreparedStatement.setBytes(PreparedStatement.java:298)
> [JAWS] at
>
>org.opentools.minerva.jdbc.PreparedStatementInPool.setBytes(PreparedStatementInPool.java:192)
> [JAWS] at
> org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand.setParameter(JDBCCommand.java:321)
> [JAWS] at
>
>org.jboss.ejb.plugins.jaws.jdbc.JDBCCreateEntityCommand.setParameters(JDBCCreateEntityCommand.java:165)
> [JAWS] at
> org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand.jdbcExecute(JDBCCommand.java:159)
> [JAWS] at
>
>org.jboss.ejb.plugins.jaws.jdbc.JDBCCreateEntityCommand.execute(JDBCCreateEntityCommand.java:135)
> [JAWS] at
>
>org.jboss.ejb.plugins.jaws.JAWSPersistenceManager.createEntity(JAWSPersistenceManager.java:122)
> [JAWS] at
>
>org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManager.java:207)
> [JAWS] at
> org.jboss.ejb.EntityContainer.createHome(EntityContainer.java:441)
> [JAWS] at java.lang.reflect.Method.invoke(Native Method)
> [JAWS] at
>
>org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:639)
> [JAWS] at
>
>org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:160)
> [JAWS] at
>
>org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:87)
> [JAWS] at
> org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:135)
> [JAWS] at
> org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:263)
> [JAWS] at
> org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:86)
> [JAWS] at
> org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:164)
> [JAWS] at
> org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:106)
> [JAWS] at
> org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:316)
> [JAWS] at
>
>org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invokeHome(JRMPContainerInvoker.java:369)
> [JAWS] at java.lang.reflect.Method.invoke(Native Method)
> [JAWS] at
> sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:241)
> [JAWS] at sun.rmi.transport.Transport$1.run(Transport.java:142)
> [JAWS] at java.security.AccessController.doPrivileged(Native Method)
> [JAWS] at sun.rmi.transport.Transport.serviceCall(Transport.java:139)
> [JAWS] at
> sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:443)
> [JAWS] at
> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:643)
> [JAWS] at java.lang.Thread.run(Thread.java:484)
> [JAWS] FastPath protocol error: Z
> [JAWS] at postgresql.fastpath.Fastpath.fastpath(Fastpath.java:159)
> [JAWS] at postgresql.fastpath.Fastpath.fastpath(Fastpath.java:188)
> [JAWS] at postgresql.fastpath.Fastpath.getInteger(Fastpath.java:200)
> [JAWS] at
> postgresql.largeobject.LargeObjectManager.create(LargeObjectManager.java:162)
> [JAWS] at
> postgresql.jdbc2.PreparedStatement.setBytes(PreparedStatement.java:298)
> [JAWS] at
>
>org.opentools.minerva.jdbc.PreparedStatementInPool.setBytes(PreparedStatementInPool.java:192)
> [JAWS] at
> org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand.setParameter(JDBCCommand.java:321)
> [JAWS] at
>
>org.jboss.ejb.plugins.jaws.jdbc.JDBCCreateEntityCommand.setParameters(JDBCCreateEntityCommand.java:165)
> [JAWS] at
> org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand.jdbcExecute(JDBCCommand.java:159)
> [JAWS] at
>
>org.jboss.ejb.plugins.jaws.jdbc.JDBCCreateEntityCommand.execute(JDBCCreateEntityCommand.java:135)
> [JAWS] at
>
>org.jboss.ejb.plugins.jaws.JAWSPersistenceManager.createEntity(JAWSPersistenceManager.java:122)
> [JAWS] at
>
>org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManager.java:207)
> [JAWS] at
> org.jboss.ejb.EntityContainer.createHome(EntityContainer.java:441)
> [JAWS] at java.lang.reflect.Method.invoke(Native Method)
> [JAWS] at
>
>org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:639)
> [JAWS] at
>
>org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:160)
> [JAWS] at
>
>org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:87)
> [JAWS] at
> org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:135)
> [JAWS] at
> org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:263)
> [JAWS] at
> org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:86)
> [JAWS] at
> org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:164)
> [JAWS] at
> org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:106)
> [JAWS] at
> org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:316)
> [JAWS] at
>
>org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invokeHome(JRMPContainerInvoker.java:369)
> [JAWS] at java.lang.reflect.Method.invoke(Native Method)
> [JAWS] at
> sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:241)
> [JAWS] at sun.rmi.transport.Transport$1.run(Transport.java:142)
> [JAWS] at java.security.AccessController.doPrivileged(Native Method)
> [JAWS] at sun.rmi.transport.Transport.serviceCall(Transport.java:139)
> [JAWS] at
> sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:443)
> [JAWS] at
> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:643)
> [JAWS] at java.lang.Thread.run(Thread.java:484)
>
> The following code reproduces the problem.
>
> Test interface code:
>
> package proftest;
>
> import java.rmi.RemoteException;
> import javax.ejb.EJBHome;
> import javax.ejb.Handle;
> import javax.ejb.EJBObject;
>
> public interface Test extends EJBObject {
> public void store(byte data[]) throws RemoteException;
> public byte[] restore() throws RemoteException;
> }
>
> TestHome code:
>
> package proftest;
>
> import java.rmi.RemoteException;
> import javax.ejb.EJBHome;
> import javax.ejb.CreateException;
> import javax.ejb.FinderException;
>
> public interface TestHome extends EJBHome {
> public Test create(String key, byte data[] ) throws RemoteException,
> CreateException;
> public Test findByPrimaryKey(String key) throws RemoteException,
> FinderException;
> }
>
>
> TestBean code:
>
> package proftest;
>
> import javax.ejb.EntityBean;
> import javax.ejb.EntityContext;
>
> public class TestBean implements EntityBean {
>
> public String key;
> public byte data[];
>
> public String ejbCreate(String key, byte data[] ) {
> this.key=key;
> this.data=data;
> return null;
> }
>
> public void ejbPostCreate(String key, byte data[] ) {
> }
>
> public void store(byte data[]) {
> this.data=data;
> }
>
> public byte[] restore() {
> return data;
> }
>
> public void ejbActivate() throws javax.ejb.EJBException,
> java.rmi.RemoteException {}
> public void ejbLoad() throws javax.ejb.EJBException,
> java.rmi.RemoteException {}
> public void ejbPassivate() throws javax.ejb.EJBException,
> java.rmi.RemoteException {}
> public void ejbRemove() throws javax.ejb.RemoveException,
> javax.ejb.EJBException, java.rmi.RemoteException {}
> public void ejbStore() throws javax.ejb.EJBException,
> java.rmi.RemoteException {}
> public void setEntityContext(EntityContext parm1) throws
> javax.ejb.EJBException, java.rmi.RemoteException {}
> public void unsetEntityContext() throws javax.ejb.EJBException,
> java.rmi.RemoteException {}
> }
>
>
>
> Client program:
>
> package proftest;
>
> import javax.naming.Context;
>
> public class Client {
>
> public static void main(String[] args) {
> try {
>
>
>System.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
> System.setProperty("java.naming.provider.url","localhost:1099");
> Context jndiContext=new javax.naming.InitialContext();
> Object obj = jndiContext.lookup("Test");
> TestHome testHome =
> (TestHome)javax.rmi.PortableRemoteObject.narrow(obj,
> TestHome.class);
> byte data[]=new byte[5];
> for ( byte i=0; i<4; i++ )
> data[i]=i;
>
> testHome.create("test",data);
> } catch (Exception ex ) {
> ex.printStackTrace(System.err);
> }
> }
> }
>
> The ejb-jar file is:
>
> <ejb-jar>
> <enterprise-beans>
> <entity>
> <description>Test of CMP for byte[] </description>
> <ejb-name>Test</ejb-name>
> <home>proftest.TestHome</home>
> <remote>proftest.Test</remote>
> <ejb-class>proftest.TestBean</ejb-class>
> <persistence-type>Container</persistence-type>
> <prim-key-class>java.lang.String</prim-key-class>
> <reentrant>False</reentrant>
> <cmp-field>
> <field-name>key</field-name>
> </cmp-field>
> <cmp-field>
> <field-name>data</field-name>
> </cmp-field>
> <primkey-field>key</primkey-field>
> </entity>
> </enterprise-beans>
> </ejb-jar>
>
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-user
>
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user