I've created an applet that uses JavaPOS to communicate with a payment terminal on the user's local system.
When run from within the Eclipse IDE, the applet works fine, but not when run in a browser. In a browser, the applet can't seem to find the jpos/res/jpos.properties and jposxml.cfg files.
When the following statements are executed in the applet (in the start() method, not init()):
JposEntryRegistry registry = JposServiceLoader.getManager().getEntryRegistry();
registry.load();
this is the output I see in the Java console window:
jpos/res/jpos.properties file not found
jpos/res/jpos.properties file not found
jpos/res/jpos.properties file not found
And no entries are loaded in the JposEntry registry.
I've tried the following to get the applet to "see" the two files:
jpos/res/jpos.properties is already present in one of the jars referenced by the applet. Nevertheless, I've added this file to the applet's main jar. I've also tried adding it to the directory on the server containing the jars (with the correct relative path). None of this works.
I can work around the inability of jpos.properties to be found by setting System properties with the appropriate values, like this:
System.setProperty("jpos.loader.serviceManagerClass", "jpos.loader.simple.SimpleServiceManager"); System.setProperty("jpos.config.populatorFile", "jposxml.cfg"); System.setProperty("jpos.util.tracing.TurnOnNamedTracers", "JposServiceLoader,SimpleEntryRegistry,SimpleRegPopulator,XercesRegPopulator"); System.setProperty("jpos.util.tracing.TurnOnAllNamedTracers", "ON");
However, the applet still can't find jposxml.cfg. This file is present in the root of the applet's main jar file. I've tried putting on the server in the same directory as the jars. I've also tried creating a separate jar file containing only jposxml.cfg, but that doesn't work either. I get the following output in the Java console window:
[AbstractRegPopulator]getPopulatorFileIS(): populatorFileName=jposxml.cfg [JposServiceLoader]manager.getEntryRegistry().load() OK [AbstractRegPopulator]getPopulatorFileIS(): populatorFileName=jposxml.cfg
But the list of JposEntries is empty. As a result the applet can't communicate with the payment terminal.
The applet is loaded via a JNLP file (and all required jars via a JNLP extension). Both JNLP files have security set to <all-permissions/>. All jars are signed with the same certificate. The same code works perfectly in Eclipse. Any ideas on what the problem is?