B4J Question java.lang.NullPointerException: Inflater has been closed

schimanski

Well-Known Member
Licensed User
Longtime User
Does somebody knows, what it means? It happens, when I try to upload a string at first time to my webserver. It only happen in release-mode, not in debug:

B4X:
2016-05-23 14:00:06.214:INFO::main: Logging initialized @878ms
2016-05-23 14:00:06.429:INFO:oejs.Server:main: jetty-9.3.z-SNAPSHOT
2016-05-23 14:00:06.474:INFO:oejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@1d371b2d{/,file:///D:/Projekt-Ordner/EIS-Server%203.019%20separater%20Admin-Port/Objects/EIS_Messenger/,AVAILABLE}
2016-05-23 14:00:06.477:INFO:oejs.AbstractNCSARequestLog:main: Opened D:\Projekt-Ordner\EIS-Server 3.019 separater Admin-Port\Objects\Admin\LogDateien\Jetty\b4j-2016_05_23.request.log
2016-05-23 14:00:06.498:INFO:oejs.ServerConnector:main: Started ServerConnector@704d6e83{HTTP/1.1,[http/1.1]}{0.0.0.0:51043}
2016-05-23 14:00:06.526:INFO:oejus.SslContextFactory:main: x509=X509@10a035a0(xx.xxx.xxx.xx (eis-messenger),h=[xx.xxx.xxx.xx],w=[]) for SslContextFactory@67b467e9(file:///D:/Projekt-Ordner/EIS-Server%203.019%20separater%20Admin-Port/Objects/eis.keystore,null)
2016-05-23 14:00:06.528:INFO:oejus.SslContextFactory:main: x509=X509@47db50c5(eis-messenger,h=[],w=[]) for SslContextFactory@67b467e9(file:///D:/Projekt-Ordner/EIS-Server%203.019%20separater%20Admin-Port/Objects/eis.keystore,null)
2016-05-23 14:00:06.747:INFO:oejs.ServerConnector:main: Started ServerConnector@49c386c8{SSL,[ssl, http/1.1]}{0.0.0.0:51044}
2016-05-23 14:00:06.760:INFO:oejs.Server:main: Started @1427ms
2016-05-23 14:00:06.764:INFO:oejs.Server:main: jetty-9.3.z-SNAPSHOT
2016-05-23 14:00:06.765:INFO:oejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@3eb7fc54{/,file:///D:/Projekt-Ordner/EIS-Server%203.019%20separater%20Admin-Port/Objects/EIS_Messenger/,AVAILABLE}
2016-05-23 14:00:06.766:INFO:oejs.AbstractNCSARequestLog:main: Opened D:\Projekt-Ordner\EIS-Server 3.019 separater Admin-Port\Objects\Admin\LogDateien\AdminJetty\b4j-2016_05_23.request.log
2016-05-23 14:00:06.769:INFO:oejs.ServerConnector:main: Started ServerConnector@7f552bd3{HTTP/1.1,[http/1.1]}{0.0.0.0:51045}
2016-05-23 14:00:06.772:INFO:oejus.SslContextFactory:main: x509=X509@460d0a57(89.163.211.60 (eis-messenger),h=[89.163.211.60],w=[]) for SslContextFactory@47d90b9e(file:///D:/Projekt-Ordner/EIS-Server%203.019%20separater%20Admin-Port/Objects/eis.keystore,null)
2016-05-23 14:00:06.773:INFO:oejus.SslContextFactory:main: x509=X509@1184ab05(eis-messenger,h=[],w=[]) for SslContextFactory@47d90b9e(file:///D:/Projekt-Ordner/EIS-Server%203.019%20separater%20Admin-Port/Objects/eis.keystore,null)
2016-05-23 14:00:06.782:INFO:oejs.ServerConnector:main: Started ServerConnector@3aefe5e5{SSL,[ssl, http/1.1]}{0.0.0.0:51046}
2016-05-23 14:00:06.783:INFO:oejs.Server:main: Started @1449ms

java.lang.RuntimeException: java.lang.NullPointerException: Inflater has been closed
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:114)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
    at anywheresoftware.b4j.object.JServlet$Handle.run(JServlet.java:115)
    at anywheresoftware.b4j.object.JServlet.Handle(JServlet.java:91)
    at anywheresoftware.b4j.object.JServlet.doFilter(JServlet.java:62)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1668)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:581)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:224)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1158)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1090)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119)
    at org.eclipse.jetty.server.Server.handle(Server.java:517)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:308)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:242)
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:261)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
    at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:192)
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:261)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
    at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75)
    at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213)
    at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException: Inflater has been closed
    at java.util.zip.Inflater.ensureOpen(Inflater.java:389)
    at java.util.zip.Inflater.inflate(Inflater.java:257)
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:152)
    at java.io.DataInputStream.readFully(DataInputStream.java:195)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readInt(B4XSerializator.java:123)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readObject(B4XSerializator.java:347)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ReadObject(B4XSerializator.java:110)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ConvertBytesToObject(B4XSerializator.java:81)
    at de.sekutor.eisserver.keyvaluestore._vvvvvvvvvvv0(keyvaluestore.java:92)
    at de.sekutor.eisserver.keyvaluestore._vvvvvvvvvvvv2(keyvaluestore.java:121)
    at de.sekutor.eisserver.nutzerdb._v0(nutzerdb.java:101)
    at de.sekutor.eisserver.passwortfilter._filter(passwortfilter.java:78)
    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:497)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
    ... 28 more
 
Last edited:

schimanski

Well-Known Member
Licensed User
Longtime User
Yes. I use one for users and the second one for admin features on a second port. Is it a problem?
 
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
Yes, that can I do. But what about writing on the same file? The user-server and the admin-server needs to write to the same contact-file. Could it be a problem?
 
Upvote 0

billzhan

Active Member
Licensed User
Longtime User
Which method do you use to write the contact-file?
You could have problem if you write to the same file at the same time.

Try:
Write to the file in a single thread(typically main thread) with CallSubDelayed.
The lock method may also help
 
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
The contact file is a simple map and saved with writeb4xobject. I want to change it to a keystore on sqlite-base..
 
Last edited:
Upvote 0

billzhan

Active Member
Licensed User
Longtime User
If the contact file is not written frequently, you could written multiple files(with different names, say timestamp+ramdonnumber). Always use the latest one, and clear the old versions.

I think DB solution is fine
 
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
Sorry, but I'm not able to find the reason for the following exception. I'm using the keyvaluestore2-Class and the exception is always raised at first time, I try to get an encypted value out of the database with

B4X:
Dim Credentials As List
Credentials=NutzerDatenbank.GetEncrypted(User, "test")

After that, it runs for a while. The problem is, that it only happens in release-mode, not in debug. I have isolated the code and the error is caused in the following line of the sub

B4X:
Public Sub Get(Key As String) As Object
    Dim rs As ResultSet = sql1.ExecQuery2("SELECT value FROM main WHERE key = ?", Array As String(Key))
    Dim result As Object = Null
    If rs.NextRow Then
        result = ser.ConvertBytesToObject(rs.GetBlob2(0))   =>>>  the exception is raised here
    End If
    rs.Close
    Return result
End Sub

of the keyvaluestore2-Class (Version 2.00). I have tried to make a demo-app, but this works without problems. I use the keyvaluestore-class in my non-Ui-Web-Server. I didn't start two servers like I do it above.

Did somebody has an idea?

B4X:
java.lang.RuntimeException: java.lang.NullPointerException: Inflater has been closed
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:114)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
    at anywheresoftware.b4j.object.JServlet$Handle.run(JServlet.java:124)
    at anywheresoftware.b4j.object.JServlet.Handle(JServlet.java:100)
    at anywheresoftware.b4j.object.JServlet.doFilter(JServlet.java:62)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1668)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:581)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:224)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1158)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1090)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119)
    at org.eclipse.jetty.server.Server.handle(Server.java:517)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:308)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:242)
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:261)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
    at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:192)
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:261)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
    at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75)
    at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213)
    at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException: Inflater has been closed
    at java.util.zip.Inflater.ensureOpen(Inflater.java:389)
    at java.util.zip.Inflater.inflate(Inflater.java:257)
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:152)
    at java.io.DataInputStream.readFully(DataInputStream.java:195)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readInt(B4XSerializator.java:123)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readObject(B4XSerializator.java:347)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ReadObject(B4XSerializator.java:110)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ConvertBytesToObject(B4XSerializator.java:81)
    at de.sekutor.eisserver.keyvaluestore._vvvvvvvvvv7(keyvaluestore.java:90)
    at de.sekutor.eisserver.keyvaluestore._vvvvvvvvvvv1(keyvaluestore.java:119)
    at de.sekutor.eisserver.nutzerdb._v0(nutzerdb.java:99)
    at de.sekutor.eisserver.passwortfilter._filter(passwortfilter.java:76)
    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:497)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
    ... 28 more
 
Last edited:
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
Thanks for help. I have extracted all the code to reproduce the exception and it seems, that the problem is my code in LadeService of the B4A-Client-App:

B4X:
CallSubDelayed(LadeService, "Status_senden")
CallSubDelayed(LadeService, "Kontaktstempel_laden")

In release-mode of the server, it seems not to be possible to send the two http-operations one after the other. To test it, start the server and after that, start the client-app. Normaly, the server will cause the exception after the first start of the client in release-mode, not in debug. If not, restart the client one or two times, and the exception will be raised. It is not exactly the same as above, but it seems to be the same reason:

B4X:
2016-05-30 20:02:31.102:INFO::main: Logging initialized @175ms
2016-05-30 20:02:31.416:INFO:oejs.Server:main: jetty-9.3.z-SNAPSHOT
2016-05-30 20:02:31.475:INFO:oejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@3ab39c39{/,file:///D:/1/Objects/Example/,AVAILABLE}
2016-05-30 20:02:31.480:INFO:oejs.AbstractNCSARequestLog:main: Opened D:\1\Objects\logs\b4j-2016_05_30.request.log
2016-05-30 20:02:31.615:INFO:oejs.ServerConnector:main: Started ServerConnector@21fb2042{HTTP/1.1,[http/1.1]}{0.0.0.0:51044}
2016-05-30 20:02:31.616:INFO:oejs.Server:main: Started @691ms
java.lang.RuntimeException: java.io.EOFException: Unexpected end of ZLIB input stream
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:114)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
    at anywheresoftware.b4j.object.JServlet$Handle.run(JServlet.java:124)
    at anywheresoftware.b4j.object.JServlet.Handle(JServlet.java:100)
    at anywheresoftware.b4j.object.JServlet.doFilter(JServlet.java:62)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1668)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:581)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:224)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1158)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1090)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119)
    at org.eclipse.jetty.server.Server.handle(Server.java:517)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:308)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:242)
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:261)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
    at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75)
    at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213)
    at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.EOFException: Unexpected end of ZLIB input stream
    at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:240)
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:122)
    at java.io.DataInputStream.readByte(DataInputStream.java:265)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readByte(B4XSerializator.java:131)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readObject(B4XSerializator.java:299)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ReadObject(B4XSerializator.java:110)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ConvertBytesToObject(B4XSerializator.java:81)
    at de.sekutor.eisserver.keyvaluestore._vvvvvv4(keyvaluestore.java:83)
    at de.sekutor.eisserver.keyvaluestore._vvvvvv6(keyvaluestore.java:112)
    at de.sekutor.eisserver.nutzerdb._v7(nutzerdb.java:60)
    at de.sekutor.eisserver.passwortfilter._filter(passwortfilter.java:67)
    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:497)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
    ... 25 more
 

Attachments

  • B4JServer.zip
    8.6 KB · Views: 193
  • B4AClient.zip
    4.6 KB · Views: 204
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
I don't want to send it one after the other. I think, that my code doesn't work for multiple requests to the keyvaluestore. That's a problem. When there are a lot of devices which communicates with the server at the same time, the server raises this exception because every request will first be checked if the credentials in the keystore are correct. Do I have to use another database solution for this?
 
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
:confused: I deleted my database and changed the code in the keyvaluestore2-class under CreateTable in

B4X:
'creates the main table (if it does not exist)
Private Sub CreateTable
    sql1.ExecNonQuery("PRAGMA journal_mode = wal")
    sql1.ExecNonQuery("CREATE TABLE IF NOT EXISTS main(key TEXT PRIMARY KEY, value NONE)")
End Sub

The same exception. Is it correct, that the exception is the result of an concurrent access? If yes, the line sql1.ExecNonQuery("PRAGMA journal_mode = wal") should enable it, or not?


Edit:

I fall into despair...I use the same client-code under b4i and the exception is not raised...
 
Last edited:
Upvote 0

billzhan

Active Member
Licensed User
Longtime User
You are using libs for ui (jfx ) in non-ui app. Not sure if jSystemTray lib is OK with non-ui app

Check your IDE and Java version.
 
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
Thanks for your answer. jSystemTray is OK for non-ui under windows. It doesn't has to do with the exception above.
 
Upvote 0

billzhan

Active Member
Licensed User
Longtime User
:confused: I deleted my database and changed the code in the keyvaluestore2-class under CreateTable in

B4J server starts here. Not test with b4a client.
You also need to to checke the libs version (to match your b4a ) :
 

Attachments

  • libs.PNG
    libs.PNG
    15.5 KB · Views: 265
Upvote 0

billzhan

Active Member
Licensed User
Longtime User
@schimanski

Run the B4A client(IDE 5.8): The B4J (IDE 4.21) exceptions throw, but the client side received the post/get result.

change the server side , no exceptions anymore :

B4X:
    If Ergebnis <> "Zugriff gewaehrt!" Then
        If Ergebnis.Length=0 Then
            Ergebnis="Unautorisierter Zugriff!"
        End If
        If Ergebnis="Zugriff mit falschen Absendernamen oder Passwort erfolgt!" Or Ergebnis.Length=0 Then
            resp.SendError(403, "Unautorisierter Zugriff!")
        Else
            resp.Write(Ergebnis)  ' shouldn't SendError here
        End If
        Return False
    Else
        Return True
    End If


Client side :

B4X:
Sub JobDone (job As HttpJob)
    Log(job.GetString)
    ToastMessageShow(job.GetString,True)
    job.Release
End Sub
 
Upvote 0
Top