Migration from H2 to Mysql

hscho5 days ago

okay I run into another issue: The old data seems okay, but if I connect my devices I can see an error like this:

2025-04-23 13:39:19  INFO: [Tb5493edb] connected
2025-04-23 13:39:19  INFO: [Tb5493edb: osmand < 10.0.2.231] POST /?id=531557×tamp=1745415330&lat=*&lon=*&speed=0&bearing=0&altitude=49.82160402922185&accuracy=11.48409016131648&batt=80 HTTP/1.1\r\nHost: 10.0.2.12:5055\r\nConnection: keep-alive\r\nAccept: */*\r\nUser-Agent: TraccarClient/60 CFNetwork/3826.500.111.2.2 Darwin/24.4.0\r\nAccept-Language: de-DE,de;q=0.9\r\nContent-Length: 0\r\nAccept-Encoding: gzip, deflate\r\n\r\n
2025-04-23 13:39:19  WARN: [Tb5493edb] error - Cannot invoke "Object.getClass()" because "object" is null - NullPointerException (CacheKey:22 < CacheGraph:95 < CacheManager:291 < *:317 < *:164 < ConnectionManager:157 < ...)
2025-04-23 13:39:19  INFO: [Tb5493edb] disconnected
Anton Tananaev5 days ago

You're likely missing some referenced objects in the database.

hscho5 days ago

here is the full stack trace:

12:5055\r\nConnection: keep-alive\r\nAccept: */*\r\nUser-Agent: TraccarClient/60 CFNetwork/3826.500.111.2.2 Darwin/24.4.0\r\nAccept-Language: de-DE,de;q=0.9\r\nContent-Length: 0\r\nAccept-Encoding: gzip, deflate\r\n\r\n
2025-04-23 13:48:32 DEBUG: Event received
2025-04-23 13:48:32  WARN: [Tdb36e8ed] error - 
java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "object" is null
    at org.traccar.session.cache.CacheKey.<init>(CacheKey.java:22)
    at org.traccar.session.cache.CacheGraph.addLink(CacheGraph.java:95)
    at org.traccar.session.cache.CacheManager.invalidatePermission(CacheManager.java:291)
    at org.traccar.session.cache.CacheManager.initializeCache(CacheManager.java:317)
    at org.traccar.session.cache.CacheManager.addDevice(CacheManager.java:164)
    at org.traccar.session.ConnectionManager.getDeviceSession(ConnectionManager.java:157)
    at org.traccar.BaseProtocolDecoder.getDeviceSession(BaseProtocolDecoder.java:135)
    at org.traccar.protocol.OsmAndProtocolDecoder.decode(OsmAndProtocolDecoder.java:70)
    at org.traccar.ExtendedObjectDecoder.channelRead(ExtendedObjectDecoder.java:73)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at org.traccar.WrapperContext.fireChannelRead(WrapperContext.java:102)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:107)
    at org.traccar.WrapperInboundHandler.channelRead(WrapperInboundHandler.java:56)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at org.traccar.WrapperContext.fireChannelRead(WrapperContext.java:102)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:318)
    at org.traccar.WrapperInboundHandler.channelRead(WrapperInboundHandler.java:56)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:93)
    at org.traccar.handler.network.StandardLoggingHandler.channelRead(StandardLoggingHandler.java:62)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at org.traccar.handler.network.NetworkMessageHandler.channelRead(NetworkMessageHandler.java:36)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1357)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:868)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:840)
2025-04-23 13:48:32  INFO: [Tdb36e8ed] disconnected

any idea how to proceed?

Anton Tananaev5 days ago

You need to find the device in the database, then follow all the linked objects, including the ones linked through groups and users, and find which links are leading to missing objects.

hscho4 days ago

ok I was able to fix it here. for the record, the issue was the tc_user_device table:

SELECT * FROM tc_user_device
WHERE deviceid = 3 AND userid NOT IN (SELECT id FROM tc_users);

this should not ouput anything. In my case the it did:

userid deviceid
2 3

then I deleted the entry:

DELETE FROM tc_user_device
WHERE deviceid = 3 AND userid = 2;