使用 parse4cn1 库在 Codenameone 上保存 ParseUser 或 ParseObject 时出错

Error saving ParseUser or ParseObject on Codenameone using parse4cn1 library

我正在尝试保存 parse4cn1 3.0 ParseUser 或 ParseObject。该对象保存在模拟器上,但是在 Java 脚本端口上我收到错误。注意 ParseFile save() 适用于模拟器和 Java 脚本端口。

public void createTask(String userObjectId, String taskName, String taskDescription, String url) {
    try {
        ParseObject task = ParseObject.create("Task");
        task.put("userId", userObjectId);
        task.put("taskName", taskName);
        task.put("taskDescription", taskDescription);
        task.put("url", url);
        task.save();
    } catch (ParseException e) {
        e.printStackTrace();
    }
}

来自以下云服务器的完整堆栈跟踪:

Executing: /home/ec2-user/jdk1.8.0_45/bin/java -Dretrolambda.inputDir=/tmp/build704717599398049525xxx/tmpClasses -Dretrolambda.classpath=/tmp/build704717599398049525xxx/tmpClasses:/tmp/temp8811672204922110315.jar -Dretrolambda.outputDir=/tmp/build704717599398049525xxx/tmpClasses_retrolamda -Dretrolambda.bytecodeVersion=49 -Dretrolambda.defaultMethods=true -jar /tmp/temp7216874003515660571.jar Retrolambda 2.0.3
Bytecode version: 49 (Java 5)
Default methods:  true
Input directory:  /tmp/build704717599398049525xxx/tmpClasses
Output directory: /tmp/build704717599398049525xxx/tmpClasses_retrolamda
Classpath:        /tmp/build704717599398049525xxx/tmpClasses:/tmp/temp8811672204922110315.jar
Executing: /home/ec2-user/javascript/apache-maven-3.2.5/bin/mvn -e clean package [INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for mobi.mfactory:HelloParse:war:1.0
[WARNING] 'dependencies.dependency.systemPath' for ca.weblite:codename1-core:jar should not point at files within the project directory, ${basedir}/lib/CodenameOne.jar will be unresolvable by dependent projects @ line 24, column 25
[WARNING] 'dependencies.dependency.systemPath' for ca.weblite:codename1-factory:jar should not point at files within the project directory, ${basedir}/lib/Factory.jar will be unresolvable by dependent projects @ line 32, column 25
[WARNING] 'dependencies.dependency.systemPath' for ca.weblite:codename1-core-hello:jar should not point at files within the project directory, ${basedir}/lib/app.jar will be unresolvable by dependent projects @ line 40, column 25
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building HelloParse 1.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ HelloParse ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ HelloParse ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ HelloParse ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 59 source files to /tmp/build704717599398049525xxx/target/classes
[WARNING] /tmp/build704717599398049525xxx/src/main/java/com/codename1/impl/html5/Stub.java: Some input files use or override a deprecated API.
[WARNING] /tmp/build704717599398049525xxx/src/main/java/com/codename1/impl/html5/Stub.java: Recompile with -Xlint:deprecation for details.
[WARNING] /tmp/build704717599398049525xxx/src/main/java/com/codename1/teavm/io/BlobUtil.java: Some input files use unchecked or unsafe operations.
[WARNING] /tmp/build704717599398049525xxx/src/main/java/com/codename1/teavm/io/BlobUtil.java: Recompile with -Xlint:unchecked for details.
[INFO] 
[INFO] --- teavm-maven-plugin:1.0.0-cn1-007:compile (web-client) @ HelloParse ---
[INFO] Preparing classpath for JavaScript generation
[INFO] Using the following classpath for JavaScript generation: /tmp/build704717599398049525xxx/lib/CodenameOne.jar:/tmp/build704717599398049525xxx/lib/Factory.jar:/tmp/build704717599398049525xxx/lib/app.jar:/home/ec2-user/.m2/repository/org/teavm/teavm-classlib/1.0.0-cn1-007/teavm-classlib-1.0.0-cn1-007.jar:/home/ec2-user/.m2/repository/org/teavm/teavm-platform/1.0.0-cn1-007/teavm-platform-1.0.0-cn1-007.jar:/home/ec2-user/.m2/repository/org/teavm/teavm-core/1.0.0-cn1-007/teavm-core-1.0.0-cn1-007.jar:/home/ec2-user/.m2/repository/org/teavm/teavm-interop/1.0.0-cn1-007/teavm-interop-1.0.0-cn1-007.jar:/home/ec2-user/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar:/home/ec2-user/.m2/repository/com/carrotsearch/hppc/0.6.1/hppc-0.6.1.jar:/home/ec2-user/.m2/repository/org/teavm/teavm-jso-apis/1.0.0-cn1-007/teavm-jso-apis-1.0.0-cn1-007.jar:/home/ec2-user/.m2/repository/org/teavm/teavm-jso-impl/1.0.0-cn1-007/teavm-jso-impl-1.0.0-cn1-007.jar:/home/ec2-user/.m2/repository/org/mozilla/rhino/1.7.7/rhino-1.7.7.jar:/home/ec2-user/.m2/repository/org/ow2/asm/asm-debug-all/5.0.4/asm-debug-all-5.0.4.jar:/home/ec2-user/.m2/repository/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar:/home/ec2-user/.m2/repository/com/jcraft/jzlib/1.1.3/jzlib-1.1.3.jar:/home/ec2-user/.m2/repository/joda-time/joda-time/2.7/joda-time-2.7.jar:/home/ec2-user/.m2/repository/org/teavm/teavm-jso/1.0.0-cn1-007/teavm-jso-1.0.0-cn1-007.jar:/home/ec2-user/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar:/home/ec2-user/.m2/repository/org/mitre/dsmiley/httpproxy/smiley-http-proxy-servlet/1.6/smiley-http-proxy-servlet-1.6.jar:/home/ec2-user/.m2/repository/org/apache/httpcomponents/httpclient/4.3.4/httpclient-4.3.4.jar:/home/ec2-user/.m2/repository/org/apache/httpcomponents/httpcore/4.3.2/httpcore-4.3.2.jar:/home/ec2-user/.m2/repository/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3.jar:/home/ec2-user/.m2/repository/commons-codec/commons-codec/1.6/commons-codec-1.6.jar:/tmp/build704717599398049525xxx/target/classes
[INFO] Building JavaScript file
[INFO] Output file built with errors
[ERROR] Method java.lang.Class.getCanonicalName()Ljava/lang/String; was not found
    at com.parse4cn1.encode.ParseEncoder.encode(ParseEncoder.java:173)
    at com.parse4cn1.operation.SetFieldOperation.encode(SetFieldOperation.java:45)
    at com.parse4cn1.ParseObject.getParseData(ParseObject.java:781)
    at com.parse4cn1.ParseObject.performSave(ParseObject.java:812)
    at com.parse4cn1.ParseObject.save(ParseObject.java:682)
    at mobi.mfactory.helloparse.HelloParse.createTask(HelloParse.java:55)
    at mobi.mfactory.helloparse.HelloParse.start(HelloParse.java:242)
    at com.codename1.impl.html5.Stub.run(Stub.java:87)
    at com.codename1.ui.Display.callSerially(Display.java:772)
    at com.codename1.impl.html5.Stub.main(Stub.java:75)
[INFO] Debug information successfully written
[INFO] Source maps successfully written
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 21.183 s
[INFO] Finished at: 2017-01-19T14:40:18+00:00
[INFO] Final Memory: 28M/893M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.teavm:teavm-maven-plugin:1.0.0-cn1-007:compile (web-client) on project HelloParse: Build error -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.teavm:teavm-maven-plugin:1.0.0-cn1-007:compile (web-client) on project HelloParse: Build error
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
    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 org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Build error
    at org.teavm.maven.TeaVMCompileMojo.execute(TeaVMCompileMojo.java:112)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 19 more
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Currently 'stopOnErrors' is on.  With this enabled, even build warnings will cause the build to fail. 
Try adding the 'javascript.stopOnErrors=false' build hint and see if it builds.  
WARNING: switching stopOnErrors off may result in runtime errors, if the warnings actually fall in the execution path of the app. 

JavaScript 端口似乎缺少 getCanonicalName()。我不确定这是我们应该在 JavaScript 端口中修复还是作为拉取请求添加到 parse4cn1。这对于解析 based on this search.

似乎不是必需的

由于该方法一开始就已弃用且不推荐使用,因此我确定可以将其删除。

分叉和更新 parse4cn1 库最终成为更快的临时解决方案。我删除了所有出现的 getCanonicalName(),重建了 cn1lib 和 re-submitted Java 脚本端口构建。

构建成功,save() 方法现在可以使用了。谢谢

parsecn1 cn1lib 需要使用此修复进行更新。