web lookup for ejb3 session Bean
htcprasad Oct 4, 2016 9:51 PMI have a session bean
@Stateless
public class SampSess implements SampLocal, SampRemote {
@PersistenceContext(unitName="mydb")
EntityManager em;
private ProductDTO toDto(ProductTO prod){
ProductDTO ret = new ProductDTO();
ret.setProdId(prod.getProdId());
ret.setProdName(prod.getProdName());
ret.setProdCost(prod.getProdCost());
return ret;
}
private ProductTO toTo(ProductDTO prod){
ProductTO ret = new ProductTO();
ret.setProdId(prod.getProdId());
ret.setProdName(prod.getProdName());
ret.setProdCost(prod.getProdCost());
return ret;
}
@Override
public boolean saveProduct(ProductTO prod) {
boolean ret = false;
ProductDTO forSave = this.toDto(prod);
try{
em.persist(forSave);
ret = true;
}catch(Exception e){
e.printStackTrace();
}
return ret;
}
@Override
public ProductTO searchProduct(int prodId) {
ProductTO ret = new ProductTO();
try{
ProductDTO dto = em.getReference(ProductDTO.class, new Integer(prodId));
ret = this.toTo(dto);
}catch(Exception ex){
ex.printStackTrace();
}
return ret;
}
public SampSess() {
}
public String hello(String str) {
return "Hello hi "+ str.toUpperCase();
}
}
deployed as a part of ear
and web delegate looking up for this
String deployName = "java:global/myProj/SessEx/SampSess!htcejbs.SampLocal";
public SampLocal getSampLocal(){
SampLocal local = null;
try{
final Properties jndiProperties = new Properties();
jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
final Context ctx = new InitialContext(jndiProperties);
local = (SampLocal)ctx.lookup(deployName);
}catch(Exception ex){
ex.printStackTrace();
}
return local;
}
but in running shows an error
java.lang.ClassCastException: htcejbs.SampLocal$$$view2 cannot be cast to htcejbs.SampLocal
how i have to resolve this [ i tried java:module/...... and java:app/........] names also for module it is telling name not found
for java:app/ same error