Boa tarde pessoal!
Usei o JPublisher para gerar as classes pelos types do Oracle, quando envio instância do CustomerAQ para fila JMS funciona ou mesmo quando tenho outro objeto com relacionamento de 1 para 1 funciona também. O problema é quando tenho um relacionamento de 1 para muitos, no caso AddressListAQ que tem um array de AddressAQ[], recebo a mensagem java.sql.SQLException: Falha ao construir descritor: Invalid arguments.
O servidor é BEA 10, Oracle 10.
Alguém tem uma luz?
Nem sei como ele consegue se conectar com Oracle (brisa :shock: )!
Muito obrigado!
Segue abaixo o código gerado e a stacktrace
Classes geradas pelo JPublisher
import java.sql.SQLException;
import java.sql.Connection;
import oracle.jdbc.OracleTypes;
import oracle.sql.ORAData;
import oracle.sql.ORADataFactory;
import oracle.sql.Datum;
import oracle.sql.STRUCT;
import oracle.jpub.runtime.MutableStruct;
public class CustomerAQ implements ORAData, ORADataFactory, java.io.Serializable
{
public static final String _SQL_NAME = "CUSTOMER_AQTP";
public static final int _SQL_TYPECODE = OracleTypes.STRUCT;
transient protected MutableStruct _struct;
private static int[] _sqlType = { 12,12,12,12,12,2002,12,12,12,12,2003,12,12,12,2003,2003,12,12,12 };
private static ORADataFactory[] _factory = new ORADataFactory[19];
static
{
_factory[5] = BrandAQ.getORADataFactory();
_factory[10] = PhoneListAQ.getORADataFactory();
_factory[14] = AddressListAQ.getORADataFactory();
_factory[15] = OptlnListAQ.getORADataFactory();
}
protected static final CustomerAQ _CustomerAQFactory = new CustomerAQ(false);
public static ORADataFactory getORADataFactory()
{ return _CustomerAQFactory; }
/* constructor */
protected CustomerAQ(boolean init)
{ if(init) _struct = new MutableStruct(new Object[19], _sqlType, _factory); }
public CustomerAQ()
{ this(true); }
public CustomerAQ(String sitecustomerid, String customerid, String typeS, String nameS, String email, BrandAQ brandinfo, String gender, String birthdate, String nickname, String relationshiptype, PhoneListAQ phonelist, String documentnumber, String istaxpayer, String stateinscription, AddressListAQ addresslist, OptlnListAQ optlnlist, String creationdate, String isblacklisted, String username) throws SQLException
{ this(true);
setSitecustomerid(sitecustomerid);
setCustomerid(customerid);
setTypeS(typeS);
setNameS(nameS);
setEmail(email);
setBrandinfo(brandinfo);
setGender(gender);
setBirthdate(birthdate);
setNickname(nickname);
setRelationshiptype(relationshiptype);
setPhonelist(phonelist);
setDocumentnumber(documentnumber);
setIstaxpayer(istaxpayer);
setStateinscription(stateinscription);
setAddresslist(addresslist);
setOptlnlist(optlnlist);
setCreationdate(creationdate);
setIsblacklisted(isblacklisted);
setUsername(username);
}
/* ORAData interface */
public Datum toDatum(Connection c) throws SQLException
{
return _struct.toDatum(c, _SQL_NAME);
}
/* ORADataFactory interface */
public ORAData create(Datum d, int sqlType) throws SQLException
{ return create(null, d, sqlType); }
protected ORAData create(CustomerAQ o, Datum d, int sqlType) throws SQLException
{
if (d == null) return null;
if (o == null) o = new CustomerAQ(false);
o._struct = new MutableStruct((STRUCT) d, _sqlType, _factory);
return o;
}
/* Serialization interface */
public void restoreConnection(Connection conn) throws SQLException
{ if (getBrandinfo()!=null) getBrandinfo().restoreConnection(conn);
if (getPhonelist()!=null) getPhonelist().restoreConnection(conn);
if (getAddresslist()!=null) getAddresslist().restoreConnection(conn);
if (getOptlnlist()!=null) getOptlnlist().restoreConnection(conn);
}
private void writeObject(java.io.ObjectOutputStream oos)
throws java.io.IOException, SQLException
{ oos.defaultWriteObject();
oos.writeObject(getSitecustomerid());
oos.writeObject(getCustomerid());
oos.writeObject(getTypeS());
oos.writeObject(getNameS());
oos.writeObject(getEmail());
oos.writeObject(getBrandinfo());
oos.writeObject(getGender());
oos.writeObject(getBirthdate());
oos.writeObject(getNickname());
oos.writeObject(getRelationshiptype());
oos.writeObject(getPhonelist());
oos.writeObject(getDocumentnumber());
oos.writeObject(getIstaxpayer());
oos.writeObject(getStateinscription());
oos.writeObject(getAddresslist());
oos.writeObject(getOptlnlist());
oos.writeObject(getCreationdate());
oos.writeObject(getIsblacklisted());
oos.writeObject(getUsername());
}
private void readObject(java.io.ObjectInputStream ois)
throws java.io.IOException, ClassNotFoundException, java.sql.SQLException
{ ois.defaultReadObject();
Object[] o = new Object[19];
o[0] = ois.readObject();
o[1] = ois.readObject();
o[2] = ois.readObject();
o[3] = ois.readObject();
o[4] = ois.readObject();
o[5] = ois.readObject();
o[6] = ois.readObject();
o[7] = ois.readObject();
o[8] = ois.readObject();
o[9] = ois.readObject();
o[10] = ois.readObject();
o[11] = ois.readObject();
o[12] = ois.readObject();
o[13] = ois.readObject();
o[14] = ois.readObject();
o[15] = ois.readObject();
o[16] = ois.readObject();
o[17] = ois.readObject();
o[18] = ois.readObject();
_struct = new MutableStruct(o, _sqlType, _factory);
}
/* accessor methods */
public String getSitecustomerid() throws SQLException
{ return (String) _struct.getAttribute(0); }
public void setSitecustomerid(String sitecustomerid) throws SQLException
{ _struct.setAttribute(0, sitecustomerid); }
public String getCustomerid() throws SQLException
{ return (String) _struct.getAttribute(1); }
public void setCustomerid(String customerid) throws SQLException
{ _struct.setAttribute(1, customerid); }
public String getTypeS() throws SQLException
{ return (String) _struct.getAttribute(2); }
public void setTypeS(String typeS) throws SQLException
{ _struct.setAttribute(2, typeS); }
public String getNameS() throws SQLException
{ return (String) _struct.getAttribute(3); }
public void setNameS(String nameS) throws SQLException
{ _struct.setAttribute(3, nameS); }
public String getEmail() throws SQLException
{ return (String) _struct.getAttribute(4); }
public void setEmail(String email) throws SQLException
{ _struct.setAttribute(4, email); }
public BrandAQ getBrandinfo() throws SQLException
{ return (BrandAQ) _struct.getAttribute(5); }
public void setBrandinfo(BrandAQ brandinfo) throws SQLException
{ _struct.setAttribute(5, brandinfo); }
public String getGender() throws SQLException
{ return (String) _struct.getAttribute(6); }
public void setGender(String gender) throws SQLException
{ _struct.setAttribute(6, gender); }
public String getBirthdate() throws SQLException
{ return (String) _struct.getAttribute(7); }
public void setBirthdate(String birthdate) throws SQLException
{ _struct.setAttribute(7, birthdate); }
public String getNickname() throws SQLException
{ return (String) _struct.getAttribute(8); }
public void setNickname(String nickname) throws SQLException
{ _struct.setAttribute(8, nickname); }
public String getRelationshiptype() throws SQLException
{ return (String) _struct.getAttribute(9); }
public void setRelationshiptype(String relationshiptype) throws SQLException
{ _struct.setAttribute(9, relationshiptype); }
public PhoneListAQ getPhonelist() throws SQLException
{ return (PhoneListAQ) _struct.getAttribute(10); }
public void setPhonelist(PhoneListAQ phonelist) throws SQLException
{ _struct.setAttribute(10, phonelist); }
public String getDocumentnumber() throws SQLException
{ return (String) _struct.getAttribute(11); }
public void setDocumentnumber(String documentnumber) throws SQLException
{ _struct.setAttribute(11, documentnumber); }
public String getIstaxpayer() throws SQLException
{ return (String) _struct.getAttribute(12); }
public void setIstaxpayer(String istaxpayer) throws SQLException
{ _struct.setAttribute(12, istaxpayer); }
public String getStateinscription() throws SQLException
{ return (String) _struct.getAttribute(13); }
public void setStateinscription(String stateinscription) throws SQLException
{ _struct.setAttribute(13, stateinscription); }
public AddressListAQ getAddresslist() throws SQLException
{ return (AddressListAQ) _struct.getAttribute(14); }
public void setAddresslist(AddressListAQ addresslist) throws SQLException
{ _struct.setAttribute(14, addresslist); }
public OptlnListAQ getOptlnlist() throws SQLException
{ return (OptlnListAQ) _struct.getAttribute(15); }
public void setOptlnlist(OptlnListAQ optlnlist) throws SQLException
{ _struct.setAttribute(15, optlnlist); }
public String getCreationdate() throws SQLException
{ return (String) _struct.getAttribute(16); }
public void setCreationdate(String creationdate) throws SQLException
{ _struct.setAttribute(16, creationdate); }
public String getIsblacklisted() throws SQLException
{ return (String) _struct.getAttribute(17); }
public void setIsblacklisted(String isblacklisted) throws SQLException
{ _struct.setAttribute(17, isblacklisted); }
public String getUsername() throws SQLException
{ return (String) _struct.getAttribute(18); }
public void setUsername(String username) throws SQLException
{ _struct.setAttribute(18, username); }
}
import java.sql.SQLException;
import java.sql.Connection;
import oracle.jdbc.OracleTypes;
import oracle.sql.ORAData;
import oracle.sql.ORADataFactory;
import oracle.sql.Datum;
import oracle.sql.ARRAY;
import oracle.sql.ArrayDescriptor;
import oracle.jpub.runtime.MutableArray;
public class AddressListAQ implements ORAData, ORADataFactory, java.io.Serializable
{
public static final String _SQL_NAME = "CUSTCUSTOMER_ADDR_T_AQTP";
public static final int _SQL_TYPECODE = OracleTypes.ARRAY;
transient MutableArray _array;
private static final AddressListAQ _AddressListAQFactory = new AddressListAQ();
public static ORADataFactory getORADataFactory()
{ return _AddressListAQFactory; }
/* constructors */
public AddressListAQ()
{
this((AddressAQ[])null);
}
public AddressListAQ(AddressAQ[] a)
{
_array = new MutableArray(2002, a, AddressAQ.getORADataFactory());
}
/* ORAData interface */
public Datum toDatum(Connection c) throws SQLException
{
return _array.toDatum(c, _SQL_NAME);
}
/* ORADataFactory interface */
public ORAData create(Datum d, int sqlType) throws SQLException
{
if (d == null) return null;
AddressListAQ a = new AddressListAQ();
a._array = new MutableArray(2002, (ARRAY) d, AddressAQ.getORADataFactory());
return a;
}
public int length() throws SQLException
{
return _array.length();
}
public int getBaseType() throws SQLException
{
return _array.getBaseType();
}
public String getBaseTypeName() throws SQLException
{
return _array.getBaseTypeName();
}
public ArrayDescriptor getDescriptor() throws SQLException
{
return _array.getDescriptor();
}
/* Serialization interface */
public void restoreConnection(Connection conn) throws SQLException
{ AddressAQ[] a = (AddressAQ[])getArray();
for (int i=0; i<a.length; i++) { a[i].restoreConnection(conn); }
}
private void writeObject(java.io.ObjectOutputStream oos)
throws java.io.IOException, SQLException
{ oos.defaultWriteObject();
oos.writeObject(getArray());
}
private void readObject(java.io.ObjectInputStream ois)
throws java.io.IOException, ClassNotFoundException, java.sql.SQLException
{ ois.defaultReadObject();
AddressAQ[] a = (AddressAQ[]) ois.readObject();
_array = new MutableArray(2002, a, AddressAQ.getORADataFactory());
}
/* array accessor methods */
public AddressAQ[] getArray() throws SQLException
{
return (AddressAQ[]) _array.getObjectArray(
new AddressAQ[_array.length()]);
}
public void setArray(AddressAQ[] a) throws SQLException
{
_array.setObjectArray(a);
}
public AddressAQ[] getArray(long index, int count) throws SQLException
{
return (AddressAQ[]) _array.getObjectArray(index,
new AddressAQ[_array.sliceLength(index, count)]);
}
public void setArray(AddressAQ[] a, long index) throws SQLException
{
_array.setObjectArray(a, index);
}
public AddressAQ getElement(long index) throws SQLException
{
return (AddressAQ) _array.getObjectElement(index);
}
public void setElement(AddressAQ a, long index) throws SQLException
{
_array.setObjectElement(a, index);
}
}
import java.sql.SQLException;
import java.sql.Connection;
import oracle.jdbc.OracleTypes;
import oracle.sql.ORAData;
import oracle.sql.ORADataFactory;
import oracle.sql.Datum;
import oracle.sql.STRUCT;
import oracle.jpub.runtime.MutableStruct;
public class AddressAQ implements ORAData, ORADataFactory, java.io.Serializable
{
public static final String _SQL_NAME = "ADDRESS_AQTP";
public static final int _SQL_TYPECODE = OracleTypes.STRUCT;
transient protected MutableStruct _struct;
private static int[] _sqlType = { 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12 };
private static ORADataFactory[] _factory = new ORADataFactory[15];
protected static final AddressAQ _AddressAQFactory = new AddressAQ(false);
public static ORADataFactory getORADataFactory()
{ return _AddressAQFactory; }
/* constructor */
protected AddressAQ(boolean init)
{ if(init) _struct = new MutableStruct(new Object[15], _sqlType, _factory); }
public AddressAQ()
{ this(true); }
public AddressAQ(String siteaddressid, String addressid, String customerid, String address, String numberP, String additionalinfo, String quarter, String city, String state, String country, String postalcode, String referenceP, String contactname, String creationdate, String username) throws SQLException
{ this(true);
setSiteaddressid(siteaddressid);
setAddressid(addressid);
setCustomerid(customerid);
setAddress(address);
setNumberP(numberP);
setAdditionalinfo(additionalinfo);
setQuarter(quarter);
setCity(city);
setState(state);
setCountry(country);
setPostalcode(postalcode);
setReferenceP(referenceP);
setContactname(contactname);
setCreationdate(creationdate);
setUsername(username);
}
/* ORAData interface */
public Datum toDatum(Connection c) throws SQLException
{
return _struct.toDatum(c, _SQL_NAME);
}
/* ORADataFactory interface */
public ORAData create(Datum d, int sqlType) throws SQLException
{ return create(null, d, sqlType); }
protected ORAData create(AddressAQ o, Datum d, int sqlType) throws SQLException
{
if (d == null) return null;
if (o == null) o = new AddressAQ(false);
o._struct = new MutableStruct((STRUCT) d, _sqlType, _factory);
return o;
}
/* Serialization interface */
public void restoreConnection(Connection conn) throws SQLException
{ }
private void writeObject(java.io.ObjectOutputStream oos)
throws java.io.IOException, SQLException
{ oos.defaultWriteObject();
oos.writeObject(getSiteaddressid());
oos.writeObject(getAddressid());
oos.writeObject(getCustomerid());
oos.writeObject(getAddress());
oos.writeObject(getNumberP());
oos.writeObject(getAdditionalinfo());
oos.writeObject(getQuarter());
oos.writeObject(getCity());
oos.writeObject(getState());
oos.writeObject(getCountry());
oos.writeObject(getPostalcode());
oos.writeObject(getReferenceP());
oos.writeObject(getContactname());
oos.writeObject(getCreationdate());
oos.writeObject(getUsername());
}
private void readObject(java.io.ObjectInputStream ois)
throws java.io.IOException, ClassNotFoundException, java.sql.SQLException
{ ois.defaultReadObject();
Object[] o = new Object[15];
o[0] = ois.readObject();
o[1] = ois.readObject();
o[2] = ois.readObject();
o[3] = ois.readObject();
o[4] = ois.readObject();
o[5] = ois.readObject();
o[6] = ois.readObject();
o[7] = ois.readObject();
o[8] = ois.readObject();
o[9] = ois.readObject();
o[10] = ois.readObject();
o[11] = ois.readObject();
o[12] = ois.readObject();
o[13] = ois.readObject();
o[14] = ois.readObject();
_struct = new MutableStruct(o, _sqlType, _factory);
}
/* accessor methods */
public String getSiteaddressid() throws SQLException
{ return (String) _struct.getAttribute(0); }
public void setSiteaddressid(String siteaddressid) throws SQLException
{ _struct.setAttribute(0, siteaddressid); }
public String getAddressid() throws SQLException
{ return (String) _struct.getAttribute(1); }
public void setAddressid(String addressid) throws SQLException
{ _struct.setAttribute(1, addressid); }
public String getCustomerid() throws SQLException
{ return (String) _struct.getAttribute(2); }
public void setCustomerid(String customerid) throws SQLException
{ _struct.setAttribute(2, customerid); }
public String getAddress() throws SQLException
{ return (String) _struct.getAttribute(3); }
public void setAddress(String address) throws SQLException
{ _struct.setAttribute(3, address); }
public String getNumberP() throws SQLException
{ return (String) _struct.getAttribute(4); }
public void setNumberP(String numberP) throws SQLException
{ _struct.setAttribute(4, numberP); }
public String getAdditionalinfo() throws SQLException
{ return (String) _struct.getAttribute(5); }
public void setAdditionalinfo(String additionalinfo) throws SQLException
{ _struct.setAttribute(5, additionalinfo); }
public String getQuarter() throws SQLException
{ return (String) _struct.getAttribute(6); }
public void setQuarter(String quarter) throws SQLException
{ _struct.setAttribute(6, quarter); }
public String getCity() throws SQLException
{ return (String) _struct.getAttribute(7); }
public void setCity(String city) throws SQLException
{ _struct.setAttribute(7, city); }
public String getState() throws SQLException
{ return (String) _struct.getAttribute(8); }
public void setState(String state) throws SQLException
{ _struct.setAttribute(8, state); }
public String getCountry() throws SQLException
{ return (String) _struct.getAttribute(9); }
public void setCountry(String country) throws SQLException
{ _struct.setAttribute(9, country); }
public String getPostalcode() throws SQLException
{ return (String) _struct.getAttribute(10); }
public void setPostalcode(String postalcode) throws SQLException
{ _struct.setAttribute(10, postalcode); }
public String getReferenceP() throws SQLException
{ return (String) _struct.getAttribute(11); }
public void setReferenceP(String referenceP) throws SQLException
{ _struct.setAttribute(11, referenceP); }
public String getContactname() throws SQLException
{ return (String) _struct.getAttribute(12); }
public void setContactname(String contactname) throws SQLException
{ _struct.setAttribute(12, contactname); }
public String getCreationdate() throws SQLException
{ return (String) _struct.getAttribute(13); }
public void setCreationdate(String creationdate) throws SQLException
{ _struct.setAttribute(13, creationdate); }
public String getUsername() throws SQLException
{ return (String) _struct.getAttribute(14); }
public void setUsername(String username) throws SQLException
{ _struct.setAttribute(14, username); }
}
Código JMS que envia para fila. Não uso factory para criar os objetos gerados pelo JPublisher.
public void postJMSMessageObject(CustomerAQ customerAQ) throws JMSException {
jmsMessage = session.createObjectMessage(customerAQ);
messageProducer.send(jmsMessage);
messageProducer.close();
session.close();
connection.close();
}
Código que usei para consultar o descritor, para teste, funciona.
Class.forName("oracle.jdbc.OracleDriver");
Connection conn = DriverManager.getConnection(url, user, pass);
ArrayDescriptor desc = ArrayDescriptor.createDescriptor(typeName, conn);
conn.close();
System.out.println(desc.getName());
java.io.IOException: unexpected exception type
at java.io.ObjectStreamClass.throwMiscException(ObjectStreamClass.java:1461)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:923)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1339)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
java.sql.SQLException: Falha ao construir descritor: Invalid arguments
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.sql.StructDescriptor.createDescriptor(StructDescriptor.java:155)
at oracle.sql.StructDescriptor.createDescriptor(StructDescriptor.java:130)
at oracle.jpub.runtime.MutableStruct.toDatum(MutableStruct.java:115)
at com.controlpanel.customer.oracle.aqtp.AddressAQ.toDatum(Unknown Source)
at oracle.jpub.runtime.Util._convertToOracle(Util.java:160)
at oracle.jpub.runtime.Util.convertToOracle(Util.java:146)
at oracle.jpub.runtime.MutableArray.getDatumElement(MutableArray.java:1273)
at oracle.jpub.runtime.MutableArray.getOracleArray(MutableArray.java:639)
at oracle.jpub.runtime.MutableArray.getObjectArray(MutableArray.java:810)
at oracle.jpub.runtime.MutableArray.getObjectArray(MutableArray.java:816)
at com.controlpanel.customer.oracle.aqtp.AddressListAQ.getArray(Unknown Source)
at com.controlpanel.customer.oracle.aqtp.AddressListAQ.writeObject(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:917)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1339)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
at com.controlpanel.customer.oracle.aqtp.CustomerAQ.writeObject(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:917)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1339)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
at weblogic.jms.common.ObjectMessageImpl.setObject(ObjectMessageImpl.java:157)
at weblogic.jms.common.ObjectMessageImpl.setObject(ObjectMessageImpl.java:132)
at weblogic.jms.extensions.JMSMessageFactoryImpl.createObjectMessage(JMSMessageFactoryImpl.java:146)
at weblogic.jms.client.JMSSession.createObjectMessage(JMSSession.java:971)
at weblogic.jms.client.WLSessionImpl.createObjectMessage(WLSessionImpl.java:554)