Search code examples
javamavenintellij-ideapom.xmlsimulator

Building jcarsdsim with maven on IntelliJ Idea 15.04


So assume that I'm bulding that repository from source. Here is the instructions given by the developer.

Аfter cloning it with built-in ItlliJ VCS tools I've modified default pom.xml a bit in order maven to work.

So, after executing mvn initialize in maven console I got following log:

"C:\Program Files\Java\jdk1.8.0_73\bin\java" "-Dmaven.home=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 15.0.4\plugins\maven\lib\maven3" "-Dclassworlds.conf=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 15.0.4\plugins\maven\lib\maven3\bin\m2.conf" -Didea.launcher.port=7537 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 15.0.4\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 15.0.4\plugins\maven\lib\maven3\boot\plexus-classworlds-2.4.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 15.0.4\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain org.codehaus.classworlds.Launcher -Didea.version=15.0.4 initialize
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Java Card Runime Environment Simulator 3.0.4
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-install-plugin:2.5.2:install-file (default) @ jcardsim ---
[INFO] pom.xml not found in api.jar
[INFO] Installing C:\java_card_kit-2_2_2\lib\api.jar to C:\Users\Foo\.m2\repository\oracle\javacard\api_classic\2.2.2\api_classic-2.2.2.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.527s
[INFO] Finished at: Sun Mar 06 10:19:39 MSK 2016
[INFO] Final Memory: 5M/116M
[INFO] ------------------------------------------------------------------------

Process finished with exit code 0

This is ok, I guess.

But when it comes to execute mvn clean install in order to make the .jar file I've got the following error:

"C:\Program Files\Java\jdk1.8.0_73\bin\java" "-Dmaven.home=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 15.0.4\plugins\maven\lib\maven3" "-Dclassworlds.conf=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 15.0.4\plugins\maven\lib\maven3\bin\m2.conf" -Didea.launcher.port=7538 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 15.0.4\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 15.0.4\plugins\maven\lib\maven3\boot\plexus-classworlds-2.4.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 15.0.4\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain org.codehaus.classworlds.Launcher -Didea.version=15.0.4 clean install
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Java Card Runime Environment Simulator 3.0.4
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ jcardsim ---
[INFO] Deleting C:\Users\Foo\Documents\GitHub\jcardsim\target
[INFO] 
[INFO] --- maven-install-plugin:2.5.2:install-file (default) @ jcardsim ---
[INFO] pom.xml not found in api.jar
[INFO] Installing C:\java_card_kit-2_2_2\lib\api.jar to C:\Users\Foo\.m2\repository\oracle\javacard\api_classic\2.2.2\api_classic-2.2.2.jar
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ jcardsim ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\Foo\Documents\GitHub\jcardsim\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ jcardsim ---
[INFO] Compiling 86 source files to C:\Users\Foo\Documents\GitHub\jcardsim\target\classes
[INFO] 
[INFO] --- maven-dependency-plugin:2.10:unpack (default) @ jcardsim ---
[INFO] Configured Artifact: oracle.javacard:api_classic:2.2.2:jar
[INFO] Unpacking C:\Users\Foo\.m2\repository\oracle\javacard\api_classic\2.2.2\api_classic-2.2.2.jar to C:\Users\Foo\Documents\GitHub\jcardsim\target\classes with includes "**/*.class" and excludes ""
[INFO] 
[INFO] --- exec-maven-plugin:1.4.0:java (default) @ jcardsim ---
[WARNING] 
java.lang.reflect.InvocationTargetException
    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.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:293)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: ClassReader.accept() should be called with EXPAND_FRAMES flag
    at org.objectweb.asm.commons.LocalVariablesSorter.visitFrame(Unknown Source)
    at org.objectweb.asm.commons.RemappingMethodAdapter.visitFrame(Unknown Source)
    at org.objectweb.asm.tree.FrameNode.accept(Unknown Source)
    at org.objectweb.asm.tree.InsnList.accept(Unknown Source)
    at org.objectweb.asm.tree.MethodNode.accept(Unknown Source)
    at org.objectweb.asm.tree.MethodNode.accept(Unknown Source)
    at org.objectweb.asm.tree.ClassNode.accept(Unknown Source)
    at com.licel.jcardsim.utils.JavaCardApiProcessor.proxyClass(JavaCardApiProcessor.java:92)
    at com.licel.jcardsim.utils.JavaCardApiProcessor.main(JavaCardApiProcessor.java:47)
    ... 6 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.245s
[INFO] Finished at: Sun Mar 06 10:21:25 MSK 2016
[INFO] Final Memory: 20M/201M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:java (default) on project jcardsim: An exception occured while executing the Java class. null: InvocationTargetException: ClassReader.accept() should be called with EXPAND_FRAMES flag -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[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

Process finished with exit code 1

Since I am new to the Java world and, especially, the Maven, I wonder what the problem is and how to properly fix it?

I'm running Windows 8.1 with IntelliJ Idea 15.04, Java 1.8 and JCSDK 2.2.2

Update

Here is the diff between original and my pom.xml

Here is the output of mvn -X clean install


Solution

  • If you revert your change from

    <java.version>1.8</java.version>
    

    back to

    <java.version>1.5</java.version>
    

    it will work.

    If you want to generate Java 8 bytecode you need to amend the class JavaCardApiProcessor.java in an appropriate way.