We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › Exceptions in applets
Page Index Toggle Pages: 1
Exceptions in applets (Read 1160 times)
Exceptions in applets
Jul 26th, 2007, 7:18pm
 
hello,

I'm trying to use a processing applet in order to get data from a Mysql DB and then print external files. I use the MySQL library and everything works ok when I run the program. Nonetheless when I export and applet and test it on my local server the java console throws me an exception of this kind:

Error while running applet.
java.lang.RuntimeException: The applet was not inited properly, or security restrictions prevented it from determining its path.
at processing.core.PApplet.sketchPath(PApplet.java:4686)
at processing.core.PApplet.savePath(PApplet.java:4716)
at processing.core.PApplet.saveStrings(PApplet.java:4630)
at evolvingCSS_stage3_2$Population.printCSS(evolvingCSS_stage3_2.java:641)
at evolvingCSS_stage3_2.mousePressed(evolvingCSS_stage3_2.java:86)
at processing.core.PApplet.handleMouseEvent(PApplet.java:1759)
at processing.core.PApplet.dequeueMouseEvents(PApplet.java:1696)
at processing.core.PApplet.handleDisplay(PApplet.java:1387)
at processing.core.PGraphics.requestDisplay(PGraphics.java:680)
at processing.core.PApplet.run(PApplet.java:1454)
at java.lang.Thread.run(Unknown Source)

Any ideas?

It seems that the MySQL connector usen by Fjen is already outdated, but that shouldn't be a reason or? I have MySQL configured in a very low security mode, so I don't know what else can be...may be windows?

Plz help!
Re: Exceptions in applets
Reply #1 - Jul 26th, 2007, 8:19pm
 
What you're seeing is the difference in behaviours which are allowed in programs within processing, and applets running in a browser.

Applets in a browser are not allowed to do certain things, such as get files from the discs of the computer, access the clipboard, or make network connections (other than the webserver that the applet is on)

You cannot use the MySQL library in a applet, unless you go through the process of signing the applet.
Re: Exceptions in applets
Reply #2 - Jul 28th, 2007, 4:40pm
 
Hi JohnG, thanks for the reply. I believed that it was possible to use mySQL without the signing process if your applet remains in localhost, isn't it so? I'll go and check the "signing" Tutorial in any case
Re: Exceptions in applets
Reply #3 - Jul 28th, 2007, 6:16pm
 
Judging by the stacktrace of your exception, the culprit is saveStrings() rather than any MySQL stuff. Same explanation though as John gave: applets are not allowed to access (or even write to) local resources unless they're signed. Here's a mini crash course how to do that though...

Re: Exceptions in applets
Reply #4 - Jul 30th, 2007, 3:33pm
 
After I corrected other problems and I signed my applet, things seemed to work nicely, at least the applet runs, updates and passes commands to mySQL with no problems at all. But still the applet cannot write text files to the localhost folder! Is there any hack around this? Should the savestrings() work after the signing of the applet? I'm kind of lost with this...found something in processinghacks for writing bytes but not strings. Any hints?

thx for the help so far,
Re: Exceptions in applets
Reply #5 - Jul 30th, 2007, 11:39pm
 
saveStrings() always implies you want to work with local files. If you want to send data to your server (localhost or any other) it's best (more flexible and easier) to have a serverside script as recipient and then send data to it via HTTP. If it's not a lot of data you're sending you can use a query string appended to the URL or else you'll have to build an HTTP POST request.
Page Index Toggle Pages: 1