Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ant-javacard.jar, build fails with NullPointerException #90

Closed
pmaier-sysmo opened this issue Aug 29, 2023 · 3 comments
Closed

ant-javacard.jar, build fails with NullPointerException #90

pmaier-sysmo opened this issue Aug 29, 2023 · 3 comments

Comments

@pmaier-sysmo
Copy link

Hello Mr. Paljak,

I stumbled upon a problem that seems to be located in ant-javacard.jar. Unfortunately I am not an expert in Java/ANT, but I hope you find the following helpful anyway.

For testing I am using the HelloSTK2 from Merlin Chlosta
git clone https://github.com/mrlnc/HelloSTK2.git

When I leave everything unchanged (except running "git submodule update --init --recursive" beforehand to get the javacard SDKs) and use the latest ant-javacard.jar ANT task (see also build.xml), I get the following:

$ ant
Buildfile: /home/owner/HelloSTK2/build.xml

dist:
      [get] Getting: https://github.com/martinpaljak/ant-javacard/releases/latest/download/ant-javacard.jar
      [get] To: /home/owner/HelloSTK2/ant-javacard.jar
      [get] https://github.com/martinpaljak/ant-javacard/releases/latest/download/ant-javacard.jar moved to https://github.com/martinpaljak/ant-javacard/releases/download/v23.08.07/ant-javacard.jar
      [get] https://github.com/martinpaljak/ant-javacard/releases/download/v23.08.07/ant-javacard.jar moved to https://objects.githubusercontent.com/github-production-release-asset-2e65be/28853876/cf98fb4e-341f-4a96-a4fb-56246e22817a?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230825%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230825T153506Z&X-Amz-Expires=300&X-Amz-Signature=25085afbcd6e3189cb3308202a904a700f5895078197919bb55517cabb50328a&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=28853876&response-content-disposition=attachment%3B%20filename%3Dant-javacard.jar&response-content-type=application%2Foctet-stream

BUILD FAILED
/home/owner/HelloSTK2/build.xml:9: java.lang.NullPointerException
	at pro.javacard.ant.JavaCard$JCCap.setTargetsdk(JavaCard.java:303)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.apache.tools.ant.IntrospectionHelper$AttributeSetter.setObject(IntrospectionHelper.java:1488)
	at org.apache.tools.ant.IntrospectionHelper.setAttribute(IntrospectionHelper.java:406)
	at org.apache.tools.ant.RuntimeConfigurable.maybeConfigure(RuntimeConfigurable.java:527)
	at org.apache.tools.ant.RuntimeConfigurable.maybeConfigure(RuntimeConfigurable.java:463)
	at org.apache.tools.ant.UnknownElement.handleChild(UnknownElement.java:588)
	at org.apache.tools.ant.UnknownElement.handleChildren(UnknownElement.java:357)
	at org.apache.tools.ant.UnknownElement.configure(UnknownElement.java:206)
	at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:165)
	at org.apache.tools.ant.Task.perform(Task.java:349)
	at org.apache.tools.ant.Target.execute(Target.java:449)
	at org.apache.tools.ant.Target.performTasks(Target.java:470)
	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1388)
	at org.apache.tools.ant.Project.executeTarget(Project.java:1361)
	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
	at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
	at org.apache.tools.ant.Main.runBuild(Main.java:834)
	at org.apache.tools.ant.Main.startAnt(Main.java:223)
	at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284)
	at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)

Total time: 1 second

when I use the ant-javacard.jar v21.12.31 [1], then everything is built without problems.

$ ant
Buildfile: /home/owner/HelloSTK2/build.xml

dist:
      [get] Destination already exists (skipping): /home/owner/HelloSTK2/ant-javacard.jar
      [cap] INFO: using JavaCard 3.0.5 SDK in /home/owner/HelloSTK2/oracle_javacard_sdks/jc305u3_kit
      [cap] INFO: targeting JavaCard 2.2.1 SDK in /home/owner/HelloSTK2/oracle_javacard_sdks/jc221_kit
      [cap] INFO: Setting package name to com.github.mrlnc.HelloSTK2
      [cap] Building CAP with 1 applet from package com.github.mrlnc.HelloSTK2 (AID: D07002CA44)
      [cap] com.github.mrlnc.HelloSTK2.HelloSTK2 D07002CA44900101
  [compile] Compiling files from /home/owner/HelloSTK2/src
  [compile] Compiling 1 source file to /home/owner/HelloSTK2/bin
  [compile] /home/owner/HelloSTK2/src/com/github/mrlnc/hellostk2/HelloSTK2.java
  [convert] [ INFO: ] Converter [v3.0.5]
  [convert] [ INFO: ]     Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
  [convert]     
  [convert]     
  [convert] [ INFO: ] conversion completed with 0 errors and 0 warnings.
   [verify] Verification passed
      [cap] CAP saved to /home/owner/HelloSTK2/bin/HelloSTK2.cap

BUILD SUCCESSFUL
Total time: 2 seconds

[1] https://github.com/martinpaljak/ant-javacard/releases/download/v21.12.31/ant-javacard.jar

Best regards.
Philipp Maier

@martinpaljak
Copy link
Owner

martinpaljak commented Aug 29, 2023

Thanks for noticing! This hits a "XXX" part of the code. Quick workarounds:

  • define JC_HOME with path to the JC kit to use (3.0.5u3 in this case)
  • move jckit to javacard tag
  • move jckit in cap tag before targetsdk attribute

Will fix soon

@martinpaljak
Copy link
Owner

martinpaljak commented Aug 29, 2023

This is fixed by v23.08.29, marked as latest release. Please delete the already downloaded ant-javacard.jar and all should work.

@pmaier-sysmo
Copy link
Author

Hello Mr. Paljak,

Thank you very much for fixing the problem. Now everything works fine here too.

best regards.
Philipp Maier

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants