[Mulgara-general] problem with Session.modelExists(URI uri)

Paul Gearon gearon at ieee.org
Fri Nov 30 00:05:39 CST 2007


The real problem here is the use of the JRDF interface.  The code  
behind this interface was using some bad processes which violated ACID  
requirements.  As a result of the transaction work that Andrae did, he  
had to break this interface.  He intends to get it working again, but  
it has not been a priority lately.

As for what exactly JRDF was doing wrong, why it had to be broken, and  
what can be done to fix it.... those are questions for Andrae.

In the meantime, there isn't anything that JRDF could do that TQL  
can't do (in fact, JRDF could be implemented as a wrapper around  
TQL).  I recommend using that instead - at least for now.

Regards,
Paul

On Nov 22, 2007, at 12:01 AM, Edwin Shin wrote:

> I'm seeing another problem with checking for model existence, but  
> only with a remote connection. I'm attaching a JUnit test that  
> provokes the error.
>
> In particular, it appears to the call to SessionFactory.close() that  
> is provoking the error:
>
> org.mulgara.query.QueryException: Failed to determine model existence
> 	at  
> org.mulgara.resolver.DatabaseSession.execute(DatabaseSession.java:634)
> 	at  
> org 
> .mulgara.resolver.DatabaseSession.modelExists(DatabaseSession.java: 
> 431)
> 	at  
> org 
> .mulgara 
> .resolver 
> .LocalJRDFDatabaseSession.modelExists(LocalJRDFDatabaseSession.java: 
> 75)
> 	at  
> org 
> .mulgara 
> .server 
> .rmi 
> .SessionWrapperRemoteSession 
> .modelExists(SessionWrapperRemoteSession.java:331)
> 	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:597)
> 	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java: 
> 305)
> 	at sun.rmi.transport.Transport$1.run(Transport.java:159)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
> 	at  
> sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java: 
> 535)
> 	at sun.rmi.transport.tcp.TCPTransport 
> $ConnectionHandler.run0(TCPTransport.java:790)
> 	at sun.rmi.transport.tcp.TCPTransport 
> $ConnectionHandler.run(TCPTransport.java:649)
> 	at java.util.concurrent.ThreadPoolExecutor 
> $Worker.runTask(ThreadPoolExecutor.java:885)
> 	at java.util.concurrent.ThreadPoolExecutor 
> $Worker.run(ThreadPoolExecutor.java:907)
> 	at java.lang.Thread.run(Thread.java:619)
> 	at  
> sun 
> .rmi 
> .transport 
> .StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java: 
> 255)
> 	at  
> sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java: 
> 233)
> 	at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142)
> 	at  
> org 
> .mulgara.server.rmi.RemoteJRDFSessionImpl_Stub.modelExists(Unknown  
> Source)
> 	at  
> org 
> .mulgara 
> .server 
> .rmi 
> .RemoteSessionWrapperSession 
> .modelExists(RemoteSessionWrapperSession.java:424)
> 	at  
> org 
> .trippi.impl.mulgara.ModelExistsTest.testRemote(ModelExistsTest.java: 
> 45)
> 	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:597)
> 	at junit.framework.TestCase.runTest(TestCase.java:154)
> 	at junit.framework.TestCase.runBare(TestCase.java:127)
> 	at junit.framework.TestResult$1.protect(TestResult.java:106)
> 	at junit.framework.TestResult.runProtected(TestResult.java:124)
> 	at junit.framework.TestResult.run(TestResult.java:109)
> 	at junit.framework.TestCase.run(TestCase.java:118)
> 	at junit.framework.TestSuite.runTest(TestSuite.java:208)
> 	at junit.framework.TestSuite.run(TestSuite.java:203)
> 	at  
> org 
> .eclipse 
> .jdt 
> .internal 
> .junit 
> .runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
> 	at  
> org 
> .eclipse 
> .jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at  
> org 
> .eclipse 
> .jdt 
> .internal 
> .junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> 	at  
> org 
> .eclipse 
> .jdt 
> .internal 
> .junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> 	at  
> org 
> .eclipse 
> .jdt 
> .internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> 	at  
> org 
> .eclipse 
> .jdt 
> .internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java: 
> 196)
> Caused by: org.mulgara.query.QueryException:  
> org.mulgara.query.MulgaraTransactionException: Transaction rollback  
> triggered
> 	at  
> org 
> .mulgara 
> .resolver 
> .MulgaraTransaction.implicitRollback(MulgaraTransaction.java:487)
> 	at  
> org 
> .mulgara 
> .resolver.MulgaraTransaction.activate(MulgaraTransaction.java:145)
> 	at  
> org 
> .mulgara.resolver.MulgaraTransaction.execute(MulgaraTransaction.java: 
> 576)
> 	at  
> org.mulgara.resolver.DatabaseSession.execute(DatabaseSession.java:631)
> 	at  
> org 
> .mulgara.resolver.DatabaseSession.modelExists(DatabaseSession.java: 
> 431)
> 	at  
> org 
> .mulgara 
> .resolver 
> .LocalJRDFDatabaseSession.modelExists(LocalJRDFDatabaseSession.java: 
> 75)
> 	at  
> org 
> .mulgara 
> .server 
> .rmi 
> .SessionWrapperRemoteSession 
> .modelExists(SessionWrapperRemoteSession.java:331)
> 	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:597)
> 	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java: 
> 305)
> 	at sun.rmi.transport.Transport$1.run(Transport.java:159)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
> 	at  
> sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java: 
> 535)
> 	at sun.rmi.transport.tcp.TCPTransport 
> $ConnectionHandler.run0(TCPTransport.java:790)
> 	at sun.rmi.transport.tcp.TCPTransport 
> $ConnectionHandler.run(TCPTransport.java:649)
> 	at java.util.concurrent.ThreadPoolExecutor 
> $Worker.runTask(ThreadPoolExecutor.java:885)
> 	at java.util.concurrent.ThreadPoolExecutor 
> $Worker.run(ThreadPoolExecutor.java:907)
> 	at java.lang.Thread.run(Thread.java:619)
> Caused by: org.mulgara.query.QueryException: Unable to enlist  
> systemResolver:null into transaction
> 	at  
> org 
> .mulgara 
> .resolver 
> .DatabaseOperationContext.initiate(DatabaseOperationContext.java:969)
> 	at  
> org 
> .mulgara 
> .resolver.MulgaraTransaction.activate(MulgaraTransaction.java:143)
> 	... 19 more
> Caused by: java.lang.IllegalStateException: Cannot create read only  
> view of uninitialized StringPool.
> 	at org.mulgara.store.stringpool.xa.XAStringPoolImpl 
> $ReadOnlyStringPool.<init>(XAStringPoolImpl.java:1080)
> 	at  
> org 
> .mulgara 
> .store 
> .stringpool 
> .xa.XAStringPoolImpl.newReadOnlyStringPool(XAStringPoolImpl.java:442)
> 	at  
> org 
> .mulgara 
> .resolver 
> .StringPoolSessionFactory 
> .newReadOnlyResolverSession(StringPoolSessionFactory.java:204)
> 	at  
> org 
> .mulgara 
> .resolver 
> .store 
> .StatementStoreResolverFactory 
> .newResolver(StatementStoreResolverFactory.java:227)
> 	at  
> org 
> .mulgara 
> .resolver 
> .DatabaseOperationContext.initiate(DatabaseOperationContext.java:966)
> 	... 20 more
>
>
> The testLocal() test is just to make the point that with a local  
> connection, there's no problem. However, for testLocal() to succeed  
> you will need to have applied the workaround for  
> ModelExistsOperation that Paul suggested previously (attached as  
> well). You could also just skip testLocal() as it's testRemote()  
> that is exhibiting the problem.
> package org.trippi.impl.mulgara;
>
> import java.net.URI;
>
> import junit.framework.TestCase;
>
> import org.mulgara.jrdf.LocalJRDFSession;
> import org.mulgara.query.QueryException;
> import org.mulgara.resolver.LocalJRDFDatabaseSession;
> import org.mulgara.server.JRDFSession;
> import org.mulgara.server.SessionFactory;
> import org.mulgara.server.driver.SessionFactoryFinder;
> import org.mulgara.server.local.LocalSessionFactory;
>
> public class ModelExistsTest extends TestCase {
>
>    public void testLocal() throws Exception {
>        URI serverURI = new URI("local://localhost/server1");
>        URI modelURI = new URI("local://localhost/server1#ri");
>
>        LocalSessionFactory factory = (LocalSessionFactory)  
> SessionFactoryFinder.newSessionFactory(serverURI);
>        LocalJRDFSession session = (LocalJRDFDatabaseSession)  
> factory.newJRDFSession();
>
>        assertFalse(session.modelExists(modelURI));
>
>        factory.close();
>
>        factory = (LocalSessionFactory)  
> SessionFactoryFinder.newSessionFactory(serverURI);
>        session = (LocalJRDFDatabaseSession) factory.newJRDFSession();
>        assertFalse(session.modelExists(modelURI));
>    }
>
>    public void testRemote() throws Exception {
>        URI serverURI = new URI("rmi://localhost:1099/server1");
>        URI modelURI = new URI("rmi://localhost/server1#ri");
>
>        SessionFactory factory =  
> SessionFactoryFinder.newSessionFactory(serverURI, true);
>        JRDFSession session = (JRDFSession) factory.newJRDFSession();
>
>        assertFalse(session.modelExists(modelURI));
>
>        factory.close(); // comment this out to pass
>        factory = SessionFactoryFinder.newSessionFactory(serverURI,  
> true);
>        session = (JRDFSession) factory.newJRDFSession();
>        assertFalse(session.modelExists(modelURI));
>    }
> }Index: src/jar/resolver/java/org/mulgara/resolver/ 
> ModelExistsOperation.java
> ===================================================================
> --- src/jar/resolver/java/org/mulgara/resolver/ 
> ModelExistsOperation.java	(revision 501)
> +++ src/jar/resolver/java/org/mulgara/resolver/ 
> ModelExistsOperation.java	(working copy)
> @@ -66,10 +66,17 @@
>                       ResolverSessionFactory resolverSessionFactory,
>                       DatabaseMetadata       metadata) throws  
> Exception
>   {
> -    long model = systemResolver.lookupPersistent(new  
> URIReferenceImpl(
> +    try {
> +      long model = systemResolver.lookupPersistent(new  
> URIReferenceImpl(
>         modelURI));
> -
> -    result = systemResolver.modelExists(model);
> +      result = systemResolver.modelExists(model);
> +      // Temporary workaround: if modelURI is not known, the  
> localize attempt
> +      // fails and returns an exception. However, in this case, we  
> should return
> +      // false. See:
> +      // http://mulgara.org/pipermail/mulgara-general/2007-October/000195.html
> +    } catch(LocalizeException le) {
> +        result = false;
> +    }
>   }
>
>   public boolean isWriteOperation() {
>
> _______________________________________________
> Mulgara-general mailing list
> Mulgara-general at mulgara.org
> http://mulgara.org/mailman/listinfo/mulgara-general



More information about the Mulgara-general mailing list