[ http://jira.jboss.com/jira/browse/JBAS-1385?page=history ] Alexey Loubyansky closed JBAS-1385: -----------------------------------
Resolution: Rejected Finder's are not allowed to return field values. Use SELECT OBJECT(p)... > ClassCastException in execution of EJB-QL finder > ------------------------------------------------ > > Key: JBAS-1385 > URL: http://jira.jboss.com/jira/browse/JBAS-1385 > Project: JBoss Application Server > Type: Bug > Components: CMP service > Versions: JBossAS-4.0.1 Final, JBossAS-3.2.7 Final, JBossAS-3.2.6 Final > Reporter: nicolas cazottes > Assignee: Scott M Stark > > > There is a ClassCastException at execution time on > Jboss since version 3.2.6 (it worked on 3.2.5 but > neither on 3.2.6 nor on 3.2.7) when calling an EJB > finder query defined as follow with Xdoclet tags : > @ejb.finder > * view-type = "local" > * signature="test.ProductLocal > findByRefToAndToLicense(java.lang.String refTo, > java.lang.String license)" > * result-type-mapping="Local" > * method-intf="LocalHome" > * query="SELECT DISTINCT pr.id FROM TourOperator > to, IN ( to.products ) AS pr WHERE to.licenseNumber = > ?2 AND pr.refTo = ?1" > * > The trace is given after when jboss is in trace log level. > I also tested the same query with a return of type > Collection and it worked well. So I think the Cast > problem is that I declared the result as ProductLocal > and not Collection but it should be working without > using a Collection since I known by construction that > the result of the search is either 0 or 1. > Here is the trace : > 16:03:09,690 TRACE [Registry] lookup > 491837535=jboss.j2ee:jndiName=ejb/ProductSearchHome,service=EJB > 16:03:09,690 TRACE [StatelessSessionContainer] METHOD > HOME INVOKE 491837535||create||[Ljava.lang.Object;@1900f17 > 16:03:09,690 TRACE [LogInterceptor] Start method=create > 16:03:09,690 TRACE [TxInterceptorCMT] Current > transaction in MI is null > 16:03:09,690 TRACE [TxInterceptorCMT] TX_REQUIRED for > create timeout=0 > 16:03:09,690 TRACE [TxInterceptorCMT] Thread came in > with tx null > 16:03:09,690 TRACE [TransactionImpl] Created new > instance for tx=TransactionImpl:XidImpl [FormatId=257, > GlobalId=NICOLAS//25, BranchQual=] > 16:03:09,690 TRACE [TxInterceptorCMT] Starting new tx > TransactionImpl:XidImpl [FormatId=257, > GlobalId=NICOLAS//25, BranchQual=] > 16:03:09,690 TRACE [TxInterceptorCMT] TxInterceptorCMT: > In finally > 16:03:09,690 TRACE [TransactionImpl] Committing, > tx=TransactionImpl:XidImpl [FormatId=257, > GlobalId=NICOLAS//25, BranchQual=], status=STATUS_ACTIVE > 16:03:09,690 TRACE [TransactionImpl] Before completion > done, tx=TransactionImpl:XidImpl [FormatId=257, > GlobalId=NICOLAS//25, BranchQual=], status=STATUS_ACTIVE > 16:03:09,690 TRACE [TransactionImpl] Zero phase commit: > No resources. > 16:03:09,690 TRACE [TransactionImpl] Committed OK, > tx=TransactionImpl:XidImpl [FormatId=257, > GlobalId=NICOLAS//25, BranchQual=] > 16:03:09,690 TRACE [LogInterceptor] End method=create > 16:03:09,752 TRACE [Registry] lookup > 491837535=jboss.j2ee:jndiName=ejb/ProductSearchHome,service=EJB > 16:03:09,752 TRACE [StatelessSessionContainer] METHOD > REMOTE INVOKE > 491837535||searchProductIDByRefToAndLicenseNumber|| > 16:03:09,752 TRACE [LogInterceptor] Start > method=searchProductIDByRefToAndLicenseNumber > 16:03:09,752 TRACE [TxInterceptorCMT] Current > transaction in MI is null > 16:03:09,752 TRACE [TxInterceptorCMT] TX_REQUIRED for > searchProductIDByRefToAndLicenseNumber timeout=0 > 16:03:09,752 TRACE [TxInterceptorCMT] Thread came in > with tx null > 16:03:09,752 TRACE [TransactionImpl] Created new > instance for tx=TransactionImpl:XidImpl [FormatId=257, > GlobalId=NICOLAS//26, BranchQual=] > 16:03:09,752 TRACE [TxInterceptorCMT] Starting new tx > TransactionImpl:XidImpl [FormatId=257, > GlobalId=NICOLAS//26, BranchQual=] > 16:03:09,752 TRACE [StatelessSessionInstancePool] Get > instance > [EMAIL PROTECTED] > test.ProductSearchSession > 16:03:09,752 TRACE [CachedConnectionManager] new stack > for key: [EMAIL PROTECTED] > 16:03:09,752 TRACE [ProxyFactoryFinderInterceptor] > invokerBInding is null in ProxyFactoryFinder > 16:03:09,752 TRACE [LogInterceptor] Start > method=findByRefToAndToLicense > 16:03:09,752 TRACE [TxInterceptorCMT] Current > transaction in MI is TransactionImpl:XidImpl > [FormatId=257, GlobalId=NICOLAS//26, BranchQual=] > 16:03:09,752 TRACE [TxInterceptorCMT] TX_REQUIRED for > findByRefToAndToLicense timeout=0 > 16:03:09,752 TRACE [TxInterceptorCMT] Thread came in > with tx TransactionImpl:XidImpl [FormatId=257, > GlobalId=NICOLAS//26, BranchQual=] > 16:03:09,752 TRACE [EntityInstancePool] Get instance > [EMAIL PROTECTED] > test.ProductCMP > 16:03:09,752 TRACE [CachedConnectionManager] old stack > for key: > [EMAIL PROTECTED] > 16:03:09,752 DEBUG [Product#findByRefToAndToLicense] > Executing SQL: SELECT DISTINCT t0_pr.ID FROM > tour_operator t1_to, product t0_pr WHERE > ((t1_to.LICENSE = ? AND t0_pr.REF_TO = ?)) AND > t1_to.ID=t0_pr.TO_ID > 16:03:09,752 TRACE [TransactionImpl] enlistResource(): > Entered, tx=TransactionImpl:XidImpl [FormatId=257, > GlobalId=NICOLAS//26, BranchQual=] status=STATUS_ACTIVE > 16:03:09,752 TRACE [TransactionImpl] > startResource(XidImpl [FormatId=257, > GlobalId=NICOLAS//26, BranchQual=1]) entered: > [EMAIL PROTECTED] > flags=0 > 16:03:09,752 TRACE [TransactionImpl] > startResource(XidImpl [FormatId=257, > GlobalId=NICOLAS//26, BranchQual=1]) leaving: > [EMAIL PROTECTED] > flags=0 > 16:03:09,752 TRACE [TransactionImpl] > registerSynchronization(): Entered, > tx=TransactionImpl:XidImpl [FormatId=257, > GlobalId=NICOLAS//26, BranchQual=] status=STATUS_ACTIVE > 16:03:09,752 TRACE [CachedConnectionManager] > registering connection from > [EMAIL PROTECTED], > connection : > [EMAIL PROTECTED], > key: > [EMAIL PROTECTED] > 16:03:09,752 TRACE [Product#findByRefToAndToLicense] > param: i=1, type=VARCHAR, value=MAR075950298 > 16:03:09,752 TRACE [Product#findByRefToAndToLicense] > param: i=2, type=VARCHAR, value=TURI3*3N1 > 16:03:09,752 TRACE [Product#id] result: i=1, > type=java.lang.Integer, value=7535 > 16:03:09,752 TRACE [CachedConnectionManager] > unregistering connection from > [EMAIL PROTECTED], > object: > [EMAIL PROTECTED], > key: > [EMAIL PROTECTED] > 16:03:09,752 TRACE [CachedConnectionManager] popped > object: > [EMAIL PROTECTED] > 16:03:09,752 TRACE [EntityInstancePool] 0/100 Free > instance:[EMAIL PROTECTED] > test.ProductCMP > 16:03:09,752 TRACE [TxInterceptorCMT] TxInterceptorCMT: > In finally > 16:03:09,752 TRACE [LogInterceptor] End > method=findByRefToAndToLicense > 16:03:09,752 TRACE [CachedConnectionManager] popped > object: > [EMAIL PROTECTED] > 16:03:09,752 TRACE [StatelessSessionInstancePool] > Discard > instance:[EMAIL PROTECTED]@335297#TransactionImpl:XidImpl > [FormatId=257, GlobalId=NICOLAS//26, > BranchQual=]#true#class test.ProductSearchSession > 16:03:09,752 TRACE [TransactionImpl] setRollbackOnly(): > Entered, tx=TransactionImpl:XidImpl [FormatId=257, > GlobalId=NICOLAS//26, BranchQual=] status=STATUS_ACTIVE > 16:03:09,752 TRACE [TxInterceptorCMT] TxInterceptorCMT: > In finally > 16:03:09,752 TRACE [TransactionImpl] rollback(): > Entered, tx=TransactionImpl:XidImpl [FormatId=257, > GlobalId=NICOLAS//26, BranchQual=] > status=STATUS_MARKED_ROLLBACK > 16:03:09,752 TRACE [TransactionImpl] endresources(0): > state=1 > 16:03:09,752 TRACE [TransactionImpl] > endResource(XidImpl [FormatId=257, > GlobalId=NICOLAS//26, BranchQual=1]) entered: > [EMAIL PROTECTED] > flag=67108864 > 16:03:09,768 TRACE [TransactionImpl] > endResource(XidImpl [FormatId=257, > GlobalId=NICOLAS//26, BranchQual=1]) leaving: > [EMAIL PROTECTED] > flag=67108864 > 16:03:09,768 ERROR [LogInterceptor] RuntimeException in > method: public abstract java.lang.Integer > test.ProductSearch.searchProductIDByRefToAndLicenseNumber(java.lang.String,java.lang.String) > throws javax.ejb.FinderException,java.rmi.RemoteException > java.lang.ClassCastException > at $Proxy84.findByRefToAndToLicense(Unknown Source) > at > test.SearchBean.searchProductIDByRefToAndLicenseNumber(SearchBean.java:62) > at > sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:324) > at > org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683) > at > org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186) > at > org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72) > at > org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84) > at > org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:317) > at > org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:150) > at > org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:111) > at > org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191) > at > org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122) > at > org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331) > at > org.jboss.ejb.Container.invoke(Container.java:709) > at > sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:324) > at > org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60) > at > org.jboss.mx.server.Invocation.dispatch(Invocation.java:62) > at > org.jboss.mx.server.Invocation.dispatch(Invocation.java:54) > at > org.jboss.mx.server.Invocation.invoke(Invocation.java:82) > at > org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:197) > at > org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473) > at > org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:360) > at > sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:324) > at > sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261) > at > sun.rmi.transport.Transport$1.run(Transport.java:148) > at > java.security.AccessController.doPrivileged(Native Method) > at > sun.rmi.transport.Transport.serviceCall(Transport.java:144) > at > sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460) > at > sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701) > at java.lang.Thread.run(Thread.java:534) > 16:03:09,768 TRACE [LogInterceptor] End > method=searchProductIDByRefToAndLicenseNumber > 16:03:09,768 TRACE [JRMPInvoker] Failed to invoke on > mbean: > jboss.j2ee:jndiName=ejb/ProductSearchHome,service=EJB > java.rmi.ServerException: RuntimeException; nested > exception is: > java.lang.ClassCastException > at > org.jboss.ejb.plugins.LogInterceptor.handleException(LogInterceptor.java:385) > at > org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:195) > at > org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122) > at > org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331) > at > org.jboss.ejb.Container.invoke(Container.java:709) > at > sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:324) > at > org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60) > at > org.jboss.mx.server.Invocation.dispatch(Invocation.java:62) > at > org.jboss.mx.server.Invocation.dispatch(Invocation.java:54) > at > org.jboss.mx.server.Invocation.invoke(Invocation.java:82) > at > org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:197) > at > org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473) > at > org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:360) > at > sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:324) > at > sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261) > at > sun.rmi.transport.Transport$1.run(Transport.java:148) > at > java.security.AccessController.doPrivileged(Native Method) > at > sun.rmi.transport.Transport.serviceCall(Transport.java:144) > at > sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460) > at > sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701) > at java.lang.Thread.run(Thread.java:534) > Caused by: java.lang.ClassCastException > at $Proxy84.findByRefToAndToLicense(Unknown Source) > at > test.SearchBean.searchProductIDByRefToAndLicenseNumber(SearchBean.java:62) > at > sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:324) > at > org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683) > at > org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186) > at > org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72) > at > org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84) > at > org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:317) > at > org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:150) > at > org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:111) > at > org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191) > ... 25 more -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa - If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira ------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ JBoss-Development mailing list JBoss-Development@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jboss-development