dev@glassfish.java.net

Re: Problem loading Entity from EJB

From: Kenneth Saks <Kenneth.Saks_at_Sun.COM>
Date: Tue, 27 Jun 2006 13:50:43 -0400

Dyego Souza Dantas Leal wrote:

> In my class i'm finding the Tabelacusta entity with three relations ,
>
> Is a SessionBean Method returing to my JUnit Test , but i get an error :

Hi Dyego,

Are you sure your client's classpath contains all the necessary classes?
It looks like one of the classes needed to unmarshal the getTablea()
return value
is not being found in the client.

 --ken

>
>
>
> 27/06/2006 14:26:37 com.sun.corba.ee.impl.encoding.CDRInputStream_1_0
> read_value
> WARNING: "IOP00810257: (MARSHAL) Could not find class"
> org.omg.CORBA.MARSHAL: vmcid: SUN minor code: 257 completed: Maybe
> at
> com.sun.corba.ee.impl.logging.ORBUtilSystemException.couldNotFindClass(ORBUtilSystemException.java:8309)
>
> at
> com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:984)
>
> at
> com.sun.corba.ee.impl.encoding.CDRInputStream.read_value(CDRInputStream.java:259)
>
> at
> com.sun.corba.ee.impl.io.IIOPInputStream.inputObjectField(IIOPInputStream.java:1987)
>
> at
> com.sun.corba.ee.impl.io.IIOPInputStream.inputClassFields(IIOPInputStream.java:2211)
>
> at
> com.sun.corba.ee.impl.io.IIOPInputStream.inputObject(IIOPInputStream.java:1219)
>
> at
> com.sun.corba.ee.impl.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:398)
>
> at
> com.sun.corba.ee.impl.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:329)
>
> at
> com.sun.corba.ee.impl.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:295)
>
> at
> com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1005)
>
> at
> com.sun.corba.ee.impl.encoding.CDRInputStream.read_value(CDRInputStream.java:259)
>
> at
> com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl$14.read(DynamicMethodMarshallerImpl.java:333)
>
> at
> com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl.readResult(DynamicMethodMarshallerImpl.java:424)
>
> at
> com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:162)
>
> at
> com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:119)
>
> at
> com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(BCELStubBase.java:197)
>
> at
> dummy.myexample.session.interfaces.__TabelaCustaSessionRemote_Remote_DynamicStub.getTabela(__TabelaCustaSessionRemote_Remote_DynamicStub.java)
>
> at
> dummy.myexample.session.interfaces._TabelaCustaSessionRemote_Wrapper.getTabela(dummy.myexample.session.interfaces._TabelaCustaSessionRemote_Wrapper.java)
>
> at
> dummy.myexample.session.TabelaCustaSessionBeanTest.testAddGetSetRemoveTabela(TabelaCustaSessionBeanTest.java:134)
>
> 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 junit.framework.TestCase.runTest(TestCase.java:154)
> at junit.framework.TestCase.runBare(TestCase.java:127)
> at junit.framework.TestResult$1.protect(TestResult.java:106)
> at junit.framework.TestResult.runProtected(TestResult.java:124)
> at junit.framework.TestResult.run(TestResult.java:109)
> at junit.framework.TestCase.run(TestCase.java:118)
> at junit.framework.TestSuite.runTest(TestSuite.java:208)
> at junit.framework.TestSuite.run(TestSuite.java:203)
> at
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:297)
>
> addGetSetRemoveItem
> at
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:672)
>
> at
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:567)
>
> Caused by: java.lang.ClassNotFoundException
> ... 33 more
>
>
>
>
>
> Any help ?
>
>
>
>
>
>
>
>
>
>
> The classes is:
>
>
> Tabelacusta.java
>
> package dummy.myexample.entity;
>
> import dummy.compartilhado.ejb.interfaces.IdOfPojo;
> import dummy.compartilhado.ejbx.EscribaEntity;
> import java.util.Date;
> import java.util.HashSet;
> import javax.persistence.CascadeType;
> import javax.persistence.Column;
> import javax.persistence.Entity;
> import javax.persistence.FetchType;
> import javax.persistence.GeneratedValue;
> import javax.persistence.GenerationType;
> import javax.persistence.Id;
> import javax.persistence.NamedQueries;
> import javax.persistence.NamedQuery;
> import javax.persistence.OneToMany;
> import javax.persistence.Table;
> import javax.persistence.Temporal;
> import javax.persistence.TemporalType;
>
> /**
> * Cadastro de Tabelas de Custas
> *
> * @author Dyego Souza Dantas Leal
> * @since 26/06/2006
> */
> @Entity
> @Table(name = "tabelacusta")
> @NamedQueries( {_at_NamedQuery(name = "Tabelacusta.findByTsId", query =
> "SELECT t FROM Tabelacusta t WHERE t.tsId = :tsId"), @NamedQuery(name
> = "Tabelacusta.findByTsEscopo", query = "SELECT t FROM Tabelacusta t
> WHERE t.tsEscopo = :tsEscopo"), @NamedQuery(name =
> "Tabelacusta.findByTsTabela", query = "SELECT t FROM Tabelacusta t
> WHERE t.tsTabela = :tsTabela"), @NamedQuery(name =
> "Tabelacusta.findByTsvigenciaIni", query = "SELECT t FROM Tabelacusta
> t WHERE t.tsvigenciaIni = :tsvigenciaIni"), @NamedQuery(name =
> "Tabelacusta.findByTsvigenciaFim", query = "SELECT t FROM Tabelacusta
> t WHERE t.tsvigenciaFim = :tsvigenciaFim"), @NamedQuery(name =
> "Tabelacusta.findByTscodigoContabil", query = "SELECT t FROM
> Tabelacusta t WHERE t.tscodigoContabil = :tscodigoContabil"),
> @NamedQuery(name = "Tabelacusta.findByTsObs", query = "SELECT t FROM
> Tabelacusta t WHERE t.tsObs = :tsObs")})
> public class Tabelacusta extends EscribaEntity {
>
> @Id
> @GeneratedValue(strategy=GenerationType.AUTO)
> @Column(name = "ts_id", nullable = false)
> private Integer tsId;
>
> @Column(name = "ts_escopo", nullable = false)
> private String tsEscopo;
>
> @Column(name = "ts_tabela", nullable = false)
> private String tsTabela;
>
> @Column(name = "ts_vigenciaIni", nullable = false)
> @Temporal(TemporalType.DATE)
> private Date tsvigenciaIni;
>
> @Column(name = "ts_vigenciaFim", nullable = false)
> @Temporal(TemporalType.DATE)
> private Date tsvigenciaFim;
>
> @Column(name = "ts_codigoContabil", nullable = false)
> private String tscodigoContabil;
>
> @Column(name = "ts_obs", nullable = false)
> private String tsObs;
>
> @OneToMany(fetch=FetchType.EAGER, cascade = CascadeType.ALL,
> mappedBy = "ittabelaCusta")
> private java.util.Set <dummy.myexample.entity.Itemtabelacusta>
> itemtabelacusta = new HashSet<dummy.myexample.entity.Itemtabelacusta>();
> /** Creates a new instance of Tabelacusta */
> public Tabelacusta() {
> }
>
> public Tabelacusta(Integer tsId) {
> this.tsId = tsId;
> }
>
> public void addItemtabelacusta(Itemtabelacusta vo) {
> vo.setIttabelaCusta(this);
> itemtabelacusta.add(vo);
> }
>
> public Tabelacusta(Integer tsId, String tsEscopo, String tsTabela,
> Date tsvigenciaIni, Date tsvigenciaFim, String tscodigoContabil,
> String tsObs) {
> this.tsId = tsId;
> this.tsEscopo = tsEscopo;
> this.tsTabela = tsTabela;
> this.tsvigenciaIni = tsvigenciaIni;
> this.tsvigenciaFim = tsvigenciaFim;
> this.tscodigoContabil = tscodigoContabil;
> this.tsObs = tsObs;
> }
>
> public Integer getTsId() {
> return this.tsId;
> }
>
> public void setTsId(Integer tsId) {
> this.tsId = tsId;
> }
>
> public String getTsEscopo() {
> return this.tsEscopo;
> }
>
> public void setTsEscopo(String tsEscopo) {
> this.tsEscopo = tsEscopo;
> }
>
> public String getTsTabela() {
> return this.tsTabela;
> }
>
> public void setTsTabela(String tsTabela) {
> this.tsTabela = tsTabela;
> }
>
> public Date getTsvigenciaIni() {
> return this.tsvigenciaIni;
> }
>
> public void setTsvigenciaIni(Date tsvigenciaIni) {
> this.tsvigenciaIni = tsvigenciaIni;
> }
>
> public Date getTsvigenciaFim() {
> return this.tsvigenciaFim;
> }
>
> public void setTsvigenciaFim(Date tsvigenciaFim) {
> this.tsvigenciaFim = tsvigenciaFim;
> }
>
> public String getTscodigoContabil() {
> return this.tscodigoContabil;
> }
>
> public void setTscodigoContabil(String tscodigoContabil) {
> this.tscodigoContabil = tscodigoContabil;
> }
>
> public String getTsObs() {
> return this.tsObs;
> }
>
> public void setTsObs(String tsObs) {
> this.tsObs = tsObs;
> }
>
> public java.util.Set <dummy.myexample.entity.Itemtabelacusta>
> getItemtabelacusta() {
> return this.itemtabelacusta;
> }
>
> public void setItemtabelacusta(java.util.Set
> <dummy.myexample.entity.Itemtabelacusta> itemtabelacusta) {
> this.itemtabelacusta = itemtabelacusta;
> }
>
> public int hashCode() {
> int hash = 0;
> hash += (this.tsId != null ? this.tsId.hashCode() : 0);
> return hash;
> }
>
> public boolean equals(Object object) {
> // TODO: Warning - this method won't work in the case the id
> fields are not set
> if (!(object instanceof Tabelacusta)) {
> return false;
> }
> Tabelacusta other = (Tabelacusta)object;
> if (this.tsId != other.tsId && (this.tsId == null ||
> !this.tsId.equals(other.tsId))) return false;
> return true;
> }
>
> public String toString() {
> return "dummy.myexample.entity.Tabelacusta[tsId=" + tsId + "]";
> }
> }
>
> Itemtabelacusta.java
>
> package dummy.myexample.entity;
>
> import dummy.compartilhado.ejb.interfaces.IdOfPojo;
> import dummy.compartilhado.ejbx.EscribaEntity;
> import java.util.HashSet;
> import javax.persistence.CascadeType;
> import javax.persistence.Column;
> import javax.persistence.Entity;
> import javax.persistence.FetchType;
> import javax.persistence.GeneratedValue;
> import javax.persistence.GenerationType;
> import javax.persistence.Id;
> import javax.persistence.JoinColumn;
> import javax.persistence.ManyToOne;
> import javax.persistence.NamedQueries;
> import javax.persistence.NamedQuery;
> import javax.persistence.OneToMany;
> import javax.persistence.Table;
>
> @Entity
> @Table(name = "itemtabelacusta")
> @NamedQueries( {_at_NamedQuery(name = "Itemtabelacusta.findByItId", query
> = "SELECT i FROM Itemtabelacusta i WHERE i.itId = :itId"),
> @NamedQuery(name = "Itemtabelacusta.findByItautoSugerir", query =
> "SELECT i FROM Itemtabelacusta i WHERE i.itautoSugerir =
> :itautoSugerir"), @NamedQuery(name =
> "Itemtabelacusta.findByItcodCusta", query = "SELECT i FROM
> Itemtabelacusta i WHERE i.itcodCusta = :itcodCusta"), @NamedQuery(name
> = "Itemtabelacusta.findByItDescricao", query = "SELECT i FROM
> Itemtabelacusta i WHERE i.itDescricao = :itDescricao"),
> @NamedQuery(name = "Itemtabelacusta.findByItbaseMin", query = "SELECT
> i FROM Itemtabelacusta i WHERE i.itbaseMin = :itbaseMin"),
> @NamedQuery(name = "Itemtabelacusta.findByItbaseMax", query = "SELECT
> i FROM Itemtabelacusta i WHERE i.itbaseMax = :itbaseMax"),
> @NamedQuery(name = "Itemtabelacusta.findByItvalorMin", query = "SELECT
> i FROM Itemtabelacusta i WHERE i.itvalorMin = :itvalorMin"),
> @NamedQuery(name = "Itemtabelacusta.findByItvalorMax", query = "SELECT
> i FROM Itemtabelacusta i WHERE i.itvalorMax = :itvalorMax")})
> public class Itemtabelacusta extends EscribaEntity {
>
> @Id
> @GeneratedValue(strategy=GenerationType.AUTO)
> @Column(name = "it_id", nullable = false)
> private Integer itId;
>
> @Column(name = "it_autoSugerir", nullable = false)
> private int itautoSugerir;
>
> @Column(name = "it_codCusta", nullable = false)
> private String itcodCusta;
>
> @Column(name = "it_descricao", nullable = false)
> private String itDescricao;
>
> @Column(name = "it_baseMin", nullable = false)
> private double itbaseMin;
>
> @Column(name = "it_baseMax", nullable = false)
> private double itbaseMax;
>
> @Column(name = "it_valorMin", nullable = false)
> private double itvalorMin;
>
> @Column(name = "it_valorMax", nullable = false)
> private double itvalorMax;
>
> @OneToMany(fetch=FetchType.EAGER,cascade = CascadeType.ALL,
> mappedBy = "vtitemTabelaCusta")
> private java.util.Set <dummy.myexample.entity.Valortabelacusta>
> valortabelacusta = new
> HashSet<dummy.myexample.entity.Valortabelacusta>();
>
> @JoinColumn(name = "it_tabelaCusta")
> @ManyToOne
> private Tabelacusta ittabelaCusta;
> /** Creates a new instance of Itemtabelacusta */
> public Itemtabelacusta() {
> }
>
> public void addValorTabelaCusta(Valortabelacusta vo) {
> vo.setVtitemTabelaCusta(this);
> valortabelacusta.add(vo);
> } public Itemtabelacusta(Integer itId) {
> this.itId = itId;
> }
>
> public Itemtabelacusta(Integer itId, int itautoSugerir, String
> itcodCusta, String itDescricao, double itbaseMin, double itbaseMax,
> double itvalorMin, double itvalorMax) {
> this.itId = itId;
> this.itautoSugerir = itautoSugerir;
> this.itcodCusta = itcodCusta;
> this.itDescricao = itDescricao;
> this.itbaseMin = itbaseMin;
> this.itbaseMax = itbaseMax;
> this.itvalorMin = itvalorMin;
> this.itvalorMax = itvalorMax;
> }
>
> public Integer getItId() {
> return this.itId;
> }
>
> public void setItId(Integer itId) {
> this.itId = itId;
> }
>
> public int getItautoSugerir() {
> return this.itautoSugerir;
> }
>
> public void setItautoSugerir(int itautoSugerir) {
> this.itautoSugerir = itautoSugerir;
> }
>
> public String getItcodCusta() {
> return this.itcodCusta;
> }
>
> public void setItcodCusta(String itcodCusta) {
> this.itcodCusta = itcodCusta;
> }
>
> public String getItDescricao() {
> return this.itDescricao;
> }
>
> public void setItDescricao(String itDescricao) {
> this.itDescricao = itDescricao;
> }
>
> public double getItbaseMin() {
> return this.itbaseMin;
> }
>
> public void setItbaseMin(double itbaseMin) {
> this.itbaseMin = itbaseMin;
> }
>
> public double getItbaseMax() {
> return this.itbaseMax;
> }
>
> public void setItbaseMax(double itbaseMax) {
> this.itbaseMax = itbaseMax;
> }
>
> public double getItvalorMin() {
> return this.itvalorMin;
> }
>
> public void setItvalorMin(double itvalorMin) {
> this.itvalorMin = itvalorMin;
> }
>
> public double getItvalorMax() {
> return this.itvalorMax;
> }
>
> public void setItvalorMax(double itvalorMax) {
> this.itvalorMax = itvalorMax;
> }
>
>
> public java.util.Set <dummy.myexample.entity.Valortabelacusta>
> getValortabelacusta() {
> return this.valortabelacusta;
> }
>
> public void setValortabelacusta(java.util.Set
> <dummy.myexample.entity.Valortabelacusta> valortabelacusta) {
> this.valortabelacusta = valortabelacusta;
> }
>
> public Tabelacusta getIttabelaCusta() {
> return this.ittabelaCusta;
> }
>
> public void setIttabelaCusta(Tabelacusta ittabelaCusta) {
> this.ittabelaCusta = ittabelaCusta;
> }
>
> public int hashCode() {
> int hash = 0;
> hash += (this.itId != null ? this.itId.hashCode() : 0);
> return hash;
> }
>
> public boolean equals(Object object) {
> if (!(object instanceof Itemtabelacusta)) {
> return false;
> }
> Itemtabelacusta other = (Itemtabelacusta)object;
> if (this.itId != other.itId && (this.itId == null ||
> !this.itId.equals(other.itId))) return false;
> return true;
> }
>
> public String toString() {
> return "dummy.myexample.entity.Itemtabelacusta[itId=" + itId +
> "]";
> }
> }
>
> Valoritemcusta.java
>
> /*
> * Valortabelacusta.java
> *
> * Created on 23 de Junho de 2006, 09:13
> *
> * To change this template, choose Tools | Template Manager
> * and open the template in the editor.
> */
>
> package dummy.myexample.entity;
>
> import dummy.compartilhado.ejbx.EscribaEntity;
> import javax.persistence.Column;
> import javax.persistence.Entity;
> import javax.persistence.GeneratedValue;
> import javax.persistence.GenerationType;
> import javax.persistence.Id;
> import javax.persistence.JoinColumn;
> import javax.persistence.ManyToOne;
> import javax.persistence.NamedQueries;
> import javax.persistence.NamedQuery;
> import javax.persistence.Table;
>
> @Entity
> @Table(name = "valortabelacusta")
> @NamedQueries( {_at_NamedQuery(name = "Valortabelacusta.findByVtId",
> query = "SELECT v FROM Valortabelacusta v WHERE v.vtId = :vtId"),
> @NamedQuery(name = "Valortabelacusta.findByVtPosicao", query = "SELECT
> v FROM Valortabelacusta v WHERE v.vtPosicao = :vtPosicao"),
> @NamedQuery(name = "Valortabelacusta.findByVtValor", query = "SELECT v
> FROM Valortabelacusta v WHERE v.vtValor = :vtValor"), @NamedQuery(name
> = "Valortabelacusta.findByVtnumViaGratuita", query = "SELECT v FROM
> Valortabelacusta v WHERE v.vtnumViaGratuita = :vtnumViaGratuita"),
> @NamedQuery(name = "Valortabelacusta.findByVtadicionalVia", query =
> "SELECT v FROM Valortabelacusta v WHERE v.vtadicionalVia =
> :vtadicionalVia"), @NamedQuery(name =
> "Valortabelacusta.findByVtvalorMin", query = "SELECT v FROM
> Valortabelacusta v WHERE v.vtvalorMin = :vtvalorMin"),
> @NamedQuery(name = "Valortabelacusta.findByVtvalorMax", query =
> "SELECT v FROM Valortabelacusta v WHERE v.vtvalorMax = :vtvalorMax")})
> public class Valortabelacusta extends EscribaEntity {
>
> @Id
> @GeneratedValue(strategy=GenerationType.AUTO)
> @Column(name = "vt_id", nullable = false)
> private Integer vtId;
>
> @Column(name = "vt_posicao", nullable = false)
> private int vtPosicao;
>
> @Column(name = "vt_valor", nullable = false)
> private String vtValor;
>
> @Column(name = "vt_numViaGratuita", nullable = false)
> private int vtnumViaGratuita;
>
> @Column(name = "vt_adicionalVia", nullable = false)
> private double vtadicionalVia;
>
> @Column(name = "vt_valorMin", nullable = false)
> private double vtvalorMin;
>
> @Column(name = "vt_valorMax", nullable = false)
> private double vtvalorMax;
>
> @JoinColumn(name = "vt_itemTabelaCusta")
> @ManyToOne
> private dummy.myexample.entity.Itemtabelacusta vtitemTabelaCusta;
> /** Creates a new instance of Valortabelacusta */
> public Valortabelacusta() {
> }
>
> public Valortabelacusta(Integer vtId) {
> this.vtId = vtId;
> }
>
> public Valortabelacusta(Integer vtId, int vtPosicao, String
> vtValor, int vtnumViaGratuita, double vtadicionalVia, double
> vtvalorMin, double vtvalorMax) {
> this.vtId = vtId;
> this.vtPosicao = vtPosicao;
> this.vtValor = vtValor;
> this.vtnumViaGratuita = vtnumViaGratuita;
> this.vtadicionalVia = vtadicionalVia;
> this.vtvalorMin = vtvalorMin;
> this.vtvalorMax = vtvalorMax;
> }
>
> public Integer getVtId() {
> return this.vtId;
> }
>
> public void setVtId(Integer vtId) {
> this.vtId = vtId;
> }
>
> public int getVtPosicao() {
> return this.vtPosicao;
> }
>
> public void setVtPosicao(int vtPosicao) {
> this.vtPosicao = vtPosicao;
> }
>
> public String getVtValor() {
> return this.vtValor;
> }
>
> public void setVtValor(String vtValor) {
> this.vtValor = vtValor;
> }
>
> public int getVtnumViaGratuita() {
> return this.vtnumViaGratuita;
> }
>
> public void setVtnumViaGratuita(int vtnumViaGratuita) {
> this.vtnumViaGratuita = vtnumViaGratuita;
> }
>
> public double getVtadicionalVia() {
> return this.vtadicionalVia;
> }
>
> public void setVtadicionalVia(double vtadicionalVia) {
> this.vtadicionalVia = vtadicionalVia;
> }
>
> public double getVtvalorMin() {
> return this.vtvalorMin;
> }
>
> public void setVtvalorMin(double vtvalorMin) {
> this.vtvalorMin = vtvalorMin;
> }
>
> public double getVtvalorMax() {
> return this.vtvalorMax;
> }
>
> public void setVtvalorMax(double vtvalorMax) {
> this.vtvalorMax = vtvalorMax;
> }
>
> public dummy.myexample.entity.Itemtabelacusta getVtitemTabelaCusta() {
> return this.vtitemTabelaCusta;
> }
>
> public void
> setVtitemTabelaCusta(dummy.myexample.entity.Itemtabelacusta
> vtitemTabelaCusta) {
> this.vtitemTabelaCusta = vtitemTabelaCusta;
> }
>
> public int hashCode() {
> int hash = 0;
> hash += (this.vtId != null ? this.vtId.hashCode() : 0);
> return hash;
> }
>
> public boolean equals(Object object) {
> // TODO: Warning - this method won't work in the case the id
> fields are not set
> if (!(object instanceof Valortabelacusta)) {
> return false;
> }
> Valortabelacusta other = (Valortabelacusta)object;
> if (this.vtId != other.vtId && (this.vtId == null ||
> !this.vtId.equals(other.vtId))) return false;
> return true;
> }
>
> public String toString() {
> return "dummy.myexample.entity.Valortabelacusta[vtId=" + vtId +
> "]";
> }
> }
>
>
>
>
>
>