Hello,
I am working with an applet that gets the smartcard via event
notification (cardInserted and cardRemoved methods).
When It runs as application it works fine but when I try to run it as
applet I get the following error in the Java Plug-In console:
java.lang.NoSuchMethodError:
opencard.core.terminal.CardTerminalRegistry: method
setObserver(Lopencard/core/terminal/Observer;)V not found
at
opencard.core.event.EventGenerator.getGenerator(EventGenerator.java:101)
at ParkingApplet.register(ParkingApplet.java:540)
at ParkingApplet.init(ParkingApplet.java:120)
at sun.applet.AppletPanel.run(Compiled Code)
at java.lang.Thread.run(Thread.java:479)
when doing the event registration.
The code I am using is the proposed on the OCF 1.2 documentation.
This is the process we follow:
Source code:
Eventos.java
----------------------------
// Prueba de eventos
import javax.swing.*;
import java.applet.*;
import opencard.core.event.CTListener;
import opencard.core.event.CardTerminalEvent;
import opencard.core.event.EventGenerator;
import opencard.core.terminal.Slot;
import opencard.core.terminal.CardTerminal;
import opencard.core.service.SmartCard;
public class Eventos extends JApplet implements CTListener {
boolean isStandalone = false;
private SmartCard smartcard = null;
private CardTerminal terminal=null;
private int slotID=0;
//Construct the applet
public Eventos() {
}
//Initialize the applet
public void init() {
try {
System.out.println("Ejecutando init()");
System.out.println("SmartCard.start()");
SmartCard.start();
register();
} catch (Exception e) {
e.printStackTrace(); }
}
public void start() {
System.out.println("Ejecutando start()");
}
public void stop(){
System.out.println("Ejecutando stop()");
}
public void destroy() {
try {
System.out.println("Ejecutando destroy()");
unregister();
SmartCard.shutdown();
} catch (Exception eDestroy) {
System.out.println(eDestroy.toString());}
}
public void register()
{
EventGenerator.getGenerator().addCTListener(this);
/*try {
EventGenerator.getGenerator().createEventsForPresentCards(this);
} catch (Exception e) {
e.printStackTrace(System.err);
}*/
}
public void unregister()
{
EventGenerator.getGenerator().removeCTListener(this);
}
public void cardInserted(CardTerminalEvent event)
{
if (smartcard == null) {
try {
smartcard = SmartCard.getSmartCard(event);
terminal = event.getCardTerminal();
slotID = event.getSlotID();
System.out.println("Tarjeta insertada");
} catch (Exception eI) {
eI.printStackTrace(System.err);
}
}
}
public void cardRemoved(CardTerminalEvent event)
{
if ((event.getSlotID() == slotID) &&
(event.getCardTerminal()==terminal)) {
smartcard = null;
terminal = null;
slotID = 0;
System.out.println("Tarjeta retirada");
}
}
public static void main(String[] args)
{
Eventos applet = new Eventos();
applet.isStandalone = true;
applet.init();
applet.start();
}//del main
} //del applet
-------------------------------------
Compilation:
O:\Proyectos\OCF 1.1.1 to OCF 1.2>javac -deprecation -classpath
.;..\TODO_OCF1.2.jar Eventos.java
Eventos.java:70: Note: The method opencard.core.service.SmartCard
getSmartCard(opencard.core.event.CardTerminalEvent) in class
opencard.core.service.SmartCard has been deprecated.
smartcard =
SmartCard.getSmartCard(event);
^
Note: Eventos.java uses or overrides a deprecated API. Please consult
the
documentation for a better alternative.
1 warning
Execution as application
O:\Proyectos\OCF 1.1.1 to OCF 1.2>java -classpath .;..\TODO_OCF1.2.jar
Eventos
Ejecutando init()
SmartCard.start()
Ejecutando start()
Tarjeta insertada
Tarjeta retirada
Tarjeta insertada
Tarjeta retirada
We make a jar that contains Eventos.class and we sign it. When we try to
run
it from an applet the messages from
the java console are:
Java(TM) Plug-in
Using JRE version 1.2.1
User home directory = C:\WINNT\Profiles\jmteruel
Proxy Configuration: no proxy
JAR cache enabled.
Opening http://smartserv.tissat.es/OCF1.2/pruebas/TODO_OCF1.2.jar no
proxy
No holding
CacheHandler trying caching.
http://smartserv.tissat.es/OCF1.2/pruebas/TODO_OCF1.2.jar
CacheHandler file name: null
No cache available, using remote copy
Opening http://smartserv.tissat.es/OCF1.2/pruebas/TODO_OCF1.2.jar no
proxy
Opening http://smartserv.tissat.es/OCF1.2/pruebas/Eventos.jar no proxy
No holding
CacheHandler trying caching.
http://smartserv.tissat.es/OCF1.2/pruebas/Eventos.jar
CacheHandler file name: C:\Archivos de
programa\Netscape\Users\jmteruel\cache\MURV2FA3.JAR
Got cached copy
Ejecutando init()
SmartCard.start()
java.lang.NoSuchMethodError:
opencard.core.terminal.CardTerminalRegistry:
method setObserver(Lopencard/core/terminal/Observer;)V not found
at
opencard.core.event.EventGenerator.getGenerator(EventGenerator.java:101)
at Eventos.register(Eventos.java:53)
at Eventos.init(Eventos.java:29)
at sun.applet.AppletPanel.run(Compiled Code)
at java.lang.Thread.run(Thread.java:479)
Have you tested an applet accessing OCF using the 1.2 version?
Does anybody know something about this error?
Cheers,
Ismael
---
> Visit the OpenCard web site at http://www.opencard.org/ for more
> information on OpenCard---binaries, source code, documents.
> This list is being archived at http://www.opencard.org/archive/opencard/
! To unsubscribe from the [EMAIL PROTECTED] mailing list send an email
! to
! [EMAIL PROTECTED]
! containing the word
! unsubscribe
! in the body.