ibinti / bugvm

This is BugVM
352 stars 51 forks source link

PathClassLoader: can't find lib/boot/bugvm-rt.jar #123

Closed jidma closed 7 years ago

jidma commented 7 years ago

After launching with gradle plugin 1.2.3 ./gradlew build launchIPhoneSimulator, I have the following error in my device / simulator log:

Dec 14 13:04:15 MacBook XXX[2321]: 
    PathClassLoader: can't find '/Users/user/Library/Developer/CoreSimulator/Devices/XX-91722E86F13D/data/Containers/Bundle/Application/XX-E8B31D5E4A51/XXXBugVM.app/lib/boot/bugvm-rt.jar'
Dec 14 13:04:15 MacBook XXX[2321]: 
    PathClassLoader: can't find '/Users/user/Library/Developer/CoreSimulator/Devices/XX-91722E86F13D/data/Containers/Bundle/Application/XX-E8B31D5E4A51/XXXBugVM.app/lib/boot/bugvm-cacerts.jar'

Same problem with launchIOSDevice.

Here is the content of my project after the build:

path-to-my-project/XX-BugVM/build/bugvm.tmp/XXBugVM.app/lib$ find .
.
./asm-all-5.0.4.jar
./asm-debug-all-5.0.3.jar
./bcpkix-jdk15on-1.49.jar
./bcprov-jdk15on-1.49.jar
./boot                                                        <---- boot folder empty
./bugvm-apple-1.2.3-SNAPSHOT.jar
./bugvm-cacerts-1.2.3-SNAPSHOT.jar
./bugvm-dist-1.2.3-SNAPSHOT.jar
./bugvm-llvm-1.2.3-SNAPSHOT.jar
./bugvm-rt-1.2.3-SNAPSHOT.jar
./bugvm-soot-1.2.3-SNAPSHOT.jar
./classes26.jar
./commons-cli-1.3.1.jar
./commons-exec-1.3.jar
./commons-io-2.4.jar
./commons-lang3-3.4.jar
./converter-gson-2.0.0-beta1.jar
./dd-plist-1.16.jar
./XX-Core-1.0.0.jar
./gson-2.3.1.jar
./hamcrest-core-1.1.jar
./json-simple-1.1.1.jar
./junit-4.10.jar
./okhttp-2.5.0.jar
./okio-1.6.0.jar
./retrofit-2.0.0-beta1.jar
./simple-xml-2.7.1.jar

My project's build.gradle:

buildscript {
    ext {
        bugVMVersion = "1.2.3-SNAPSHOT"
    }
    repositories {
        mavenLocal()
        mavenCentral()
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
    }
    dependencies {
        classpath "com.bugvm:bugvm-gradle:${bugVMVersion}"
    }
}

apply plugin: 'java'
apply plugin: 'bugvm'

repositories {
    mavenLocal()
    mavenCentral()
    maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}

dependencies {

    compile "com.bugvm:bugvm-dist:${bugVMVersion}"
    compile "my.project:XX-Core:1.0.0"

}

task wrapper(type: Wrapper) {
    gradleVersion = '3.2'
}

Any idea how to get the compiler to put the rt and cacert libraries in lib/boot, or why is it looking for them there in the first place?

Thank you

PS1: the application starts correctly, and the cacert files are needed only when it tries to connect to the internet for the first time com.squareup.okhttp.OkHttpClient.getDefaultSSLSocketFactory.

PS2: the same code used to work fine in previous bugvm versions (1.1.4) and in previous iOS version (9).

jidma commented 7 years ago

I tried adding this to bugvm.xml:

 <skipRuntimeLib>false</skipRuntimeLib>
 <cacerts>full</cacerts>

but it didn't help.

jidma commented 7 years ago

I also tried setting BUGVM_HOME with no better luck:

$ echo $BUGVM_HOME 
/Users/me/.m2/repository/com/bugvm/bugvm-dist/1.2.3-SNAPSHOT/unpacked/bugvm-1.2.3-SNAPSHOT/
$ find $BUGVM_HOME
/Users/user/.m2/repository/com/bugvm/bugvm-dist/1.2.3-SNAPSHOT/unpacked/bugvm-1.2.3-SNAPSHOT/
/Users/user/.m2/repository/com/bugvm/bugvm-dist/1.2.3-SNAPSHOT/unpacked/bugvm-1.2.3-SNAPSHOT//bin
/Users/user/.m2/repository/com/bugvm/bugvm-dist/1.2.3-SNAPSHOT/unpacked/bugvm-1.2.3-SNAPSHOT//bin/bugvm
/Users/user/.m2/repository/com/bugvm/bugvm-dist/1.2.3-SNAPSHOT/unpacked/bugvm-1.2.3-SNAPSHOT//bin/bugvm-device
/Users/user/.m2/repository/com/bugvm/bugvm-dist/1.2.3-SNAPSHOT/unpacked/bugvm-1.2.3-SNAPSHOT//bin/bugvm-sim
/Users/user/.m2/repository/com/bugvm/bugvm-dist/1.2.3-SNAPSHOT/unpacked/bugvm-1.2.3-SNAPSHOT//lib
/Users/user/.m2/repository/com/bugvm/bugvm-dist/1.2.3-SNAPSHOT/unpacked/bugvm-1.2.3-SNAPSHOT//lib/bugvm-apple.jar
/Users/user/.m2/repository/com/bugvm/bugvm-dist/1.2.3-SNAPSHOT/unpacked/bugvm-1.2.3-SNAPSHOT//lib/bugvm-cacerts.jar
/Users/user/.m2/repository/com/bugvm/bugvm-dist/1.2.3-SNAPSHOT/unpacked/bugvm-1.2.3-SNAPSHOT//lib/bugvm-compiler.jar
/Users/user/.m2/repository/com/bugvm/bugvm-dist/1.2.3-SNAPSHOT/unpacked/bugvm-1.2.3-SNAPSHOT//lib/bugvm-rt.jar
/Users/user/.m2/repository/com/bugvm/bugvm-dist/1.2.3-SNAPSHOT/unpacked/bugvm-1.2.3-SNAPSHOT//lib/vm
/Users/user/.m2/repository/com/bugvm/bugvm-dist/1.2.3-SNAPSHOT/unpacked/bugvm-1.2.3-SNAPSHOT//lib/vm/ios
..etc..
ibinti commented 7 years ago

There are at least two possible issues I see.

  1. SNAPSHOT was not published correctly to maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }: solution for this -> I did publish 1.2.3-SNAPSHOT again, It should be ok now. Also you could build and publish locally to your /Users/user/.m2/repository with ./gradlew install or ./gradlew publishToMavenLocal

  2. For project dependencies, you will need

    dependencies {
    compile "com.bugvm:bugvm-apple:${bugVMVersion}"
    compile "com.bugvm:bugvm-rt:${bugVMVersion}"
    compile "my.project:XX-Core:1.0.0"
    }

    bugvm-dist should not be used as dependencies, it will be used internally by bugvm-gradle plugin.

jidma commented 7 years ago

Thanks for the reply.

I cleaned my local repository from all bugvm files with version 1.2.3-SNAPSHOT.

I cleared the previously set environnement variable.

I fixed the dependencies in the build.gradle.

I launched:

./gradlew clean build launchIPhoneSimulator -d -s

and got this error this time:

Caused by: java.io.IOException: Cannot run program "/Users/user/.m2/repository/com/bugvm/bugvm-dist/1.2.3-SNAPSHOT/unpacked/bugvm-1.2.3-SNAPSHOT/bin/bugvm-sim" (in directory "."): error=2, No such file or directory

here are the contents of my repository at this location:

/Users/user/.m2/repository/com/bugvm/bugvm-dist/1.2.3-SNAPSHOT/unpacked/bugvm-1.2.3-SNAPSHOT/bin$ ls -ltr
total 184
-rwxr-xr-x  1 user  staff    380 Nov 18 22:08 bugvm
-rwxr-xr-x  1 user  staff  14160 Dec 13 10:17 idevicesyslog
-rwxr-xr-x  1 user  staff  38380 Dec 13 10:17 ideviceinstaller
-rwxr-xr-x  1 user  staff  19796 Dec 13 10:17 idevicedebug
-rwxr-xr-x  1 user  staff   9316 Dec 13 18:27 idevice_id

am I missing something else?

Thank you again.

jidma commented 7 years ago

I reverted back to 1.2.2-SNAPSHOT and went back to square one: bugvm-sim is found this time but I have the bugvm-rt.jar missing from the boot/lib directory.

ibinti commented 7 years ago

Previous 1.2.*.SNAPSHOT in maven repo seem to be broken due to my incorrect publishing.

Let's focus on 1.2.3-SNAPSHOT.

Caused by: java.io.IOException: Cannot run program "/Users/user/.m2/repository/com/bugvm/bugvm-dist/1.2.3-SNAPSHOT/unpacked/bugvm-1.2.3-SNAPSHOT/bin/bugvm-sim" (in directory "."): error=2, No such file or directory

Indeed, bugvm-sim has been removed in 1.2.3-SNAPSHOT as its functions are merged into bugvm-compiler.jar. As a result, 1.2.3-SNAPSHOT should not have any references to bugvm-sim. I am wondering how you get the error message in the first place.

jidma commented 7 years ago

here's the whole console output if that could help

logs.txt

I cleaned my maven repository before hand. The files has been re-downloaded.

jidma commented 7 years ago

Nevermind, I just retried using launchIOSDevice and back to launchIPhoneSimulator task and it compiled fine. It must have something to do with gradle cache or something.

But i still have the same error:

 PathClassLoader: can't find '/private/var/containers/Bundle/Application/3FFBECB9-E614-4222-9B23-DB6017ABF227/MyApp.app/lib/boot/bugvm-rt.jar'
 PathClassLoader: can't find '/private/var/containers/Bundle/Application/3FFBECB9-E614-4222-9B23-DB6017ABF227/MyApp.app/lib/boot/bugvm-cacerts.jar'

just before a retrofit.OkHttpCall :

STACK : com.squareup.okhttp.OkHttpClient.getDefaultSSLSocketFactory @ -1
STACK : com.squareup.okhttp.OkHttpClient.copyWithDefaults @ -1
STACK : com.squareup.okhttp.Call.<init> @ -1
STACK : com.squareup.okhttp.OkHttpClient.newCall @ -1
STACK : retrofit.OkHttpCall.createRawCall @ -1
STACK : retrofit.OkHttpCall.enqueue @ -1
ibinti commented 7 years ago

IDEA plugin 1.1.19-SNAPSHOT do generate lib/boot/bugvm-rt.jar. Can you please confirm it work?

Download and install idea plugin to either BugVM Studio 1.1.10-SNAPSHOT or Android Studio 2.2.3.

https://github.com/bugvm/bugvm/releases/download/bugvm-1.1.19-SNAPSHOT/bugvm-idea-1.1.19-SNAPSHOT-plugin-dist.jar

Set BugVM Version in your build.gradle

bugVMVersion = "1.1.19-SNAPSHOT"

Compile and launch using IDE.

IDEA plugin outputs to build-bugvm

jidma commented 7 years ago

tl;dr; It worked using IDEA plugin 1.1.19-SNAPSHOT and BugVM Studio 1.1.10-SNAPSHOT:

I wrote the bellow text as I was proceeding step by step, didn't know whether it would work or not while typing

re-Installation process:

To avoid having any cache problem, I deleted the following:

Fresh Install

Test Template Project

/SampleBugVMApp/build-bugvm$ find . -name *.jar ./tmp/sim-iphone6/ios/x86_64/Main.app/lib/boot/bugvm-rt.jar ./tmp/sim-iphone6/ios/x86_64/Main.app/lib/bugvm-apple.jar ./tmp/sim-iphone6/ios/x86_64/Main.app/lib/bugvm-cacerts.jar ./tmp/sim-iphone6/ios/x86_64/Main.app/lib/bugvm-compiler.jar ./tmp/sim-iphone6/ios/x86_64/Main.app/lib/classes0.jar

Test of my project:

ibinti commented 7 years ago

Cool. Please use IDEA plugin 1.1.19-SNAPSHOT for a while. I will come back later when I have more time and continue to investigate gradle plugin further.

jidma commented 7 years ago

Thank you.

Please let me know if you need a minimal working project on 1.1.19 that doesn't work on 1.2.3.

ibinti commented 7 years ago

That's very nice of you. I appreciate it.

jidma commented 7 years ago

Here's a minimal project :

SampleBugVMApp.tar.gz

using idea plugin 1.1.19:

Everything is fine. Device log:

Dec 16 21:08:55 MacBook-Pro-de-Majid Main[46440]: before service
Dec 16 21:08:55 MacBook-Pro-de-Majid Main[46440]: -->getClient
Dec 16 21:08:55 MacBook-Pro-de-Majid Main[46440]: Loading class 'java.util.logging.ConsoleHandler' failed
Dec 16 21:08:55 MacBook-Pro-de-Majid Main[46440]: java.lang.ClassNotFoundException: java.util.logging.ConsoleHandler
Dec 16 21:08:55 MacBook-Pro-de-Majid Main[46440]: builder
Dec 16 21:08:55 MacBook-Pro-de-Majid Main[46440]: gson
Dec 16 21:08:55 MacBook-Pro-de-Majid Main[46440]: client
Dec 16 21:08:55 MacBook-Pro-de-Majid Main[46440]: <--getClient
Dec 16 21:08:55 MacBook-Pro-de-Majid Main[46440]: after service
Dec 16 21:08:55 MacBook-Pro-de-Majid Main[46440]: after call
Dec 16 21:08:56 MacBook-Pro-de-Majid Main[46440]: on response retrofit.Response@17df5900

using gradle plugin 1.2.3:

./gradlew clean build launchIPhoneSimulator -d -s

After clicking on the "click me" button, it gives the following log:

Dec 16 22:25:40 MacBook-Pro-de-Majid Main[46645]: before service
Dec 16 22:25:40 MacBook-Pro-de-Majid Main[46645]: -->getClient
Dec 16 22:25:40 MacBook-Pro-de-Majid Main[46645]: PathClassLoader: can't find '/Users/majidlaissi/Library/Developer/CoreSimulator/Devices/9B17EF2E-B57E-4745-988F-91722E86F13D/data/Containers/Bundle/Application/25F8BF3F-9776-49E8-B2FD-6E0D85E2413E/Main.app/lib/boot/bugvm-rt.jar'
Dec 16 22:25:40 MacBook-Pro-de-Majid Main[46645]: PathClassLoader: can't find '/Users/majidlaissi/Library/Developer/CoreSimulator/Devices/9B17EF2E-B57E-4745-988F-91722E86F13D/data/Containers/Bundle/Application/25F8BF3F-9776-49E8-B2FD-6E0D85E2413E/Main.app/lib/boot/bugvm-cacerts.jar'
Dec 16 22:25:40 MacBook-Pro-de-Majid Main[46645]: builder
Dec 16 22:25:40 MacBook-Pro-de-Majid Main[46645]: gson
Dec 16 22:25:40 MacBook-Pro-de-Majid Main[46645]: client
Dec 16 22:25:40 MacBook-Pro-de-Majid Main[46645]: <--getClient
Dec 16 22:25:40 MacBook-Pro-de-Majid Main[46645]: after service
Dec 16 22:25:40 MacBook-Pro-de-Majid Main[46645]: after call
Dec 16 22:25:40 MacBook-Pro-de-Majid Main[46645]: java.io.FileNotFoundException: /Users/majidlaissi/Library/Developer/CoreSimulator/Devices/9B17EF2E-B57E-4745-988F-91722E86F13D/data/Containers/Bundle/Application/25F8BF3F-9776-49E8-B2FD-6E0D85E2413E/Main.app/lib/logging.properties: open failed: ENOENT (No such file or directory)   
at libcore.io.IoBridge.open(IoBridge.java)  
at java.io.FileInputStream.<init>(FileInputStream.java) 
at java.io.FileInputStream.<init>(FileInputStream.java) 
at java.util.logging.LogManager.readConfiguration(LogManager.java)  
at java.util.logging.LogManager.<clinit>(LogManager.java)   
at java.util.logging.Logger.getLogger(Logger.java)  
at com.squareup.okhttp.internal.Internal.<clinit>(Internal.java)    
at com.squareup.okhttp.OkHttpClient.<clinit>(OkHttpClient.java) 
at com.mycompany.myapp.MyViewController.getClient(MyViewController.java)    
at com.mycompany.myapp.MyViewController.access$200(MyViewController.java)   
at com.mycompany.myapp.MyViewController$1.onTouchUpInside(MyViewController.java)    
at com.bugvm.apple.uikit.UIControl$ListenerWrapper.handleTouchEvent(UIControl.java) 
at com.bugvm.apple.uikit.UIControl$ListenerWrapper.$cb$handleTouchEvent(UIControl.java) 
at com.bugvm.apple.uikit.UIApplication.main(Native Method)  
at com.bugvm.apple.uikit.UIApplication.main(UIApplication.java) 
at com.mycompany.myapp.Main.main(Main.java)Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)    at libcore.io.Posix.open(Native Method) 
at libcore.io.BlockGuardOs.open(BlockGuardOs.java)  
... 16 more
PathClassLoader: can't find '/Users/majidlaissi/Library/Developer/CoreSimulator/Devices/9B17EF2E-B57E-4745-988F-91722E86F13D/data/Containers/Bundle/Application/25F8BF3F-9776-49E8-B2FD-6E0D85E2413E/Main.app/lib/boot/bugvm-rt.jar'
Dec 16 22:25:40 MacBook-Pro-de-Majid Main[46645]: PathClassLoader: can't find '/Users/majidlaissi/Library/Developer/CoreSimulator/Devices/9B17EF2E-B57E-4745-988F-91722E86F13D/data/Containers/Bundle/Application/25F8BF3F-9776-49E8-B2FD-6E0D85E2413E/Main.app/lib/boot/bugvm-cacerts.jar'
Dec 16 22:25:40 MacBook-Pro-de-Majid Main[46645]: on failure java.lang.AssertionError
ibinti commented 7 years ago

reproduced the issues.

ibinti commented 7 years ago

now the issue has been resolved with 1.2.3-SNAPSHOT.