This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 194124 - Debugging an Applet in the NetBeans IDE resets the card service
Summary: Debugging an Applet in the NetBeans IDE resets the card service
Status: NEW
Alias: None
Product: javacard
Classification: Unclassified
Component: Java Card (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P3 normal (vote)
Assignee: onkentes
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-07 13:58 UTC by Benjamin_Gittins
Modified: 2012-08-01 08:41 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin_Gittins 2011-01-07 13:58:32 UTC
Hi, 

I am attempting to debug a shared interface application.
I have two java card 3 extended applets A and B and in package PA and package PB respectively.
They compile both compile.
I can install both of them onto a card.

Now, what i want to do is debug applet B in package PB which calls applet A.

Note, that there are TWO applets. I cannot convert package PA into a library, because the IDE provides no way to start the applet A in package PA which i need to access via SIO. I also cannot create a dependency in the project of PB because PA is NOT a library.

So i start up the default device under bundle java card 3.0.2 runtime.
I load and create an instance of the Package A, all good.  I can see it's AID in the IDE.

I now set package PB as my main package, and start the debugger.
** The first thing the debugger does is shut down the smart card. **
It then installs package PB and runs the Applet B.
Of course at this point, there is no Package PA or applet A installed.

There seems to be no way for me to configure the debugger to install Package PB first. 
Furthermore, there seems to be no good reason to reset the smart card back-end just to start the debugger. 

I can't test this on versions higher than 6.8 because of the bug with selecting an applet in the project configuration window in the NetBeans IDE 6.9.1  and 7.0.0 beta.

You would have to write your application so that PB can be installed first, then install PA, then call applet B in PB to make the SIO call to Applet A. This is forcing the programmer to do something they should have to do, but for the limitations in the IDE.
Comment 1 _ tboudreau 2011-01-07 18:50:17 UTC
Adding Anki from the Java Card team to CC.

@Benjamin:  I recall this issue generally:  If the emulator is running, but it is not in debug mode, then there are no ports open for the debugger to attach to.  So the IDE has to restart the emulator in debug mode to debug anything.

However, if the emulator is already running in debug mode (you can start it that way on the Services tab), then trying to debug PB *should* not cause the emulator to be restarted (I have no recollection of whether that really means it *won't* be, but I remember writing the calls to check if the emulator is already running in debug mode, so the IDE is certainly capable of detecting that state and not trying to restart it).

As a workaround, you may be able to 
 - Start the emulator in debug mode (if necessary, hack $JC_SDK/platform.properties which defines the command line - I wrote pretty extensive docs for how this all works here - http://wiki.netbeans.org/JavaCardPlatformIntegration )
 - Attach the NetBeans debugger to the running process
 - Send whatever query you want to trigger a breakpoint using the emulator console
Comment 2 Benjamin_Gittins 2011-01-16 13:58:15 UTC
(In reply to comment #1)
> Adding Anki from the Java Card team to CC.
> 
> @Benjamin:  I recall this issue generally:  If the emulator is running, but it
> is not in debug mode, then there are no ports open for the debugger to attach
> to.  So the IDE has to restart the emulator in debug mode to debug anything.
> 
> However, if the emulator is already running in debug mode (you can start it
> that way on the Services tab), then trying to debug PB *should* not cause the
> emulator to be restarted (I have no recollection of whether that really means
> it *won't* be, but I remember writing the calls to check if the emulator is
> already running in debug mode, so the IDE is certainly capable of detecting
> that state and not trying to restart it).
> 
> As a workaround, you may be able to 
>  - Start the emulator in debug mode (if necessary, hack
> $JC_SDK/platform.properties which defines the command line - I wrote pretty
> extensive docs for how this all works here -
> http://wiki.netbeans.org/JavaCardPlatformIntegration )
>  - Attach the NetBeans debugger to the running process
>  - Send whatever query you want to trigger a breakpoint using the emulator
> console

Hi. I found the "Default Device.jcard" file in the not so obvious location of: 

"Documents and Settings\Administrator\.netbeans\6.8\config\org-netbeans-modules-javacard\servers\javacard_default"

In there, i can see properties such as:

"javacard.device.start.cmdline=${javacard.emulator} -debug ${debug} -suspend ${suspend} -ramsize ${javacard.device.ramSize} -e2psize ${javacard.device.e2pSize} -corsize ${javacard.device.corSize} -e2pfile ${javacard.device.eprom.file} -loggerlevel ${javacard.device.loggerLevel} -httpport ${javacard.device.httpPort} -contactedport ${javacard.device.contactedPort} -contactedprotocol ${javacard.device.apdutool.contactedProtocol} -contactlessport ${javacard.device.contactlessPort}"

and

"javacard.device.debugger.cmdline=${java.home}/bin/java -classpath ${javacard.debug.proxy.classpath} {{{-Djc.home=${javacard.ri.home}}}} com.sun.javacard.debugproxy.Main {{{debug}}} --listen ${javacard.device.proxy2idePort} --remote ${javacard.device.host}:${javacard.device.proxy2cjcrePort} --classpath ${class.path}"

I commented out javacard.device.start.cmdline.
I cut-and-paste javacard.device.debugger.cmdline and renamed it javacard.device.start.cmdline.
I restarted the development environment.

Running the debugger still reset the package. 

Any suggestions on what i need to do??

--------

> However, if the emulator is already running in debug mode (you can start it
> that way on the Services tab), 

I could not find any way through the GUI to start the emulator in debug mode through the services tab.
Comment 3 _ tboudreau 2011-01-16 17:10:44 UTC
Can you deploy and then use Debug > Attach Debugger to attach to the running VM?
Comment 4 Adam Sotona 2011-02-16 11:17:42 UTC
this issue requires more evaluation
Comment 5 Adam Sotona 2011-03-08 13:01:46 UTC
Decreasing the priority as the issue affects just a particular use case and workaround exists.
Comment 6 J Bachorik 2012-08-01 08:41:50 UTC
changing owner