-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: java.lang.ClassCastException:
PostPosted: Wed Aug 20, 2014 5:16 am 
Newbie

Joined: Wed Aug 20, 2014 5:09 am
Posts: 2
Hi All,

I am new to Hibernate and trying to integrate Spring, EJB and Hibernate in Glassh Fish 4.0

When i try to integrate, I get the below exception.

java.lang.ClassCastException: com.geoplace.entitymodels.ChangeLog cannot be cast to com.geoplace.entitymodels.ChangeLog
at com.geoplace.middleware.businessobject.ejbimpl.DemoEJB.sayHello(DemoEJB.java:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1081)
at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1153)
at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4695)
at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:630)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582)
at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:140)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:369)
at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:4667)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4655)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:205)
at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:79)
at com.sun.proxy.$Proxy221.sayHello(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:239)
at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:150)
at com.sun.corba.ee.impl.presentation.rmi.codegen.CodegenStubBase.invoke(CodegenStubBase.java:226)
at com.geoplace.middleware.businessobject.ejbremote.__DemoEJBRemote_Remote_DynamicStub.sayHello(


My EJB :
@Stateless(name="ejb/DemoEJB" , mappedName="ejb/DemoEJBService")
public class DemoEJB implements DemoEJBRemote {


@PersistenceUnit(name="primary")
private EntityManagerFactory emf;

public String sayHello() {

EntityManager em = emf.createEntityManager();
System.out.println(emf.getMetamodel().getEntities());

Calendar myCal = Calendar.getInstance();
myCal.set(Calendar.YEAR, 2014);
myCal.set(Calendar.MONTH, Calendar.AUGUST);
myCal.set(Calendar.DAY_OF_MONTH, 07);

Query q = em
.createQuery(
"select ch from ChangeLog ch where ch.recordIdentifier = :rd and ch.authCode = :ad and ch.referenceNumber = :rf" , ChangeLog.class)
.setParameter("rd", new BigDecimal(23))
.setParameter("ad", new BigDecimal(505))
.setParameter("rf", new BigDecimal("200004167368"));


List<ChangeLog> results = q.getResultList();

for (ChangeLog entity : results) {

System.out.println(entity);
}

em.close();

return "Helllooo";
}

}

Spring Bean
--------------


@Component
@Scope(value="session", proxyMode=ScopedProxyMode.TARGET_CLASS)
public class SessionSpringBean implements Serializable{

@EJB(mappedName = "ejb/DemoEJBService")
private DemoEJBRemote demoejb;


private static final long serialVersionUID = 184513L;

final Logger logger = LogManager
.getLogger(SessionSpringBean.class);


public SessionSpringBean(){
super();
logger.info("I am the constructor in session spring bean");
}

public void getFromDB(){
logger.info("Calling");
demoejb.sayHello();
logger.info("Called");
}
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.