File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Applets and the fly likes Applet classloader can't load Properties Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Applet classloader can Watch "Applet classloader can New topic
Author

Applet classloader can't load Properties

Antonio Foglia
Greenhorn

Joined: Jun 30, 2013
Posts: 17
I'm developing an Applet that print a bar code using Jpos API. I need some jars and two configuration file. I've added jars to the classpath and configuration files in src directory. In Eclipse everything works fine.



Everything works fine in Eclispe but I can't find property files when i call the applet from a web page. So I've checked the JavaPos sources and I've paste the loadJposProperties() and xmlReg.load("wincor.jpos17.THxxx.xml") content in my source code:



The same method is used to found wincor.jpos17.THxxx.xml. So when I call applet form the browser I get INPUT STREAM FROM PROPERTIES OK!! from (1) and jpos/res/jpos.properties not found from (2).
So getClass().getClassLoader().getResourceAsStream works if i write it directly in my code, but doesn't work if i call a jar method.
I am really at a loss for what to try next in the debugging chain. Thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42264
    
  64
So when I call applet form the browser I get INPUT STREAM FROM PROPERTIES OK!! from (1) and jpos/res/jpos.properties not found from (2).

Not knowing what prop.loadJposProperties() does, it's not possible to say why it behaves differently.

So getClass().getClassLoader().getResourceAsStream works if i write it directly in my code, but doesn't work if i call a jar method.

By "directly" you mean what you call "(1)", correct? What do you mean by "if i call a jar method"?


Ping & DNS - my free Android networking tools app
Antonio Foglia
Greenhorn

Joined: Jun 30, 2013
Posts: 17
prop.loadJposProperties() does



Yes, by "directly" i mean whe i call (1).
By "if i call a jar method" i mean call "prop.loadJposProperties()". Prop is a DefaultProperties object imported from an external jar. I've added alle xternal jar declarations to the jnlp file.
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2310
    
  49
Have you checked the Java console to see if any exceptions are being thrown?

BTW I suspect code 1 is not the complete equivalent of code 2. Code 1 just gets an input stream whereas code 2 almost certainly gets the input stream, reads it and creates some sort of property object. It may be one of the later stages of process 2 is failing for example due to a lack of read permissions.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Applet classloader can't load Properties