This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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
Rancher

Joined: Mar 22, 2005
Posts: 42958
    
  73
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"?
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: 2724
    
  56
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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Applet classloader can't load Properties
 
It's not a secret anymore!