|
Hi,
I'm trying to store in Oracle database an attribute
implementing a java serializable Class :
I modified the JOnAS exemple AccountImplBean like
this :
public class AccountImplBean implements EntityBean
{
....
public int
accno;
public String customer; public double balance; public SVector myObject; ... public AccountBeanPK
ejbCreate(int val_accno, String val_customer, double val_balance, SVector
myObject)
throws CreateException { // Init object state
accno = val_accno; customer = val_customer; balance = val_balance; this.myObject = myObject; return null; } public void ejbPostCreate(int
val_accno, String val_customer, double val_balance, SVector myObject)
{
} ...
-----> where SVector is a simple serializable
java Vector Object :
public class SVector extends java.util.Vector
implements java.io.Serializable
{ public SVector () { super(); } } -----> I modified
the ejb-jar.xml file as follow :
....
<cmp-field>
<field-name>balance</field-name> </cmp-field> <cmp-field> <field-name>myObject</field-name> </cmp-field> ... -----> and
jonas-ejb-jar.xml :
<cmp-field-jdbc-mapping>
<field-name>balance</field-name> <jdbc-field-name>balance</jdbc-field-name> </cmp-field-jdbc-mapping> <cmp-field-jdbc-mapping> <field-name>myObject</field-name> <jdbc-field-name>myobject</jdbc-field-name> </cmp-field-jdbc-mapping> -----> the Oracle
table is built using the script :
drop table accountsample;
create table accountsample ( accno integer primary key, customer varchar(30), balance number(15, 4), myobject BLOB ); insert into accountsample values(101, 'Antoine de St Exupery', 200.00,null); insert into accountsample values(102, 'alexandre dumas fils', 400.00,null); insert into accountsample values(103, 'conan doyle', 500.00,null); insert into accountsample values(104, 'alfred de musset', 100.00,null); insert into accountsample values(105, 'phileas lebegue', 350.00,null); insert into accountsample values(106, 'alphonse de lamartine', 650.00,null); -----> The Client
runs, create a new bean instance :
SVector zob = new
SVector();
zob.add("test"); try { System.out.println("Create a new Account in database, number "+args[2]); home.create(Integer.parseInt(args[2]),"new client",1000.00,zob); } catch (CreateException ce) { System.out.println("Cannot create account number "+args[2]); ce.printStackTrace(); } -----> The
Creation happens well and the finder method also :
Account acc2 =
null;
try { acc2 = home.findByNumber(Integer.parseInt(args[2])); } catch (Exception e) { System.err.println("Cannot find Account"); e.printStackTrace(); } -----> But when
trying to access bean attribute :
try
{ System.out.println("Account "+ acc2.getNumber() + " found"); } catch (Exception e) { System.out.println("Cannot access getNumber method"); e.printStackTrace(); } -----> I get an
EJBException :
Cannot access getNumber
method
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: java.rmi.RemoteException: Got exception in activate:; nested exception is: javax.ejb.EJBException java.rmi.RemoteException: Got exception in activate:; nested exception is: javax.ejb.EJBException javax.ejb.EJBException at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:245) at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:220) at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:354) at org.objectweb.jonas.rmifilters.RemoteStub.invoke(RemoteStub.java:87) at ismarttechnology.smartycart.smartycartwebos.debug.JOnASAccountImplRemote_Stub.getNumber(JOnASAccountImplRemote_Stub.java:211) at ismarttechnology.smartycart.smartycartwebos.debug.ClientSave.main(ClientSave.java:99) Does Jonas support attributes mapping to BLOB
?
What did I do wrong ?
Thanx in advance
Thomas
DANDELOT
|
- Re: Using Serializable Attributes and Oracle BLOB with Con... Thomas DANDELOT
- Re: Using Serializable Attributes and Oracle BLOB wit... H�l�ne JOANIN
- Re: Using Serializable Attributes and Oracle BLOB wit... H�l�ne JOANIN
