HughP / simal

Automatically exported from code.google.com/p/simal
0 stars 0 forks source link

Log why Simal database can't be created or opened #351

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
If the database can't be created (or opened) the should be a clear description 
in the log, probably an resulting IOException shouldn't be caught.

This is the root exception, Wicket Exceptions left out for readability.

Caused by: java.lang.NullPointerException
        at atlas.lib.FileOps.existsAnyFiles(FileOps.java:64)
        at com.hp.hpl.jena.tdb.sys.SetupTDB.locationMetadata(SetupTDB.java:545)
        at com.hp.hpl.jena.tdb.sys.SetupTDB.buildDataset(SetupTDB.java:185)
        at com.hp.hpl.jena.tdb.sys.DatasetGraphSetup.createDatasetGraph(DatasetGraphSetup.java:21)
        at com.hp.hpl.jena.tdb.sys.CachingTDBMaker.createDatasetGraph(CachingTDBMaker.java:39)
        at com.hp.hpl.jena.tdb.sys.TDBMaker._createGraph(TDBMaker.java:64)
        at com.hp.hpl.jena.tdb.TDBFactory.createGraph(TDBFactory.java:89)
        at com.hp.hpl.jena.tdb.TDBFactory.createGraph(TDBFactory.java:95)
        at com.hp.hpl.jena.tdb.TDBFactory.createModel(TDBFactory.java:55)
        at uk.ac.osswatch.simal.model.jena.simal.JenaDatabaseSupport.initialiseDatabase(JenaDatabaseSupport.java:90)
        at uk.ac.osswatch.simal.model.jena.simal.JenaSimalRepository.initialise(JenaSimalRepository.java:124)
        at uk.ac.osswatch.simal.rdf.AbstractSimalRepository.initialise(AbstractSimalRepository.java:341)
        at uk.ac.osswatch.simal.wicket.UserApplication.getRepository(UserApplication.java:119)
        at uk.ac.osswatch.simal.wicket.data.SortableProjectDataProvider.<init>(SortableProjectDataProvider.java:42)
        at uk.ac.osswatch.simal.wicket.panel.ProjectListPanel.populatePanel(ProjectListPanel.java:107)
        at uk.ac.osswatch.simal.wicket.panel.ProjectListPanel.<init>(ProjectListPanel.java:59)
        at uk.ac.osswatch.simal.wicket.UserHomePage.<init>(UserHomePage.java:30)
        ... 32 more
Exception in thread "Timer-3" java.lang.NullPointerException
        at uk.ac.osswatch.simal.model.jena.simal.JenaSimalRepository.getAllProjects(JenaSimalRepository.java:272)
        at uk.ac.osswatch.simal.importData.PTSWImport.importLatestDOAP(PTSWImport.java:187)
        at uk.ac.osswatch.simal.schedule.ImportPTSWTask.run(ImportPTSWTask.java:40)
        at java.util.TimerThread.mainLoop(Timer.java:512)
        at java.util.TimerThread.run(Timer.java:462)

Original issue reported on code.google.com by cmah...@googlemail.com on 17 Sep 2010 at 11:05

GoogleCodeExporter commented 9 years ago
There is a similar Exception if there is a problem with the imported data:

Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.apache.wicket.session.DefaultPageFactory.createPage(DefaultPageFactory.java:192)
    ... 27 more
Caused by: com.hp.hpl.jena.rdf.model.LiteralRequiredException: Apache UGH 
metadata library
    at com.hp.hpl.jena.rdf.model.impl.StatementImpl.getLiteral(StatementImpl.java:101)
    at com.hp.hpl.jena.rdf.model.impl.StatementBase.getString(StatementBase.java:127)
    at uk.ac.osswatch.simal.model.jena.Resource.getLiteralValue(Resource.java:198)
    at uk.ac.osswatch.simal.model.jena.DoapResource.getName(DoapResource.java:77)
    at uk.ac.osswatch.simal.wicket.panel.ProjectSummaryPanel.populatePage(ProjectSummaryPanel.java:83)
    at uk.ac.osswatch.simal.wicket.panel.ProjectSummaryPanel.<init>(ProjectSummaryPanel.java:65)
    at uk.ac.osswatch.simal.wicket.UserHomePage.<init>(UserHomePage.java:32)
    ... 32 more

This is caused by malformed date as described here[1].

[1] http://jira.codehaus.org/browse/MDOAP-27

Original comment by cmah...@googlemail.com on 17 Sep 2010 at 1:13

GoogleCodeExporter commented 9 years ago
Comment 1 is unrelated to this issue, but the reason of the error is the fact 
that it's a resource reference: 

<name rdf:resource="Apache UGH metadata library"/>

whereas the range of the "name" property in DOAP is literal [1]. If you're 
requesting  additional checks on import to make sure these errors are spotted 
on import please create a new issue for that.

[1] http://usefulinc.com/ns/doap

Original comment by sander.v...@oucs.ox.ac.uk on 17 Sep 2010 at 2:16

GoogleCodeExporter commented 9 years ago
Just before this exception a log message records where the database will be 
created :

DEBUG uk.ac.osswatch.simal.model.jena.simal.JenaSimalRepository - Creating TDB 
database with URL /opt/simal/data/simal_TDB

A check should be added here if the path is writable.

Note that there is no IOException thrown anywhere. Jena throws a 
NullPointerException and that one is wrapped and logged. Other than assuring 
the path is valid and writable there's not very much sensible we can do here.

Original comment by sander.v...@oucs.ox.ac.uk on 17 Sep 2010 at 2:59

GoogleCodeExporter commented 9 years ago
Ok, this probably a problem (the IOException) of Jena then. I'll think I first 
have to check if there already is a issue regarding the import. I'm probably 
not the first one seeing this.

Original comment by cmah...@googlemail.com on 17 Sep 2010 at 4:12

GoogleCodeExporter commented 9 years ago
There's no IOException. In Jena, class atlas.lib.FileOps, this method is 
executed: 

    /** See if there are any files in this directory */ 
    public static boolean existsAnyFiles(String dir)
    {
        File d = new File(dir) ;
        File[] entries = d.listFiles() ;
        return entries.length > 0 ;
    }

d.listFiles() returns null, in according with the javadoc [1], which leads to 
the NPE.

[1] http://download.oracle.com/javase/6/docs/api/java/io/File.html#listFiles()

Original comment by sander.v...@oucs.ox.ac.uk on 17 Sep 2010 at 5:34