[jboss-user] [EJB 3.0] - Problem with @OneToMany annotation

dsf qsdf do-not-reply at jboss.com
Wed Aug 25 22:05:35 EDT 2010


dsf qsdf [http://community.jboss.org/people/ezza3im] created the discussion

"Problem with @OneToMany annotation"

To view the discussion, visit: http://community.jboss.org/message/559054#559054

--------------------------------------------------------------
Hello

I have a problem with EJB project which contains the  @OneToMany annotation.

The EJB Entities are "User" and "Privilege". A "Privilege" has many "User".

Here is the source of my EJB Entities:


 
 
[CODE]
package entities;
 
import java.io.Serializable;
import java.sql.Date;
import java.util.Collection;
 
 
import javax.persistence.*;
 
 
@Entity
 
public class User implements Serializable {
 
@Id
@Column(name = "UserID")
private int  UserID;
 
private String password;
private String login;
private String Name;
private String gender;
private String Phone;
private String Email;
private String Address;
private int isActive;
private Date lastLoginTime;
 
@ManyToOne(cascade=CascadeType.ALL)
@JoinColumn(name = "Privilege_idPrivilege")
private Privilege privilege;
 
public User() {
super();
// TODO Auto-generated constructor stub
}
 
 
 
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getName() {
return Name;
}
public void setName(String name) {
Name = name;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getPhone() {
return Phone;
}
public void setPhone(String phone) {
Phone = phone;
}
public String getEmail() {
return Email;
}
public void setEmail(String email) {
Email = email;
}
public String getAddress() {
return Address;
}
public void setAddress(String address) {
Address = address;
}
public int getIsActive() {
return isActive;
}
public void setIsActive(int isActive) {
this.isActive = isActive;
}
public void setLogin(String login) {
this.login = login;
}
 
public String getLogin() {
return login;
}
 
 
public int getUserID() {
return UserID;
}
 
 
public void setUserID(int userID) {
UserID = userID;
}
 
 
public void setLastLoginTime(Date lastLoginTime) {
this.lastLoginTime = lastLoginTime;
}
 
 
 
public Date getLastLoginTime() {
return lastLoginTime;
}
 
 
 
public Privilege getPrivilege() {
return privilege;
}
public void setPrivilege(Privilege privilege) {
this.privilege = privilege;
}
 
 
}
 
[/CODE]
 
 
et 
[CODE]
package entities;
 
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
 
import javax.persistence.*;
 
 
 
 
 
@Entity
 
public class Privilege implements Serializable{
 
 
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int idPrivilege ;
 
private int Level ;
 
 
@OneToMany
private Collection<User> users = new ArrayList<User>();
 
public int getIdPrivilege() {
return idPrivilege;
}
public void setIdPrivilege(int idPrivilege) {
this.idPrivilege = idPrivilege;
}
public int getLevel() {
return Level;
}
public void setLevel(int level) {
Level = level;
}
 
 
public Collection<User> getUsers() {
return users;
}
 
public void setUsers(Collection<User> users) {
this.users = users;
}
}
[/CODE]
 





In the test application I get the following error message (given that the test app: GestionDeStockClient and "search_user" is a method of the EJB Session that returns User):



[CODE]Exception in thread "main" java.lang.reflect.UndeclaredThrowableException
 at $Proxy0.search_user(Unknown Source)
 at com.et.GestionDeStockClient.main(GestionDeStockClient.java:30)
[COLOR="Red"]Caused by: java.lang.ClassNotFoundException: [/COLOR][Ljava.lang.StackTraceElement;
 at java.net.URLClassLoader$1.run(Unknown Source)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(Unknown Source)
 at java.lang.ClassLoader.loadClass(Unknown Source)
 at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
 at java.lang.ClassLoader.loadClass(Unknown Source)
 at org.jboss.remoting.loading.RemotingClassLoader.loadClass(RemotingClassLoader.java:50)
 at org.jboss.remoting.loading.ObjectInputStreamWithClassLoader.resolveClass(ObjectInputStreamWithClassLoader.java:139)
 at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
 at java.io.ObjectInputStream.readClassDesc(Unknown Source)
 at java.io.ObjectInputStream.readArray(Unknown Source)
 at java.io.ObjectInputStream.readObject0(Unknown Source)
 at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
 at java.io.ObjectInputStream.readSerialData(Unknown Source)
 at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
 at java.io.ObjectInputStream.readObject0(Unknown Source)
 at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
 at java.io.ObjectInputStream.readSerialData(Unknown Source)
 at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
 at java.io.ObjectInputStream.readObject0(Unknown Source)
 at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
 at java.io.ObjectInputStream.readSerialData(Unknown Source)
 at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
 at java.io.ObjectInputStream.readObject0(Unknown Source)
 at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
 at java.io.ObjectInputStream.readSerialData(Unknown Source)
 at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
 at java.io.ObjectInputStream.readObject0(Unknown Source)
 at java.io.ObjectInputStream.readObject(Unknown Source)
 at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObject(JavaSerializationManager.java:128)
 at org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:66)
 at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:279)
 at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:143)
 at org.jboss.remoting.Client.invoke(Client.java:525)
 at org.jboss.remoting.Client.invoke(Client.java:488)
 at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:55)
 at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
 at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
 at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
 at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:53)
 at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
 at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:77)
 at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
 at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:102)
 ... 2 more
[/CODE]


thanks

--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/559054#559054]

Start a new discussion in EJB 3.0 at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100825/5ad3496e/attachment-0001.html 


More information about the jboss-user mailing list