我在 netbeans 中创建了一个 java web 项目,我创建了我的实体 bean,然后部署了我的项目来生成我的数据库,这项工作是成功的。
然后我生成了会话 bean 来访问创建的数据库。我创建了一个主类来测试会话 bean,当我测试通过会话 bean 接口调用的方法“find”时,我注意到一些类抛出异常,并且我注意到带有 vars List 的实体类抛出好像它们无法序列化的异常。
我想给我带来实体列表是一个请求。
我在同一个项目中拥有实体 bean,该项目具有我的会话 bean,在 Web 应用程序中......
我使用 Glass Fish 3.1.2
Netbeans 7.1.2
EclipseLink 2.0
实体持久性是:
@Entity
public class UserApplication implements Serializable {
private static long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long idUserApplication;
@Basic(optional=false)
@Column(nullable=false)
private String dcn;
@Basic(optional=false)
@Column(nullable=false)
private String password;
@Basic(optional=false)
@Column(nullable=false)
private String title ;
@Basic(optional=false)
@Column(nullable=false)
private String firstName;
@Basic(optional=false)
@Column(nullable=false)
private String lastName;
@Basic(optional=false)
@Column(nullable=false)
private String ci;
@Basic(optional=false)
@Column(nullable=false)
private String personalEmail;
@Basic(optional=false)
@Column(nullable=false)
private String workEmail;
@OneToMany
@JoinColumn(name = "userApplication_id", nullable = false)
private List<Account> accounts;
@OneToMany
@JoinColumn(name = "userApplication_id", nullable = true)
private List<CreditCard> creditCards = null;
@ManyToMany
@JoinTable(name="UserApplication_BeneficiaryThird", joinColumns=@JoinColumn
(name="userApplication_id", nullable = false), inverseJoinColumns=
@JoinColumn(name="beneficiaryThird_id", nullable = false))
private List<BeneficiaryThird> beneficiariesThird = null;
@OneToMany
@JoinColumn(name = "userApplication_id_beneficiary", nullable = true)
private List<BeneficiaryBankItself> beneficiariesBankItself = null;
@ManyToMany
@JoinTable(name="UserApplication_TransactionRule", joinColumns=@JoinColumn
(name="userApplication_id", nullable = false), inverseJoinColumns=
@JoinColumn(name="transactionRule_id", nullable = false))
private List<TransactionRule> transactionRules = null;
@OneToOne(mappedBy = "userApplication", optional = true, cascade = CascadeType.ALL)
private SessionCookie cookieId = null;................
主类是:
public class Main {
public static void main(String[] args) {
long id = 2;
bank.setId(id);
UserApplication userApplication = GetBean.getUserFacade().find(id);
System.out.println("user: " + userApplication.getFirstName());
}
}
GetBean 是实用程序类,是:
public class GetBean {
public static BankFacadeLocal getBankFacade() {
BankFacadeLocal bankFacade = null;
String jndiName = beans.BankFacadeLocal.class.getName();
try {
//bankFacade = (BankFacadeLocal) new InitialContext().lookup("java:global/IntegrationBanking/BankFacade!sessionBeans.BankFacadeLocal");
bankFacade = (BankFacadeLocal) new InitialContext().lookup(jndiName);
} catch (NamingException ex) {
Logger.getLogger(GetBean.class.getName()).log(Level.SEVERE, null, ex);
}
return bankFacade;
}
public static UserApplicationFacadeLocal getUserFacade() {
UserApplicationFacadeLocal userFacade = null;
String jndiName = UserApplicationFacadeLocal.class.getName();
try {
// userFacade = (UserApplicationFacadeLocal) new InitialContext().lookup("java:global/IntegrationBanking/UserApplicationFacade!beans.UserApplicationFacadeLocal");
userFacade = (UserApplicationFacadeLocal) new InitialContext().lookup(jndiName);
} catch (NamingException ex) {
Logger.getLogger(GetBean.class.getName()).log(Level.SEVERE, null, ex);
}
return userFacade;
}
}
坚持单位:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="BankingIntegrationPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>sqlServer</jta-data-source>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence>
例外是:
jul 26, 2012 2:55:38 PM com.sun.corba.ee.spi.orbutil.logex.WrapperGenerator handleFullLogging
Advertencia: IOP00810011: Exception from readValue on ValueHandler in CDRInputStream
org.omg.CORBA.MARSHAL: Advertencia: IOP00810011: Exception from readValue on ValueHandler in CDRInputStream vmcid: OMG minor code: 11 completed: Maybe
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)............
Caused by: java.io.IOException: Mismatched serialization UIDs : Source (Rep. IDRMI:entities.UserApplication:5CDFA7C871B53786:F07C8D07E21B75FA) = F07C8D07E21B75FA whereas Target (Rep. ID RMI:entities.UserApplication:4357CF2703B83ACF:180694EF6A1B61BC) = 180694EF6A1B61BC
at com.sun.corba.ee.impl.util.RepositoryId.useFullValueDescription(RepositoryId.java:679)
at com.sun.corba.ee.impl.util.RepositoryId.useFullValueDescription(RepositoryId.java:639)
at com.sun.corba.ee.impl.io.ValueHandlerImpl.useFullValueDescription(ValueHandlerImpl.java:360)
at com.sun.corba.ee.impl.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:422)........
jul 26, 2012 2:55:38 PM com.sun.corba.ee.spi.orbutil.logex.WrapperGenerator handleFullLogging
Advertencia: ORBIO00013: Stream corrupted
java.io.StreamCorruptedException: Advertencia: ORBIO00013: Stream corrupted
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)............
jul 26, 2012 2:55:38 PM com.sun.corba.ee.spi.orbutil.logex.WrapperGenerator handleFullLogging
Advertencia: IOP00810011: Exception from readValue on ValueHandler in CDRInputStream
org.omg.CORBA.MARSHAL: Advertencia: IOP00810011: Exception from readValue on ValueHandler in CDRInputStream vmcid: OMG minor code: 11 completed: Maybe
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)............
Caused by: java.io.StreamCorruptedException: Advertencia: ORBIO00013: Stream corrupted
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)...........
Exception in thread "main" javax.ejb.EJBException: java.rmi.MarshalException: CORBA MARSHAL 1330446347 Maybe; nested exception is:
org.omg.CORBA.MARSHAL: Advertencia: IOP00810011: Exception from readValue on ValueHandler in CDRInputStream vmcid: OMG minor code: 11 completed: Maybe
at beans._BeneficiaryBankItselfFacadeLocal_Wrapper.find(beans/_BeneficiaryBankItselfFacadeLocal_Wrapper.java)....................
Caused by: java.rmi.MarshalException: CORBA MARSHAL 1330446347 Maybe; nested exception is:
org.omg.CORBA.MARSHAL: Advertencia: IOP00810011: Exception from readValue on ValueHandler in CDRInputStream vmcid: OMG minor code: 11 completed: Maybe
at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.mapSystemException(Util.java:267)...........
Caused by: org.omg.CORBA.MARSHAL: Advertencia: IOP00810011: Exception from readValue on ValueHandler in CDRInputStream vmcid: OMG minor code: 11 completed: Maybe
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)..................
Caused by: java.io.StreamCorruptedException: Advertencia: ORBIO00013: Stream corrupted
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)....................