Title: RE: [JBoss-user] Re: Unable to load a ResultSet column into a variable of type '[B'

Dmitri,

If I understand what you are doing there is another approach instead of
attempting to store a byte[].  Take the encrypted byte[] and run it through
a Base64 conversion and out pops a String you can easily store/retrieve. 

John




-----Original Message-----
From: Burkhard Vogel [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 03, 2001 3:05 AM
To: [EMAIL PROTECTED]
Subject: Re: [JBoss-user] Re: Unable to load a ResultSet column into a
variable of type '[B'


Hi,
byte is AFAIK a primitive type. To use it as Primary Key you need to to
define a helper class as primary key, which declares a byte var as it only
member. I had this problem when trying to use a GUID as Primary key
(VARBINARY(16)). Look like this:

public class GuidPK implements Serializable {
    public byte guid[];

    public GuidPK(byte _guid[]) {
        guid = _guid;
    }
    public boolean equals(Object obj) {
        if( this.getClass().equals(obj.getClass()) ) {
            GuidPK that = (GuidPK)obj;
            return (this.guid==that.guid);
        }
        return false;
    }
    public int hashCode() {
        return super.hashCode();
    }
    public String toString() {
        GUID tmp=null;
        try {
            tmp = new GUID();
            tmp.setBytes(guid); } catch(Exception Ex) {}
        String result = tmp.toFormattedGuid();
        return result;
    }
}
Burkhard

----- Original Message -----
From: "Dmitri Colebatch" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, May 03, 2001 10:06 AM
Subject: [JBoss-user] Re: Unable to load a ResultSet column into a variable
of type '[B'


> A question I should've posed last time is could this be a problem with the
> Postgres driver?  In the JBoss doco it notes that the driver can have a
> problem with large long values....  I'm not sure about this, but if
someone
> who knows more about this could give it 2 minutes thought?
>
> cheers, tia again
> dim
>
> On Thu,  3 May 2001 17:35, Dmitri Colebatch wrote:
> > Hi all,
> >
> > (could any replies to this come directly to me as well as the list
please -
> > I get the list in digest mode)
> >
> > I have a basic CMP entity bean that models a user's account in a system,
> > and I have a password field that I need to encrypt.  This is a very
simple
> > example, but you'll see my problem from it.
> >
> > I have the password field declared as a byte[], but get/set methods have
> > String param/return type.  My methods are then:
> >
> > public void setPassword(String password) { this.password =
> > password.getBytes(); }
> > public String getPassword() { return new String(password); }
> >
> > This all seems to work fine, but it breaks some of my other test cases.
I
> > haven't been able to identify exactly what the circumstances are that
cause
> > it, but basically after a call to remove() on the bean I get the
following
> > exception:
> >
> > java.sql.SQLException: Unable to load a ResultSet column into a variable
of
> > type '[B': java.io.StreamCorruptedException: InputStream does not
contain a
> > serialized object
> >
> > I only get this exception in some cases, and I haven't been able to
> > replicate it in isolation away from the other tests.  I'm running on
> > Postgres, and JBoss 2.1 with Sun 1.3 JVM.
> >
> > When JBoss creates the table, it creates the password column as an "oid"
> > type - I dont know what this is, but if I do a JDBC query on it I get an
> > Integer type.  I can also get it as a Blob, but Postgres' Blob isn't
fully
> > implemented so I haven't been able to determine a lot from that.
> >
> > The value is never null - I found a previous mail that had the same
> > exception from trying to put a null value into a primitive int type.
> >
> > I have very little idea what the exact cause of this is, any help would
be
> > apprecitated - see the stack trace below.
> >
> > cheers, tia for any help
> > dim
> >
> > Stack trace:  (edited to make readable)
> >
> >  [Account] TRANSACTION ROLLBACK EXCEPTION:Load failed; nested exception
is:
> >  java.sql.SQLException: Unable to load a ResultSet column into a
variable
> > of type '[B': java.io.StreamCorruptedException: InputStream does not
> > contain a serialized object; nested exception is:
> >  java.rmi.ServerException: Load failed; nested exception is:
> >  java.sql.SQLException: Unable to load a ResultSet column into a
variable
> > of type '[B': java.io.StreamCorruptedException: InputStream does not
> > contain a serialized object
> >  [Account] java.rmi.ServerException: Load failed; nested exception is:
> >  [Account] java.sql.SQLException: Unable to load a ResultSet column into
a
> > variable of type '[B': java.io.StreamCorruptedException: InputStream
does
> > not contain a serialized object
> >  [Account] java.sql.SQLException: Unable to load a ResultSet column into
a
> > variable of type '[B': java.io.StreamCorruptedException: InputStream
does
> > not contain a serialized object
> >  [Account] at
> >
org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand.getResultObject(JDBCCommand.jav
> >a: 482) [Account] at
> >
org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand.getResultObject(JDBCCommand.jav
> >a: 498) [Account] at
> >
org.jboss.ejb.plugins.jaws.jdbc.JDBCLoadEntityCommand.handleResult(JDBCLoad
> >En tityCommand.java:115) [Account] at
> >
org.jboss.ejb.plugins.jaws.jdbc.JDBCQueryCommand.executeStatementAndHandleR
> >es ult(JDBCQueryCommand.java:59) [Account] at
> >
org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand.jdbcExecute(JDBCCommand.java:15
> >9) [Account] at
> >
org.jboss.ejb.plugins.jaws.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntit
> >yC ommand.java:78) [Account] at
> >
org.jboss.ejb.plugins.jaws.JAWSPersistenceManager.loadEntity(JAWSPersistenc
> >eM anager.java:150) [Account] at
> >
org.jboss.ejb.plugins.CMPPersistenceManager.loadEntity(CMPPersistenceManage
> >r. java:341) [Account] at
> >
org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchro
> >ni zationInterceptor.java:192) [Account] at
> >
org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterc
> >ep tor.java:186) [Account] at
> >
org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:133
> >) [Account] at
> >
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT
> >.j ava:263) [Account] at
> > org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:99)
> >  [Account] at
> >
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:1
> >77 ) [Account] at
> > org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:195)
> >  [Account] at
> > org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:323) [Account]
> > at
> >
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainer
> >In voker.java:471) [Account] at
> >
org.jboss.ejb.plugins.jrmp.interfaces.EntityProxy.invoke(EntityProxy.java:1
> >46 ) [Account] at $Proxy16.getBdoId(Unknown Source)
> >  [Account] at
> >
com.nuix.bdo.connection.ConnectionManagerEJB.removeConnection(ConnectionMan
> >ag erEJB.java:148) [Account] at java.lang.reflect.Method.invoke(Native
> > Method) [Account] at
> >
org.jboss.ejb.StatefulSessionContainer$ContainerInterceptor.invoke(Stateful
> >Se ssionContainer.java:570) [Account] at
> >
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:1
> >77 ) [Account] at
> >
org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor.invoke(StatefulSes
> >si onInstanceInterceptor.java:206) [Account] at
> >
org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:133
> >) [Account] at
> >
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT
> >.j ava:263) [Account] at
> > org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:99)
> >  [Account] at
> > org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:195)
> >  [Account] at
> >
org.jboss.ejb.StatefulSessionContainer.invoke(StatefulSessionContainer.java
> >:3 26) [Account] at
> >
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainer
> >In voker.java:471) [Account] at
> >
org.jboss.ejb.plugins.jrmp.interfaces.StatefulSessionProxy.invoke(StatefulS
> >es sionProxy.java:150) [Account] at $Proxy12.removeConnection(Unknown
> > Source) [Account] at
> >
com.nuix.interceptor.interpretor.DeleteConnectionInterpretor.execute(Delete
> >Co nnectionInterpretor.java:149) [Account] at
> > com.nuix.interceptor.InterceptorEJB.execute(InterceptorEJB.java:127)
> >  [Account] at java.lang.reflect.Method.invoke(Native Method)
> >  [Account] at
> >
org.jboss.ejb.StatefulSessionContainer$ContainerInterceptor.invoke(Stateful
> >Se ssionContainer.java:570) [Account] at
> >
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:1
> >77 ) [Account] at
> >
org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor.invoke(StatefulSes
> >si onInstanceInterceptor.java:206) [Account] at
> >
org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:133
> >) [Account] at
> >
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT
> >.j ava:263) [Account] at
> > org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:99)
> >  [Account] at
> > org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:195)
> >  [Account] at
> >
org.jboss.ejb.StatefulSessionContainer.invoke(StatefulSessionContainer.java
> >:3 26) [Account] at
> >
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainer
> >In voker.java:381) [Account] at java.lang.reflect.Method.invoke(Native
> > Method) [Account] at
> > sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:241)
> >  [Account] at sun.rmi.transport.Transport$1.run(Transport.java:142)
> >  [Account] at java.security.AccessController.doPrivileged(Native Method)
> >  [Account] at
sun.rmi.transport.Transport.serviceCall(Transport.java:139)
> >  [Account] at
> > sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:443)
> >  [Account] at
> >
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:
> >64 3) [Account] at java.lang.Thread.run(Thread.java:484)
> >
> > -------------------------------------------------------
>
> _______________________________________________
> 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

Reply via email to