23

I downloaded Java Card Connected Edition 3.0.2 from Oracle official website and installed it. There are some web samples in JCDK. In documentation written:

All samples must be run from within the NetBeans IDE. They cannot be run from the command line in this release of the development kit.

Samples works with NetBeans IDE correctly. I can import them and run on Java Card Platform.

But I want to use this samples on Eclipse IDE. In Eclipse as Java Card SDK path I showed Java Card Connected home path. Then created new device and tried to start it [CardHolderApp for example]. But Eclipse gives:

ApduTool thread exited
User input thread exited
APDU|ApduTool [v3.0.2]
APDU|    Copyright (c) 2009 Sun Microsystems, Inc.
APDU|    All rights reserved.
APDU|    Use is subject to license terms.
APDU|Opening connection to localhost on port 9025.
APDU|Connected.
APDU|java.net.ConnectException: Connection refused: connect
ApduTool process finished with code: 1

.log file:

!ENTRY org.eclipse.core.jobs 4 2 2015-09-08 01:39:17.142
!MESSAGE An internal error occurred during: "Launching CardHolderApp".
!STACK 0
java.lang.RuntimeException: Cannot start device. Please see the log.
    at com.oracle.javacard.jcdk.launch.runconfiguration.AppletRunConfigurationDelegate.launch(AppletRunConfigurationDelegate.java:79)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:885)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:739)
    at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1039)
    at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1256)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

Is it possible to run Java Card Connected Web project in Eclipse IDE?

UPDATE:

Device started successfully. But project not deployed. It gives "unsupported String type constant" on every String usage. Code example:

public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    response.setContentType("text/html"); // unsupported String type constant
    PrintWriter out = response.getWriter();
    RequestDispatcher dispatcher = null;
    dispatcher = request.getRequestDispatcher("/WEB-INF/header.i");//unsupported String type constant
    response.sendRedirect(response.encodeRedirectURL("http://www.sun.com"));//unsupported String type constant
    dispatcher.include(request, response);
    dispatcher.include(request, response);
}

Classic Edition did not support Strings. But it must work on Connected Edition.

LEQADA
  • 1,913
  • 3
  • 22
  • 41

1 Answers1

1

Forgetting about all the complicated software in between. Just looking at the error messages, it looks like port 9025 is not open or available on your localhost :

APDU|Opening connection to localhost on port 9025.
APDU|Connected.
APDU|java.net.ConnectException: Connection refused: connect
ApduTool process finished with code: 1

The text [java.net.ConnectException: Connection refused: connect], everytime I see "Connection refused" it means java tried to create a socket on the port (9025 in this case) and it could not get the port number either because of a blockage (like a firewall) or not available (something else is using port 9025).

On windows or *nix, you can usually use the netstat command to see what ports are being used.

hth, adym

lincolnadym
  • 909
  • 1
  • 12
  • 29
  • It doesn't matter wich port I'm trying to use. Same error. As I know Connected Edition Dev. Kit works only on Windows. The same code works on NetBeans clearly and gives error on Eclipse even when firewall is turned off. – LEQADA Sep 28 '15 at 07:00
  • So with Eclipse up and running, what does the netstat -a command list out? Might help to repeat with NetBeans up and running, then compare the two netstat -a outputs...of course, close out Eclipse before starting NetBeans. – lincolnadym Sep 30 '15 at 02:04
  • Something else I noticed on your stack trace...Are you running it in a Debug mode...I see DebugUIPlugin? Because a debugger is going to open a port to allow you to step thru code. Did you try and just use a Run Configuration (no debugger)? – lincolnadym Sep 30 '15 at 02:15
  • it's not debug mode. Device started. But it gives me "unsupported string type constant" on every String I am using (for example `response.setContentType("text/html");`). So, it seems that this device on Eclipse only for Classic Edition. Maybe there is some other method to set up default device to work with Connected Edition. Or maybe that's not possible to run on Eclipse. Maybe I need to contact Oracle for more information. – LEQADA Sep 30 '15 at 20:31
  • Port is opened. But project is not deployed. Browser couldn't load the page. – LEQADA Sep 30 '15 at 20:43
  • Ok, I've never used Java Card. So I downloaded the 3.0.5u1, published Aug 2015. I'm trying to get some samples to run via command line, before I try and bring it to Eclipse. From some google searches it's looking like your 3.0.2 version is simply missing an Eclipse Plugin. It looks like the Java Card stuff runs in Eclipse as long as you have an Eclipse Plugin...i.e. version 2.2.2. You might want to try the 3.0.5u1, as I see an Eclipse plugin zipped up in the *.msi installer. I'll try and run some samples, but I must confess, I've never used Java Card. Any good tutorials I could follow? – lincolnadym Oct 01 '15 at 23:51
  • 3.0.5u1 is Java Card Classic Edition version. Latest Connected Edition version is 3.0.2. To run Connected Edition application from terminal you need to set up a server (to run servlets). In NetBeans it's Jetty. Maybe some modificated version of Jetty. I don't know. After installation in root folder of development kit in docs folder you'll find PDF document with nice guide. Unfortunately Eclipse plugin is for Classic Edition. Not for Connected. – LEQADA Oct 02 '15 at 21:05