B4J Question Inline Java intents work fine in IDE debug mode, not work in execute compiled file

Gnappo jr

Active Member
Licensed User
Longtime User
see test.zip example in
https://www.b4x.com/android/forum/c...ot-present-in-debug-mode.20471/#message-66480


in a class module I added the following code:

#if java
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import java.security.Provider;
import java.security.Security;
static{
Provider BC = new BouncyCastleProvider();
Security.addProvider(BC);
}
#End If

Starting the program from the IDE of B4j, everything works well. When I compile the compiled version of the class module called the added java code, I get this error message:

C:\Users\hp840>java -jar c:\x\star.jar

2017-10-08 21:42:53.987:INFO::main: Logging initialized @199ms to org.eclipse.jetty.util.log.StdErrLog
2017-10-08 21:42:54.956:INFO:eek:ejs.Server:main: jetty-9.4.z-SNAPSHOT
2017-10-08 21:42:55.019:INFO:eek:ejs.session:main: DefaultSessionIdManager workerName=node0
2017-10-08 21:42:55.019:INFO:eek:ejs.session:main: No SessionScavenger set, using defaults
2017-10-08 21:42:55.019:INFO:eek:ejs.session:main: Scavenging every 600000ms
2017-10-08 21:42:55.034:INFO:eek:ejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@5bfa9431{/,file:///C:/Users/hp840/www,AVAILABLE}
2017-10-08 21:42:55.050:INFO:eek:ejs.AbstractNCSARequestLog:main: Opened C:\Users\hp840\logs\b4j-2017_10_08.request.log
2017-10-08 21:42:55.065:INFO:eek:ejs.AbstractConnector:main: Started ServerConnector@5bdd284{HTTP/1.1,[http/1.1]}{0.0.0.0:8888}
2017-10-08 21:42:55.065:INFO:eek:ejs.Server:main: Started @1284ms
Server started
[Ljava.lang.String;@31e04985
[Ljava.lang.String;@617a5bd5
java.lang.RuntimeException: java.lang.SecurityException: JCE cannot authenticate the provider BC
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:119)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:77)
at anywheresoftware.b4j.object.JServlet$Handle.run(JServlet.java:130)
at anywheresoftware.b4j.object.JServlet.Handle(JServlet.java:110)
at anywheresoftware.b4j.object.JServlet.doGet(JServlet.java:84)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:841)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:535)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:564)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:317)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:126)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.SecurityException: JCE cannot authenticate the provider BC
at javax.crypto.Cipher.getInstance(Cipher.java:657)
at javax.crypto.Cipher.getInstance(Cipher.java:596)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at anywheresoftware.b4j.agraham.reflection.Reflection.RunStaticMethod(Reflection.java:994)
at b4j.example.webservice1._initializecipher(webservice1.java:200)
at b4j.example.webservice1._decrypt(webservice1.java:74)
at b4j.example.webservice1._handle(webservice1.java:167)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90)
... 33 more
Caused by: java.util.jar.JarException: file:/C:/x/star.jar has unsigned entries - anywheresoftware/b4j/object/JavaObject$1.class
at javax.crypto.JarVerifier.verifySingleJar(JarVerifier.java:500)
at javax.crypto.JarVerifier.verifyJars(JarVerifier.java:361)
at javax.crypto.JarVerifier.verify(JarVerifier.java:289)
at javax.crypto.JceSecurity.verifyProviderJar(JceSecurity.java:159)
at javax.crypto.JceSecurity.getVerificationResult(JceSecurity.java:185)
at javax.crypto.Cipher.getInstance(Cipher.java:653)
... 47 more
java.lang.RuntimeException: java.lang.SecurityException: JCE cannot authenticate the provider BC
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:119)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:77)
at anywheresoftware.b4j.object.JServlet$Handle.run(JServlet.java:130)
at anywheresoftware.b4j.object.JServlet.Handle(JServlet.java:110)
at anywheresoftware.b4j.object.JServlet.doGet(JServlet.java:84)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:841)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:535)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:564)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:317)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:126)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.SecurityException: JCE cannot authenticate the provider BC
at javax.crypto.Cipher.getInstance(Cipher.java:657)
at javax.crypto.Cipher.getInstance(Cipher.java:596)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at anywheresoftware.b4j.agraham.reflection.Reflection.RunStaticMethod(Reflection.java:994)
at b4j.example.webservice1._initializecipher(webservice1.java:200)
at b4j.example.webservice1._decrypt(webservice1.java:74)
at b4j.example.webservice1._handle(webservice1.java:167)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90)
... 33 more
Caused by: java.util.jar.JarException: file:/C:/x/star.jar has unsigned entries - anywheresoftware/b4j/object/JavaObject$1.class
at javax.crypto.JarVerifier.verifySingleJar(JarVerifier.java:500)
at javax.crypto.JarVerifier.verifyJars(JarVerifier.java:361)
at javax.crypto.JarVerifier.verify(JarVerifier.java:289)
at javax.crypto.JceSecurity.verifyProviderJar(JceSecurity.java:159)
at javax.crypto.JceSecurity.getVerificationResult(JceSecurity.java:185)
at javax.crypto.Cipher.getInstance(Cipher.java:653)
... 47 more

Does anyone have a solution?
Thank you




 
Last edited:

Gnappo jr

Active Member
Licensed User
Longtime User
Does it work in release mode when you run it from the IDE?
No, not work in release mode from IDE, work fine in debug mode.
I also tried to copy the additional libraries into the lib folder of the JSDK but it does not change anything.
Bug compiler?

add test.zip
 

Attachments

  • test.zip
    33.5 KB · Views: 232
Upvote 0

Gnappo jr

Active Member
Licensed User
Longtime User
Much me, now in IDE release mode works!
But I still have a problem: it does not work out of the IDE. (is the first program I compile with B4J), I probably miss other things.
this is the error message: (further information at the bottom of the message)

C:\Users\hp840>java -jar c:\y\test.jar
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: anywheresoftware/b4a/BA
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: anywheresoftware.b4a.BA
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more
I found that the failure to boot out of IDE is caused by the statement [#MergeLibraries: false]
I attach a test file with graphic inerface
 

Attachments

  • 18.zip
    32.8 KB · Views: 234
Last edited:
Upvote 0

Gnappo jr

Active Member
Licensed User
Longtime User
Please compile your app in release mode and post the compilation window text.


B4J Versione: 5.90
Analisi del Codice. (0.00s)
Compilazione del codice. (0.03s)
Compilazione del codice di layouts (0.01s)
Organizzazione Librerie. (0.00s)
Compilazione del codice Java prodotto. (1.12s)
Creazione del jar.file (0.05s)
File Jar creato: C:\z\_B4J\18\Objects\test2.jar
Le librerie non sono state incluse nel file jar.
Le seguenti librerie dovrebbero essere distribuite nella cartella libs:
jCore.jar jFX.jar Encryption.jar jReflection.jar ByteConverter.jar Json.jar bcprov-jdk15on-154.jar
Applicazione in esecuzione. (0.01s)
Completato con successo.


Maybe I need to create a LIB folder inside the main program folder?
Is there a way to include libraries in the compiled jar file?
Thank you
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Is there a way to include libraries in the compiled jar file?
Yes, set #MergeLibraries to True. However there is something special with one of the libraries that you are using (it is signed) so you cannot merge them.

You need to create a folder named libs and copy all these jars to that folder.

The structure should be:
<your jar here>
libs
- all other jars
 
Upvote 0

Gnappo jr

Active Member
Licensed User
Longtime User
Yes, set #MergeLibraries to True. However there is something special with one of the libraries that you are using (it is signed) so you cannot merge them.

You need to create a folder named libs and copy all these jars to that folder.

The structure should be:
<your jar here>
libs
- all other jars
nuntio vobis gaudium magnum
works well
I did not know the need for a LIBS folder and I did not know the operation of Mergelibrary, I did not know the problem with the signature libraries.
Now it is clear, I hope this is useful to others.
Erel thank you very much ..
 
Upvote 0
Top