Remote acces on an Entity
infodavid Nov 14, 2005 3:57 PMI use a client to connect to JBoss 4.0.3SP1 using sun jdk 1.5.
I retrieve a stateless bean and it's ok (stateless is a jboss proxy) but when
I try to create an entity using this bean manager, a ClassNotFoundException is thrown because the returned object is not a proxy, it's the entity bean class, not the remote interface.
The interfaces :
@Remote public interface ICityManager extends IDataManager<ICity> { public ICity create(String name, String code, String country) throws RemoteException; } @Remote public interface ICity extends INamed { public String getCode() throws RemoteException; public void setCode(String s) throws RemoteException; public String getCountry() throws RemoteException; public void setCountry(String o) throws RemoteException; }
The concrete classes :
@Stateless @Remote(ICityManager.class) public class CityManagerBean extends AbstractManagerBean<ICity> implements ICityManager { ... public ICity create(String name, String code, String country) throws RemoteException { ICity o = new City(); o.setName(name); o.setCode(code); o.setCountry(country); manager.persist(o); return o; } @Entity(access = AccessType.PROPERTY) @Table(name = "CITIES", uniqueConstraints = { @UniqueConstraint( columnNames = { INamed.NAME, ICity.CODE, ICity.COUNTRY } ) } ) @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @Remote(ICity.class) public class City extends AbstractNamedEntity implements ICity { private String code; private String country; public City() { } ... @Id(generate = GeneratorType.IDENTITY) @Column(name = ID, nullable = false, unique = true) public long getPrimaryKey() { return id; } ... }
The client :
public static void main(String[] args) { try { if (System.getSecurityManager() == null) { System.setSecurityManager(new AllPermissionsManager()); } DataManagerFactory factory = DataManagerFactory.getInstance(); ICityManager cityManager = factory.get(ICityManager.class); cityManager.removeAll(); System.out.print("city creation =>"); System.out.println(cityManager.getClass().getName()); System.out.println("cities : " + cityManager.size()); ICity city = cityManager.create("Paris", "75000", "fra"); //ClassNotFoundException appears here ... }
I don't understand, I need to put my concrete entity class on the class path of the client or it's not necessary (proxy or not) ?