T1a_HelloWorld: java.lang.NullPointerExceptio.Is it SERVER_URL the cause?

18 views
Skip to first unread message

Sikolo

unread,
Mar 7, 2019, 3:59:00 PM3/7/19
to jwpl-users
Hi everybody,

Can you help with the following issue. I'm trying to run the T1a_HelloWorld class from the toturial, but I'm getting the exception listed below. What is the true value of SERVER_URL? Is there any example? I firstly used "localhost", the I used "jdbc:mysql://localhost". In both case, I'm getting the same exception. Is it SERVER_URL the cause? How can I solve this? 

Thanks you.

Exception in thread "main" java.lang.NullPointerException
at de.tudarmstadt.ukp.wikipedia.api.hibernate.WikiHibernateUtil.getProperties(WikiHibernateUtil.java:72)
at de.tudarmstadt.ukp.wikipedia.api.hibernate.WikiHibernateUtil.getConfiguration(WikiHibernateUtil.java:144)
at de.tudarmstadt.ukp.wikipedia.api.hibernate.WikiHibernateUtil.getSessionFactory(WikiHibernateUtil.java:49)
at de.tudarmstadt.ukp.wikipedia.api.Wikipedia.__getHibernateSession(Wikipedia.java:791)
at de.tudarmstadt.ukp.wikipedia.api.MetaData.<init>(MetaData.java:41)
at de.tudarmstadt.ukp.wikipedia.api.Wikipedia.<init>(Wikipedia.java:87)
at org.jgnn.T1a_HelloWorld.main(T1a_HelloWorld.java:51)



Source file is:
public class T1a_HelloWorld implements WikiConstants {

    public static void main(String[] args) throws WikiApiException {

        // configure the database connection parameters
        DatabaseConfiguration dbConfig = new DatabaseConfiguration();
        //dbConfig.setHost("SERVER_URL");
dbConfig.setHost("jdbc:mysql://localhost");
        dbConfig.setDatabase("DB_PTWIKI");
        dbConfig.setUser("root");
        dbConfig.setPassword("secret");
        dbConfig.setLanguage(Language.portuguese);

        // Create a new German wikipedia.
        Wikipedia wiki = new Wikipedia(dbConfig);

        // Get the page with title "Hello world".
        // May throw an exception, if the page does not exist.
        Page page = wiki.getPage("Brasil");
        System.out.println(page.getText());

    }
}

Message has been deleted

Sikolo

unread,
Mar 7, 2019, 7:06:56 PM3/7/19
to jwpl-users
I changed the "T1a_HelloWorld.java" altering the constructor of the DatabaseConfiguration class as listed below.
This solved the first issue, but I'm still getting errors like shown below. Can someone help me with this?
Thanks you.

CODE:
-----------------------------------------------------------------


public class T1a_HelloWorld implements WikiConstants {

public static void main(String[] args) throws WikiApiException {

String host="localhost";
String user="root";
String password="secret";
String database="DB_PTWIKI";
Language language= Language.portuguese;
DatabaseConfiguration dbConfig =
new DatabaseConfiguration(host,database, user, password, language);


// Create a new German wikipedia.
Wikipedia wiki = new Wikipedia(dbConfig);

// Get the page with title "Hello world".
// May throw an exception, if the page does not exist.
Page page = wiki.getPage("Brasil");
System.out.println(page.getText());

}
}
-------------------------------------------------------
ERROR:

Exception in thread "main" org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [Category]
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.validateTable(AbstractSchemaValidator.java:121)
at org.hibernate.tool.schema.internal.GroupedSchemaValidatorImpl.validateTables(GroupedSchemaValidatorImpl.java:42)
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.performValidation(AbstractSchemaValidator.java:89)
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.doValidation(AbstractSchemaValidator.java:68)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:191)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:312)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:462)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:710)
at de.tudarmstadt.ukp.wikipedia.api.hibernate.WikiHibernateUtil.getSessionFactory(WikiHibernateUtil.java:51)


at de.tudarmstadt.ukp.wikipedia.api.Wikipedia.__getHibernateSession(Wikipedia.java:791)
at de.tudarmstadt.ukp.wikipedia.api.MetaData.<init>(MetaData.java:41)
at de.tudarmstadt.ukp.wikipedia.api.Wikipedia.<init>(Wikipedia.java:87)

at org.jgnn.T1a_HelloWorld.main(T1a_HelloWorld.java:59)

Torsten Zesch

unread,
Mar 8, 2019, 1:38:59 AM3/8/19
to jw...@googlegroups.com
The error message says your "Category" table is missing. Could you make sure that it is actually there?

-Torsten
--
You received this message because you are subscribed to the Google Groups "jwpl-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jwpl+uns...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sikolo

unread,
Mar 8, 2019, 8:25:22 AM3/8/19
to jwpl-users
Thank you for replying. The Category table was created and populated as described in Jhttps://dkpro.github.io/dkpro-jwpl/JWPLCore_GettingStarted/, as you can see in an image attached to this message.
Category_DB.PNG

Torsten Zesch

unread,
Mar 8, 2019, 10:18:39 AM3/8/19
to jw...@googlegroups.com
I notice that all the table names are lower case. Depending on your setup, table name resolution is case sensitive and the schema definition:
https://github.com/dkpro/dkpro-jwpl/blob/master/de.tudarmstadt.ukp.wikipedia.wikimachine/jwpl_tables.sql
assumes upper case table name for "Category"

-Torsten
https://groups.google.com/d/optout <https://groups.google.com/d/optout>.

Sikolo

unread,
Mar 8, 2019, 11:13:57 AM3/8/19
to jwpl-users
For instance, the Category table SQL is listed below, but in MySQL tables and database are not case sensitive, i.e, for MySQL Category and category are the same thing.
Is there any way to solve this?


CREATE TABLE `Category` (
  `id` bigint(20) NOT NULL auto_increment,
  `pageId` int(11) default NULL,
  `name` varchar(255) default NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `pageId` (`pageId`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

Torsten Zesch

unread,
Mar 8, 2019, 11:19:31 AM3/8/19
to jw...@googlegroups.com
You could try to lower the logging level to see more debug output. Without more information it is hard to say what is going on.



On 08.03.19, 17:13, "jw...@googlegroups.com on behalf of Sikolo" <jw...@googlegroups.com on behalf of mvo...@gmail.com> wrote:

I used tables names suggested by https://github.com/dkpro/dkpro-jwpl/blob/master/de.tudarmstadt.ukp.wikipedia.wikimachine/jwpl_tables.sql.
For instance, the Category table SQL is listed below, but in MySQL tables and database are not case sensitive, i.e, for MySQL Category and category are the same thing.
Is there any way to solve this?




CREATE TABLE `Category` (
`id` bigint(20) NOT NULL auto_increment,
`pageId` int(11) default NULL,
`name` varchar(255) default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `pageId` (`pageId`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

Em sexta-feira, 8 de março de 2019 12:18:39 UTC-3, Torsten Zesch escreveu:

I notice that all the table names are lower case. Depending on your setup, table name resolution is case sensitive and the schema definition:

https://github.com/dkpro/dkpro-jwpl/blob/master/de.tudarmstadt.ukp.wikipedia.wikimachine/jwpl_tables.sql
assumes upper case table name for "Category"

-Torsten



On 08.03.19, 14:25, "jw...@googlegroups.com <> on behalf of Sikolo" <jw...@googlegroups.com <> on behalf of
mvo...@gmail.com <>> wrote:

Thank you for replying. The Category table was created and populated as described in Jhttps://dkpro.github.io/dkpro-jwpl/JWPLCore_GettingStarted/ <http://dkpro.github.io/dkpro-jwpl/JWPLCore_GettingStarted/>,

Sikolo

unread,
Mar 8, 2019, 11:52:37 AM3/8/19
to jwpl-users
Thanks you. I saw some tips about MySQL settings (attached links), which seem to confirm that may be a case sensitve problem.  I will try to apply these settings first. I give a feedback after that.

Sikolo

unread,
Mar 8, 2019, 1:21:46 PM3/8/19
to jwpl-users
The tips from the last sites didn't work.  This is logging of the exception:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
mar 08, 2019 10:13:09 AM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {[WORKING]}
mar 08, 2019 10:13:09 AM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
mar 08, 2019 10:13:13 AM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
mar 08, 2019 10:13:13 AM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
mar 08, 2019 10:13:13 AM org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl makeLobCreatorBuilder
INFO: HHH000422: Disabling contextual LOB creation as connection was null
mar 08, 2019 10:13:15 AM org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator instantiateC3p0Provider
WARN: HHH000022: c3p0 properties were encountered, but the c3p0 provider class was not found on the classpath; these properties are going to be ignored.
mar 08, 2019 10:13:15 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!)
mar 08, 2019 10:13:15 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001005: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://localhost/DB_PTWIKI]
mar 08, 2019 10:13:15 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001001: Connection properties: {useUnicode=true, user=root, password=****, characterEncoding=UTF-8}
mar 08, 2019 10:13:15 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001003: Autocommit mode: false
mar 08, 2019 10:13:15 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections <init>
INFO: HHH000115: Hibernate connection pool size: 1 (min=1)
mar 08, 2019 10:13:15 AM org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl getIsolatedConnection
INFO: HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@547c04c4] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.
mar 08, 2019 10:13:16 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl stop
INFO: HHH10001008: Cleaning up connection pool [jdbc:mysql://localhost/DB_PTWIKI]
Exception in thread "main" org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [Category]
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.validateTable(AbstractSchemaValidator.java:121)
at org.hibernate.tool.schema.internal.GroupedSchemaValidatorImpl.validateTables(GroupedSchemaValidatorImpl.java:42)
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.performValidation(AbstractSchemaValidator.java:89)
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.doValidation(AbstractSchemaValidator.java:68)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:191)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:312)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:462)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:710)
at de.tudarmstadt.ukp.wikipedia.api.hibernate.WikiHibernateUtil.getSessionFactory(WikiHibernateUtil.java:51)
at de.tudarmstadt.ukp.wikipedia.api.Wikipedia.__getHibernateSession(Wikipedia.java:791)
at de.tudarmstadt.ukp.wikipedia.api.MetaData.<init>(MetaData.java:41)
at de.tudarmstadt.ukp.wikipedia.api.Wikipedia.<init>(Wikipedia.java:87)
at org.jgnn.T1a_HelloWorld.main(T1a_HelloWorld.java:59)


Em sexta-feira, 8 de março de 2019 13:19:31 UTC-3, Torsten Zesch escreveu:

Torsten Zesch

unread,
Mar 8, 2019, 1:26:05 PM3/8/19
to jw...@googlegroups.com
Unfortunately that more detailed output doesn’t help much. 
Can you rename the table to start with upper case letter, or is this not supported?

Sikolo

unread,
Mar 8, 2019, 7:43:08 PM3/8/19
to jwpl-users
Issue resolved! Thank a lots for your big help.
Like you noticed the problem was case sensitivity in tables names. In his default installation, MySQL databases and tables names are not case sensitive.
So I had to configure MySQL Server to allow case sensitive. I changed the default value of the --lower-case-table-names (or lower_case_table_names) global system variable, in Windows OS, from 1 to 2.
Now the code is running without errors.

Thank you.

Reply all
Reply to author
Forward
0 new messages