[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Limitation of Ozone -- Cant return an iterator



On Fri, 01 Dec 2000, Neil Aggarwal wrote:
> Hello:
> 
> In one of my persistent class's implementation, I have a method that 
> returns an Interator for a collection:
> 	public Iterator getDataIterator() {
> 		return map.getValues().iterator();
> 	}
> 
> When I call this method, the proxy object throws this
> Exception:
> org.ozoneDB.UnexpectedException: java.io.WriteAbortedException: Writing
> aborted by exception; java.io.NotSerializableException:
> java.util.HashMap$HashIterator
> 	at
> persistent.ControllerImpl_Proxy.getDataIterator(ControllerImpl_Proxy.java:67)
> 	at DatabaseTest.doGet(DatabaseTest.java:102)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> 	at
> org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
> 	at
> org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:597)
> 	at
> org.apache.tomcat.servlets.InvokerServlet.service(InvokerServlet.java:257)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> 	at
> org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
> 	at
> org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
> 	at
> org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java:156)
> 	at
> org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338)
> 	at java.lang.Thread.run(Thread.java:484)
> 
> Here is the generated code in the Proxy:
>    public java.util.Iterator getDataIterator () {
>       try {
>          Object target = link.fetch (this, Lock.LEVEL_READ);
>          if (target != null) {
>             return
> (java.util.Iterator)ResultConverter.substituteOzoneCompatibles
> (((persistent.ControllerImpl)target).getDataIterator());
>             }
>          else {
>             Object[] args = {};
>             Object result = link.invoke (this, 6, args,
> Lock.LEVEL_READ);
>             return (java.util.Iterator)result;
>             }
>          }
>       catch (RuntimeException e) {
>          e.fillInStackTrace();
>          throw e;
>          }
>       catch (Exception e) {
>          e.fillInStackTrace();
>          throw new UnexpectedException (e.toString());
>          }
>       }
>    }
> 
> 
> Is this a limitation of Ozone in that I cant return an iterator from the
> database?
> What other such limitations exist?

Neil, I'm always saying that application developers must keep in mind the
special architecture of ozone -- it's the strength and the limiting factor when
doing app design/development with ozone....

In your code you are trying to manipulate the internal data of an database
object via ordinary Java references. The hashmap iterator keeps a ordinary
java reference to the hashmap to do its job. It knows nothing about ozone's
persistent references (proxies). After the iterator is serialized thru the
socket connection its references are no longer valid in the new VM.

Besides, java.util.HashMap$HashIterator is plain and simple not serializable.
One could hardly tell this a limitation of ozone.


Falko
-- 
______________________________________________________________________
Falko Braeutigam                              mailto:falko@smb-tec.com
SMB GmbH                                        http://www.smb-tec.com