Pendrush Well-Known Member Licensed User Longtime User Dec 22, 2024 #1 #MergeLibraries: False = I can run app in Release mode #MergeLibraries: True = App crash in Release mode Stacktrace: java.lang.RuntimeException: java.lang.StringIndexOutOfBoundsException: Range [0, -1) out of bounds for length 7 at anywheresoftware.b4a.keywords.Common$2$1.run(Common.java:1052) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457) at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456) at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96) at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184) at java.base/java.lang.Thread.run(Thread.java:1589) Caused by: java.lang.StringIndexOutOfBoundsException: Range [0, -1) out of bounds for length 7 at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:55) at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:52) at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:213) at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:210) at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98) at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckFromToIndex(Preconditions.java:112) at java.base/jdk.internal.util.Preconditions.checkFromToIndex(Preconditions.java:349) at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4602) at java.base/java.lang.String.substring(String.java:2715) at org.openqa.selenium.manager.SeleniumManager.<init>(SeleniumManager.java:81) at org.openqa.selenium.manager.SeleniumManager.getInstance(SeleniumManager.java:107) at org.openqa.selenium.remote.service.DriverFinder.<init>(DriverFinder.java:45) at org.openqa.selenium.chrome.ChromeDriver.generateExecutor(ChromeDriver.java:98) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:88) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:83) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:72) at com.pendrush.selenium.kotlin.SeleniumLib.initialize(SeleniumLib.kt:42) at com.pendrush.selenium.Wrapper.initialize2(Wrapper.java:80) at com.pendrush.selenium.Wrapper.Initialize(Wrapper.java:76) at b4j.example.main$ResumableSub_AppStart.resume(main.java:92) at anywheresoftware.b4a.keywords.Common$2$1.run(Common.java:1050) ... 7 more Click to expand... Line 42 in wrapper lib: Java: Copy private val options = ChromeOptions() // <- global declaration driver = ChromeDriver(options) // <- error line 42 from stacktrace: at com.pendrush.selenium.kotlin.SeleniumLib.initialize(SeleniumLib.kt:42) The error is completely unrelated... I cannot get it. This behavior also create unusable app with standalone package. Library: Selenium Library - Pnd_Selenium Selenium automates browsers. That's it! What you do with that power is entirely up to you. Primarily it is for automating web applications for testing purposes, but is certainly not limited to just that. Boring web-based administration tasks can (and should) also be automated as well. Library... www.b4x.com I need to build standalone package, any solution?
#MergeLibraries: False = I can run app in Release mode #MergeLibraries: True = App crash in Release mode Stacktrace: java.lang.RuntimeException: java.lang.StringIndexOutOfBoundsException: Range [0, -1) out of bounds for length 7 at anywheresoftware.b4a.keywords.Common$2$1.run(Common.java:1052) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457) at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456) at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96) at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184) at java.base/java.lang.Thread.run(Thread.java:1589) Caused by: java.lang.StringIndexOutOfBoundsException: Range [0, -1) out of bounds for length 7 at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:55) at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:52) at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:213) at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:210) at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98) at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckFromToIndex(Preconditions.java:112) at java.base/jdk.internal.util.Preconditions.checkFromToIndex(Preconditions.java:349) at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4602) at java.base/java.lang.String.substring(String.java:2715) at org.openqa.selenium.manager.SeleniumManager.<init>(SeleniumManager.java:81) at org.openqa.selenium.manager.SeleniumManager.getInstance(SeleniumManager.java:107) at org.openqa.selenium.remote.service.DriverFinder.<init>(DriverFinder.java:45) at org.openqa.selenium.chrome.ChromeDriver.generateExecutor(ChromeDriver.java:98) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:88) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:83) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:72) at com.pendrush.selenium.kotlin.SeleniumLib.initialize(SeleniumLib.kt:42) at com.pendrush.selenium.Wrapper.initialize2(Wrapper.java:80) at com.pendrush.selenium.Wrapper.Initialize(Wrapper.java:76) at b4j.example.main$ResumableSub_AppStart.resume(main.java:92) at anywheresoftware.b4a.keywords.Common$2$1.run(Common.java:1050) ... 7 more Click to expand... Line 42 in wrapper lib: Java: Copy private val options = ChromeOptions() // <- global declaration driver = ChromeDriver(options) // <- error line 42 from stacktrace: at com.pendrush.selenium.kotlin.SeleniumLib.initialize(SeleniumLib.kt:42) The error is completely unrelated... I cannot get it. This behavior also create unusable app with standalone package. Library: Selenium Library - Pnd_Selenium Selenium automates browsers. That's it! What you do with that power is entirely up to you. Primarily it is for automating web applications for testing purposes, but is certainly not limited to just that. Boring web-based administration tasks can (and should) also be automated as well. Library... www.b4x.com I need to build standalone package, any solution?
Solution Erel Dec 26, 2024 Example of adding a file to a merged jar during "build standalone package": Code: Copy #CustomBuildAction: before packager, %JAVABIN%\jar.exe, uf BCTextInCLV.jar -C C:\Users\H\Downloads Files\1.txt The file is located in C:\Users\H\Downloads\Files\1.txt and it will be included in the jar under Files\1.txt. BCTextInCLV.jar is the name of this app. My test worked. I was able to read the file. I'm not 100% sure that it will work with the META-INF file, after it is packed.
Example of adding a file to a merged jar during "build standalone package": Code: Copy #CustomBuildAction: before packager, %JAVABIN%\jar.exe, uf BCTextInCLV.jar -C C:\Users\H\Downloads Files\1.txt The file is located in C:\Users\H\Downloads\Files\1.txt and it will be included in the jar under Files\1.txt. BCTextInCLV.jar is the name of this app. My test worked. I was able to read the file. I'm not 100% sure that it will work with the META-INF file, after it is packed.
Erel B4X founder Staff member Licensed User Longtime User Dec 23, 2024 #2 Possible reasons for such issues: 1. The jar is signed and merging the jars breaks the signature. 2. There are multiple files with the same name. This one is not too difficult to solve once you find it. Check the files inside the jars, under META-INF. Upvote 0
Possible reasons for such issues: 1. The jar is signed and merging the jars breaks the signature. 2. There are multiple files with the same name. This one is not too difficult to solve once you find it. Check the files inside the jars, under META-INF.
Pendrush Well-Known Member Licensed User Longtime User Dec 23, 2024 #3 After some research, I found that some files from my library were not copied into the JAR file that was compiled in release mode with flag #MergeLibraries: True. If I copy ALL the files from my kotlin-selenium-all.jar library, WITHOUT overwriting, into the compiled JAR everything works fine. You can also see the difference in the size of the files, it is obvious that something is also missing in the Release JAR: My Library: B4X: Copy Pnd_Selenium.xml 70,210 Pnd_Selenium.jar 6,457 kotlin-selenium-all.jar 30,139,004 Release JAR (#MergeLibraries: True): B4X: Copy Selenium7.jar 26,156,717 Any solution? Last edited: Dec 23, 2024 Upvote 0
After some research, I found that some files from my library were not copied into the JAR file that was compiled in release mode with flag #MergeLibraries: True. If I copy ALL the files from my kotlin-selenium-all.jar library, WITHOUT overwriting, into the compiled JAR everything works fine. You can also see the difference in the size of the files, it is obvious that something is also missing in the Release JAR: My Library: B4X: Copy Pnd_Selenium.xml 70,210 Pnd_Selenium.jar 6,457 kotlin-selenium-all.jar 30,139,004 Release JAR (#MergeLibraries: True): B4X: Copy Selenium7.jar 26,156,717 Any solution?
Erel B4X founder Staff member Licensed User Longtime User Dec 24, 2024 #4 Which files weren't copied? Upvote 0
Pendrush Well-Known Member Licensed User Longtime User Dec 24, 2024 #5 2940 Files are missing in Release Jar. PDF with folders and file names is attached to this post. Attachments 2940MissingFilesInReleaseJar.zip 2940MissingFilesInReleaseJar.zip 454 KB · Views: 600 Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Dec 25, 2024 #6 With the exception of services and native, META-INF subfolders are not copied. Simply copying many of the folders there will not work for various reasons. You can make a test and manually copy the folders to the merged jar. Upvote 0
With the exception of services and native, META-INF subfolders are not copied. Simply copying many of the folders there will not work for various reasons. You can make a test and manually copy the folders to the merged jar.
Pendrush Well-Known Member Licensed User Longtime User Dec 25, 2024 #7 Simple copy missing files from META-INF subfolder make app to work as it should. EDIT: Only one file make app to work on path: META-INF\selenium-build.properties Is there any chance to make app in release mode and somehow to instruct B4J to include this file? Last edited: Dec 25, 2024 Upvote 0
Simple copy missing files from META-INF subfolder make app to work as it should. EDIT: Only one file make app to work on path: META-INF\selenium-build.properties Is there any chance to make app in release mode and somehow to instruct B4J to include this file?
Pendrush Well-Known Member Licensed User Longtime User Dec 25, 2024 #8 File is used inside library: selenium/java/src/org/openqa/selenium/BuildInfo.java at trunk · SeleniumHQ/selenium A browser automation framework and ecosystem. Contribute to SeleniumHQ/selenium development by creating an account on GitHub. github.com also here: selenium/java/src/org/openqa/selenium/manager/SeleniumManager.java at 359ac9a9191646ce49ff5381e81baef4e2b23634 · SeleniumHQ/selenium A browser automation framework and ecosystem. Contribute to SeleniumHQ/selenium development by creating an account on GitHub. github.com Last edited: Dec 25, 2024 Upvote 0
File is used inside library: selenium/java/src/org/openqa/selenium/BuildInfo.java at trunk · SeleniumHQ/selenium A browser automation framework and ecosystem. Contribute to SeleniumHQ/selenium development by creating an account on GitHub. github.com also here: selenium/java/src/org/openqa/selenium/manager/SeleniumManager.java at 359ac9a9191646ce49ff5381e81baef4e2b23634 · SeleniumHQ/selenium A browser automation framework and ecosystem. Contribute to SeleniumHQ/selenium development by creating an account on GitHub. github.com
Erel B4X founder Staff member Licensed User Longtime User Dec 26, 2024 #9 Example of adding a file to a merged jar during "build standalone package": Code: Copy #CustomBuildAction: before packager, %JAVABIN%\jar.exe, uf BCTextInCLV.jar -C C:\Users\H\Downloads Files\1.txt The file is located in C:\Users\H\Downloads\Files\1.txt and it will be included in the jar under Files\1.txt. BCTextInCLV.jar is the name of this app. My test worked. I was able to read the file. I'm not 100% sure that it will work with the META-INF file, after it is packed. Upvote 0 Solution
Example of adding a file to a merged jar during "build standalone package": Code: Copy #CustomBuildAction: before packager, %JAVABIN%\jar.exe, uf BCTextInCLV.jar -C C:\Users\H\Downloads Files\1.txt The file is located in C:\Users\H\Downloads\Files\1.txt and it will be included in the jar under Files\1.txt. BCTextInCLV.jar is the name of this app. My test worked. I was able to read the file. I'm not 100% sure that it will work with the META-INF file, after it is packed.
Pendrush Well-Known Member Licensed User Longtime User Dec 27, 2024 #10 \META-INF\selenium-build.properties - folder and file inside project Files folder Solution for: build standalone package B4X: Copy #CustomBuildAction: before packager, %JAVABIN%\jar.exe, uf Selenium16.jar -C e:\B4J\_WRAP\Selenium\Selenium16\Files META-INF\selenium-build.properties Solution for: compile app in release mode with #MergeLibraries: True B4X: Copy #CustomBuildAction: 2, %JAVABIN%\jar.exe, uf Selenium15.jar -C e:\B4J\_WRAP\Selenium\Selenium15\Files META-INF\selenium-build.properties Last edited: Dec 27, 2024 Upvote 0
\META-INF\selenium-build.properties - folder and file inside project Files folder Solution for: build standalone package B4X: Copy #CustomBuildAction: before packager, %JAVABIN%\jar.exe, uf Selenium16.jar -C e:\B4J\_WRAP\Selenium\Selenium16\Files META-INF\selenium-build.properties Solution for: compile app in release mode with #MergeLibraries: True B4X: Copy #CustomBuildAction: 2, %JAVABIN%\jar.exe, uf Selenium15.jar -C e:\B4J\_WRAP\Selenium\Selenium15\Files META-INF\selenium-build.properties