Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » OM2M » Configure OM2M to connect to the server
Configure OM2M to connect to the server [message #1780942] Tue, 30 January 2018 08:57 Go to next message
Sting Yong is currently offline Sting YongFriend
Messages: 2
Registered: January 2018
Junior Member
Hello everyone,

https://wiki.eclipse.org/OM2M/one/Advanced_DB
I've been trying to run the default database (h2) in server mode using the same way as the tutorial above. I downloaded the package from h2 website and launched the server. The tutorial said I need to modify the constant in the config.ini file. Here are several dburls I've been trying out:

org.eclipse.om2m.dbUrl=jdbc\:h2\:tcp\://127.0.0.1\:9092/~/sample
org.eclipse.om2m.dbUrl=jdbc:h2:tcp://localhost/~/test
org.eclipse.om2m.dbUrl=jdbc:h2:tcp://127.0.0.1:9092/~/sample

After I modified the dburl and started "sh start.sh" in cmd, it showed errors such as "Error in creation of EntityManagerFactory" and "Error initializing Database: EntityManagerFactory is null".
I think I've modified the dburl in wrong ways. Can anyone tell me how I should configure the config.ini file so that I am able to run h2 database in server mode?
Re: Configure OM2M to connect to the server [message #1780950 is a reply to message #1780942] Tue, 30 January 2018 10:09 Go to previous messageGo to next message
Guillaume Garzone is currently offline Guillaume GarzoneFriend
Messages: 54
Registered: April 2015
Member
Hello,

The url should have this form: org.eclipse.om2m.dbUrl=jdbc\:h2\:tcp\://127.0.0.1\:9092/~/sample
However, did you modify the configuration of H2? By default the H2 server seems to use 8082 port, not 9092.
I recommend you to look for more information here too: http://www.h2database.com/html/tutorial.html

Try to connect to your H2 server using your browser as stated in the H2 tutorial to be sure your H2 server is started correctly.
Re: Configure OM2M to connect to the server [message #1781220 is a reply to message #1780942] Sat, 03 February 2018 09:08 Go to previous message
Sting Yong is currently offline Sting YongFriend
Messages: 2
Registered: January 2018
Junior Member
Hi Guillaume,

Thank you for your reply.
I started a TCP server using command "java -jar h2-1.4.196.jar -webAllowOthers -tcpAllowOthers" and it showed that the TCP server is running at tcp://127.0.1.1:41903
(The port may change every time I started a new TCP server). After I successfully started the server, I tested the connection using the web console of h2 so I think my h2 server was started correctly.
I then modified dburl in the config.ini file :
org.eclipse.om2m.dbUrl=jdbc\:h2\:tcp\://127.0.1.1\:41903/~/indb

However, there were always errors as below when I started "sh start.sh" in cmd:
Error in creation of EntityManagerFactory
javax.persistence.PersistenceException: Exception [EclipseLink-4019] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Error while obtaining information about the database. Refer to the nested exception for more details.
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:766)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:204)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:182)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getDatabaseSession(EntityManagerFactoryImpl.java:527)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:140)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:177)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
at org.eclipse.om2m.persistence.eclipselink.internal.DBServiceJPAImpl.init(DBServiceJPAImpl.java:103)
at org.eclipse.om2m.persistence.eclipselink.Activator$1.run(Activator.java:51)
Caused by: Exception [EclipseLink-4019] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Error while obtaining information about the database. Refer to the nested exception for more details.
at org.eclipse.persistence.exceptions.DatabaseException.errorRetrieveDbMetadataThroughJDBCConnection(DatabaseException.java:368)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.setOrDetectDatasource(DatabaseSessionImpl.java:238)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:741)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:239)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:685)
... 8 more
Caused by: org.h2.jdbc.JdbcSQLException: Connection is broken: "unexpected status 16777216" [90067-186]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:179)
at org.h2.message.DbException.get(DbException.java:155)
at org.h2.engine.SessionRemote.done(SessionRemote.java:637)
at org.h2.engine.SessionRemote.close(SessionRemote.java:568)
at org.h2.jdbc.JdbcConnection.close(JdbcConnection.java:384)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.setOrDetectDatasource(DatabaseSessionImpl.java:235)
... 11 more
[2018-01-30 20:41:19,565 ERROR] - org.eclipse.om2m.persistence.eclipselink.internal.DBServiceJPAImpl
ERROR initializing Database: EntityManagerFactory is null!

I did also tried jdbc\:h2\:tcp\://127.0.0.1\:8082/~/sample or changing the dbuser and password, but similar errors showed up as above when I started running CSE. It seemed like OM2M was not able to find my h2 database. Should I delete the default embedded h2 database when configuring OM2M to connect to server? Can anyone tell me where I did it wrong?

[Updated on: Sat, 03 February 2018 09:09]

Report message to a moderator

Previous Topic:Achieving authentication on a public OM2M-IN
Next Topic:connection between MN-CSE and IN-CSE
Goto Forum:
  


Current Time: Tue Mar 19 02:16:58 GMT 2024

Powered by FUDForum. Page generated in 0.02194 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top