sqlite-sync / SQLite-sync.com

AMPLI-SYNC is a framework for synchronizing data between a Sqlite database and an MS SQL/MySQL/Oracle/PostgreSQL database. With this framework your application can work completely offline (Airplane Mode), then perform an automated Bidirectional Synchronization when an internet connection becomes available.
https://ampliapps.com/sqlite-sync/
BSD 3-Clause "New" or "Revised" License
329 stars 82 forks source link

Sync issue from local to server database. #30

Open dhruvvarde opened 4 years ago

dhruvvarde commented 4 years ago

I have successfully sync the data and get all the data in the local SQLite database but when I add a new record in local and try to sync on the server at that time, the new data is not reflating in the server database. Its creating one .dat file and the data is present in it in XML format.

I am using ionic 4 to send the data on the server database.

So can you please help to solve this issue?

sqlite-sync commented 4 years ago

Can you share logs?

dhruvvarde commented 4 years ago

I have sent the sync request to the server like this :

This is my server URL : http://192.168.1.15:8086/amplisync-testnew/API3/Send

Request is : {"content":"<?xml version=\"1.0\" encoding=\"utf-8\"?><SyncData xmlns=\"urn:sync-schema\"><tab n=\"MergeIdentity\"><\/ins><![CDATA[116]]><\/Id><![CDATA[9]]><\/TableId><![CDATA[215005]]><\/SubscriberId><![CDATA[1]]><\/Rev><![CDATA[90040]]><\/IdentityStart><![CDATA[95040]]><\/IdentityEnd><![CDATA[90041]]><\/IdentityCurrent><![CDATA[A3B362DA-E084-4400-B583-E0B8546B212D]]><\/RowId><\/r><\/upd><\/tab><tab n=\"MergeSubscribers\"><\/ins><\/upd><\/tab><tab n=\"Users\"><\/ins><\/upd><\/tab><tab n=\"Documents\"><![CDATA[90041]]><\/docId><![CDATA[test msg]]><\/docName><![CDATA[null]]><\/RowId><\/r><\/ins><\/upd><\/tab><tab n=\"UserDocuments\"><\/ins><\/upd><\/tab><tab n=\"Test\"><\/ins><\/upd><\/tab><\/delete><\/SyncData>","subscriber":"ffffffff-9aaa-6f72-ffff-ffff99d603a9","version":"3"}

Error :

<!doctype html>HTTP Status 500 – Internal Server Error

HTTP Status 500 – Internal Server Error


Type Exception Report

Message java.lang.NullPointerException

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

javax.servlet.ServletException: java.lang.NullPointerException
org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:489)
org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
org.apache.catalina.filters.CorsFilter.handleNonCORS(CorsFilter.java:352)
org.apache.catalina.filters.CorsFilter.doFilter(CorsFilter.java:171)

Root Cause

java.lang.NullPointerException
java.text.SimpleDateFormat.<init>(Unknown Source)
java.text.SimpleDateFormat.<init>(Unknown Source)
SQLiteSyncCore.SyncServer.Synchronization.SyncService.ParseStatmentParameter(SyncService.java:1315)
SQLiteSyncCore.SyncServer.Synchronization.SyncService.PushUpdateRecords(SyncService.java:1165)
SQLiteSyncCore.SyncServer.Synchronization.SyncService.PushTableData(SyncService.java:1015)
SQLiteSyncCore.SyncServer.Synchronization.SyncService.CommitChangesToDb(SyncService.java:933)
SQLiteSyncCore.SyncServer.Synchronization.SyncService.ReceiveData(SyncService.java:848)
com.sqlitesync.ws.SyncAPI3.RecieveChanges(SyncAPI3.java:91)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$VoidOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:143)
org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326)
org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
org.glassfish.jersey.internal.Errors.process(Errors.java:315)
org.glassfish.jersey.internal.Errors.process(Errors.java:297)
org.glassfish.jersey.internal.Errors.process(Errors.java:267)
org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)
org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473)
org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
org.apache.catalina.filters.CorsFilter.handleNonCORS(CorsFilter.java:352)
org.apache.catalina.filters.CorsFilter.doFilter(CorsFilter.java:171)

Note The full stack trace of the root cause is available in the server logs.


Apache Tomcat/9.0.27

swaytz commented 4 years ago

I face the same error when using the android client. Server to sqlite synchronization works fine but the sqlite to server synchronization throws a similar exception.

02-Dec-2019 14:28:33.412 SEVERE [http-nio-8080-exec-9] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [sqlite-sync-serlvet] in context with path [/SqliteSync] threw exception [java.lang.NullPointerException] with root cause java.lang.NullPointerException at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:598) at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:580) at SQLiteSyncCore.SyncServer.Synchronization.SyncService.ParseStatmentParameter(SyncService.java:1315) at SQLiteSyncCore.SyncServer.Synchronization.SyncService.PushInsertRecords(SyncService.java:1070) at SQLiteSyncCore.SyncServer.Synchronization.SyncService.PushTableData(SyncService.java:1009) at SQLiteSyncCore.SyncServer.Synchronization.SyncService.CommitChangesToDb(SyncService.java:933) at SQLiteSyncCore.SyncServer.Synchronization.SyncService.ReceiveData(SyncService.java:848) at com.sqlitesync.ws.SyncAPI3.RecieveChanges(SyncAPI3.java:91) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144) at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$VoidOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:143) at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99) at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326) at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) at org.glassfish.jersey.internal.Errors.process(Errors.java:315) at org.glassfish.jersey.internal.Errors.process(Errors.java:297) at org.glassfish.jersey.internal.Errors.process(Errors.java:267) at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473) at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:501) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1376) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748)

IchoTolot commented 4 years ago

Do you set TIMESTAMP_FORMAT?

swaytz commented 4 years ago

I have followed the documentation and the properties files has the following contents. Is there any other place to set the TIMESTAMP_FORMAT?

DB_ENGINE = mysql DBURL = jdbc:mysql://localhost:3306/amplisync?rewriteBatchedStatements=true&useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC DBUSER = DBPASS = DBDRIVER = com.mysql.cj.jdbc.Driver DATE_FORMAT = yyyy-MM-dd HH:mm:ss HISTORY_DAYS = 7 LOG_LEVEL = 4

sqlite-sync commented 4 years ago

You need to put it in sync.properties

DATE_FORMAT =yyyy-MM-dd HH:mm:ss TIMESTAMP_FORMAT =yyyy-MM-dd HH:mm:ssZ

swaytz commented 4 years ago

Thank you very much.Adding the timestamp solved the problem.