*
The moose likes Websphere and the fly likes WSAD 5.1 using CMR .  hasNext() method of LinkSet$Itr throws IllegalStateExce Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "WSAD 5.1 using CMR .  hasNext() method of LinkSet$Itr throws IllegalStateExce" Watch "WSAD 5.1 using CMR .  hasNext() method of LinkSet$Itr throws IllegalStateExce" New topic
Author

WSAD 5.1 using CMR . hasNext() method of LinkSet$Itr throws IllegalStateExce

Cliff Edwards
Greenhorn

Joined: Mar 22, 2004
Posts: 16
Hello All,
I need help with a problem I've been looking at for too long. The environment is WSAD 5.1 using CMR on Oracle.
The problem: hasNext() method of LinkSet$Itr throws IllegalStateException.
A Struts Action class is calling a Stateless Session Bean over a local interface. The session bean is calling a method of a local entity bean that returns a Collection ( this is the "many" side of a "many-to-one" relationship). The method actually returns an instance of com.ibm.ws.ejbpersistence.associations.LinkSet. Then I extract an Iterator from the LinkSet. It is actually an instance of com.ibm.ws.ejbpersistence.associations.LinkSet$Itr. The problem comes when I try to call hasNext() on the instance of LinkSet$Itr. It throws an IllegalStateException. Can anyone help?
Here's the stack detail:
[4/21/04 13:31:12:459 EDT] c940c94 WSRdbDataSour u Database version is
Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
[4/21/04 13:31:12:459 EDT] c940c94 WSRdbDataSour u JDBC Driver version is 9.2.0.3.0
[4/21/04 13:36:02:105 EDT] c940c94 RequestProces W org.apache.struts.action.RequestProcessor Unhandled Exception thrown: class java.lang.IllegalStateException
[4/21/04 13:36:03:487 EDT] c940c94 WebGroup E SRVE0026E: [Servlet Error]-[]: java.lang.IllegalStateException
at java.lang.Throwable.<init>(Throwable.java)
at com.ibm.ws.ejbpersistence.associations.LinkSet.checkValidTx(Unknown Source)
at com.ibm.ws.ejbpersistence.associations.LinkSet.access$100(Unknown Source)
at com.ibm.ws.ejbpersistence.associations.LinkSet$Itr.hasNext(Unknown Source)
at com.certegy.webdisclosure.TestAction.execute(TestAction.java)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:948)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:530)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:176)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:201)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:610)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:431)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java)
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
Robert,
Judging from the

line in the stack trace, I assume that you're having a problem because you're attempting to use the CMR collection outside of the transaction that created it.
You should make sure 1) that your session bean is executing within a transaction, and 2) that the CMR accessor will execute in your session bean's transaction by setting it's trans-attribute appropriately. Try that out and get back to us.


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
Roland Barcia
author
Ranch Hand

Joined: Apr 15, 2004
Posts: 181
Does the stateless Session Bean have a transaction. Per the EJB 2.0 spec, a CMR based collection is only valid in the transaction that accesses it. The Statelss Session Bean method should be set to REQUIRED so that it can access the collection through a finder and iterate through it all in the same transaction.


Roland Barcia: IBM Distinguished Engineer, CTO Mobile for Lab Services
Cliff Edwards
Greenhorn

Joined: Mar 22, 2004
Posts: 16
Problem is solved. Thanks very much!
You were right, I was violating transaction boundaries. I've reorganized the code and it works fine now. I should not have tried to return an Iterator to the Struts client code.
Thanks again!
Robert
Nathan Yeager
Greenhorn

Joined: Apr 02, 2002
Posts: 2
I am having a similar issue to this thread. However, when specifying a Required transaction on my session bean's method I get a failure to enlist one of my other resources in the transaction. Apparently with multiple resources involved in this method it requires 2-phase-commit, and one of mine supports only single-phase.

I now get the following:

[5/18/06 14:50:15:719 CDT] 3a70cf63 TransactionIm E WTRN0062E: An illegal attempt to use multiple resources that have only one
-phase capability has occurred within a global transaction.
[5/18/06 14:50:15:802 CDT] 3a70cf63 LocalTransact E J2CA0030E: Method enlist caught com.ibm.ws.Transaction.IllegalResourceIn2P
CTransactionException
at com.ibm.ws.Transaction.JTA.TransactionImpl.enlistResource(TransactionImpl.java:1788)
at com.ibm.ws.Transaction.JTA.TranManagerSet.enlistOnePhase(TranManagerSet.java:525)
at com.ibm.ejs.j2c.LocalTransactionWrapper.enlist(LocalTransactionWrapper.java:517)
at com.ibm.ejs.j2c.ConnectionEventListener.interactionPending(ConnectionEventListener.java:753)
at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.processInteractionPendingEvent(WSRdbManagedConnectionImpl.java:
1560)
at com.ibm.ws.rsadapter.cci.WSRdbConnectionImpl.enlistIfNecessary(WSRdbConnectionImpl.java:621)
at com.ibm.ws.rsadapter.cci.WSInteractionImpl.execute(WSInteractionImpl.java:435)
at com.ibm.wsspi.ejbpersistence.WSEJBToRAAdapter.executeFinder(WSEJBToRAAdapter.java:173)
at com.ibm.ws.rsadapter.cci.WSRelationalRAAdapter.executeFinder(WSRelationalRAAdapter.java:358)
at com.ibm.ws.ejbpersistence.dataaccess.DataAccessRequestImpl.execute(Unknown Source)
at com.ibm.ws.ejbpersistence.beanextensions.ConcreteBeanStatefulInstanceExtensionImpl.executeQuery(Unknown Source)
at com.ibm.ws.ejbpersistence.beanextensions.ConcreteBeanStatefulInstanceExtensionImpl.fetchRecordFromDataStore(Unknown
Source)
at com.ibm.ws.ejbpersistence.beanextensions.ConcreteBeanStatefulInstanceExtensionImpl.getRecordForLoad(Unknown Source)
at com.ibm.ws.ejbpersistence.beanextensions.ConcreteBeanStatefulInstanceExtensionImpl.executeLoad(Unknown Source)
at com.ibm.ws.ejbpersistence.beanextensions.CBReadyState.ejbLoad(Unknown Source)
at com.ibm.ws.ejbpersistence.beanextensions.ConcreteBeanStatefulInstanceExtensionImpl.ejbLoad(Unknown Source)
at com.coral.ecap.common.ejb.entity.invoice.ConcreteInvoice_c0842a91.ejbLoad(Unknown Source)
at com.ibm.ejs.container.ContainerManaged2_0BeanO.loadForEnlist(ContainerManaged2_0BeanO.java:361)
at com.ibm.ejs.container.EntityBeanO.enlist(EntityBeanO.java:729)
at com.ibm.ejs.container.activator.OptCEntityActivationStrategy.atActivate(OptCEntityActivationStrategy.java:139)
at com.ibm.ejs.container.activator.Activator.activateBean(Activator.java:519)
at com.ibm.ejs.container.EJSHome.activateBean_Common(EJSHome.java:1360)
at com.ibm.ejs.container.EJSHome.activateBean_Local(EJSHome.java:1274)
at com.coral.ecap.common.ejb.entity.invoice.EJSCMPInvoiceHomeBean_c0842a91.findByPrimaryKey_Local(Unknown Source)
at com.coral.ecap.common.ejb.entity.invoice.EJSLocalCMPInvoiceHome_c0842a91.findByPrimaryKey(Unknown Source)
at com.coral.ecap.common.ejb.session.taskmanagement.TaskManagerSLBean.getActivitiesForInvoice(TaskManagerSLBean.java:3
57)
at com.coral.ecap.common.ejb.session.taskmanagement.EJSRemoteStatelessTaskManager_f90839ae.getActivitiesForInvoice(Unk
nown Source)
at com.coral.ecap.common.ejb.session.taskmanagement._TaskManagerSL_Stub.getActivitiesForInvoice(_TaskManagerSL_Stub.ja
va:395)
at com.coral.ecap.webapp.invoice.InvoiceEJBProxy.getActivitiesForInvoice(InvoiceEJBProxy.java:778)
at com.coral.ecap.webapp.invoice.action.ReportAction.execute(ReportAction.java:203)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:465)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1422)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:505)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:76)
at com.coral.ecap.common.webapp.filter.AuthenticateFilter.doFilter(AuthenticateFilter.java:74)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:132)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:71)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:1162)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:676)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:203)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:125)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:294)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:116)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:186)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:652)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:458)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:912)
while trying to enlist resources from datasource /ecap/jdbc/ecap with the Transaction Manager for the current transaction, an
d threw a Exception.
[5/18/06 14:50:15:986 CDT] 3a70cf63 DataAccessReq E PMGR6022E: Error using adapter to create or execute an Interaction. com.ib
m.ws.rsadapter.cci.WSInteractionImpl@6f4fcf23



Any ideas?

[ May 18, 2006: Message edited by: Nathan Yeager ]
[ May 18, 2006: Message edited by: Nathan Yeager ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: WSAD 5.1 using CMR . hasNext() method of LinkSet$Itr throws IllegalStateExce
 
Similar Threads
ServletException BeanUtils populate
Call servlet from action class
Null PointerException
How to use PostgreSQL with WSAD 5.1
classcastexception when running on Unix server.