• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Applet Breaks Otherwise Functional Buttons

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greetings from a new member! I minored in software engineering during my undergraduate work (my major was Spanish), but my focus has since shifted to graduate studies in linguistics, in which I have just earned my M.A. From time to time, I dust off my probably rusty programming skills in Java to develop linguistic software. My main project is a program that can transcribe English words according to a variety of phonetic representation systems. It does this essentially by looking up each item in the Cambridge Online Dictionary, parsing through the HTML code of the page returned by Cambridge, and extracting the necessary information.

I have recently been doing some maintenance on the stand-alone program, and I decided to renew my attempts to convert it into an Applet. The problem is that, although everything displays nicely and the drop-down menu seems to work, the buttons that should start the transcription process do absolutely nothing. They work perfectly fine in the normal application, but in the Applet version, they're completely ineffectual, and the code is identical everywhere it can be.

This is the source code for my GUI.



The main Applet class is as follows:



Applet's host webpage

Any help you can offer will be greatly appreciated. Thanks in advance!
 
Ranch Hand
Posts: 43
Spring Tomcat Server Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
'completely ineffectual' means? That nothing is happening when you click?

Try add debug statements. For example, do a println, when the event is caught. Another while the event is being processed. Until you find where it stopped.
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch.

This is probably down to the appropriate security permissions not having been granted. Check the Java Console (see https://www.java.com/en/download/help/javaconsole.xml) to see if any errors/exceptions have been thrown.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, if the applet tries to access websites other than the one it was downloaded from, as yours does, then it has to be signed.
 
Gregory Bontrager
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your ideas! How would I see the print-out if running it in a web browser? In the NetBeans viewer, strangely enough, the buttons work, but only three of the five notations do. If you select either of the other two in the drop-down menu, it defaults to the International Phonetic Alphabet (IPA). When that happens, the transcription retains any punctuation from the input and lacks the slashes that it should put on both ends as one of the finishing touches before displaying the output.

I don't think security is the problem, or at least not the only one. Very basic and common words are listed with their IPA renditions (from which the transcription into any other notation can be derived) in a built-in lexicon, and the algorithm is designed to try finding a word there before it consults the online resource. Even when I input a word that I know is in that native database and therefore shouldn't require external website access to transcribe, the buttons still don't do anything.

I followed the steps given in the link to enable the console, but I can't see where to access it in my browser (Firefox).

In any case, based on your remarks, it seems that even if I solve this particular problem, I'll need to get certified if I want the program to be fully functional. Any tips on that?
 
Tony Docherty
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I run an applet in Firefox the Java console just appears automatically. Check your "running applications" for the Java console as it may be running behind the browser.

There are lots of security permissions that may need permissions granting, not just visiting another site, so you really need to check the console to see if any exceptions are thrown.

If the application is just for your use you can self sign the applet and add your site address to the Exception Site List in the Java Control Panel's security tab
 
Gregory Bontrager
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Java Console (in IE) had this to say.

Exception in thread "AWT-EventQueue-2" java.lang.NoClassDefFoundError: org/jsoup/Jsoup
at Pronounce2.getPron(Pronounce2.java:1277)
at Pronounce2.isWord(Pronounce2.java:748)
at Pronounce2.parseMorph(Pronounce2.java:1543)
at Pronounce2.extrPron(Pronounce2.java:1081)
at Pronounce2.finalPron(Pronounce2.java:1103)
at TextParser.parseText(TextParser.java:119)
at ConvGUI$KeyHandler.actionPerformed(ConvGUI.java:100)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.jsoup.Jsoup
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 42 more

Jsoup is a third-party redistributable library that expedites the access and HTML-parsing of web pages. While all my class and source files are stored in "...\TranRLS7\," Jsoup is stored as a JAR in "...\TranRLS7\lib\." At some point in my earlier testing, I once got a message in the NetBeans debugging console that Jsoup was "already signed," so I think it's fine security wise. Something's just not finding or recognizing it, apparently.
 
Tony Docherty
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I may be wrong here but I think the jar has to be in the same directory as the class file for the applet to be able to find it.
 
Gregory Bontrager
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had the same thought, so I tried moving the Jsoup JAR into the main directory with all the other source files. It didn't change anything.
 
John Cruz
Ranch Hand
Posts: 43
Spring Tomcat Server Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are 2 ways. You can either unjar the jsoup jar and put them all together with your jar, or specify both jars in the 'archive' attribute in your html.

Like:

archive="main.jar,second.jar"
 
John Cruz
Ranch Hand
Posts: 43
Spring Tomcat Server Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Take note, the 'codebase' attribute says where the jars should be. For your case, if you put the 2 jars inside the 'archive' attribute, you should copy the jsoup jar in the same folder as your main jar.
 
Gregory Bontrager
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A bit of research, now confirmed by the latest responses here, revealed that the lack of an archive attribute in my HTML was the culprit, at least for the Jsoup issue. Now, the console says this:

Exception in thread "AWT-EventQueue-3" java.security.AccessControlException: access denied ("java.net.SocketPermission" "dictionary.cambridge.org" "resolve")
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkConnect(Unknown Source)
at sun.plugin2.applet.SecurityManagerHelper.checkConnectHelper(Unknown Source)
at sun.plugin2.applet.AWTAppletSecurityManager.checkConnect(Unknown Source)
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName(Unknown Source)
at java.net.InetAddress.getAllByName(Unknown Source)
at java.net.InetAddress.getByName(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:439)
at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:424)
at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:178)
at org.jsoup.helper.HttpConnection.get(HttpConnection.java:167)
at Pronounce2.getPron(Pronounce2.java:1277)
at Pronounce2.isWord(Pronounce2.java:748)
at Pronounce2.parseMorph(Pronounce2.java:1543)
at Pronounce2.extrPron(Pronounce2.java:1081)
at Pronounce2.finalPron(Pronounce2.java:1103)
at TextParser.parseText(TextParser.java:119)
at ConvGUI$KeyHandler.actionPerformed(ConvGUI.java:100)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-3" java.security.AccessControlException: access denied ("java.net.SocketPermission" "dictionary.cambridge.org:80" "connect,resolve")
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkConnect(Unknown Source)
at sun.plugin2.applet.SecurityManagerHelper.checkConnectHelper(Unknown Source)
at sun.plugin2.applet.AWTAppletSecurityManager.checkConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:439)
at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:424)
at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:178)
at org.jsoup.helper.HttpConnection.get(HttpConnection.java:167)
at Pronounce2.getPron(Pronounce2.java:1277)
at Pronounce2.isWord(Pronounce2.java:748)
at Pronounce2.parseMorph(Pronounce2.java:1543)
at Pronounce2.extrPron(Pronounce2.java:1081)
at Pronounce2.finalPron(Pronounce2.java:1103)
at TextParser.parseText(TextParser.java:96)
at ConvGUI$KeyHandler.actionPerformed(ConvGUI.java:100)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

So we appear to have eliminated all but the security issue that we initially suspected. *SIGH* It looks like I'll have to fork out the dough for a certificate. I only hope it's affordable and doesn't take too long.
 
John Cruz
Ranch Hand
Posts: 43
Spring Tomcat Server Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, you need it.

But if it is only for personal use, like Tony said, you can self-sign. In addition, if it is for personal use only, there is also the alternative of editing the java.policy file if you dont want to sign the jar.
 
John Cruz
Ranch Hand
Posts: 43
Spring Tomcat Server Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you wish, below will let you continue. This is dangerous as it gives full access to all applets loaded by the java installation. You may want to remove ASAP after your testing, to be safe that applets you load later are not given FULL access unnecessarily.

Find the java.policy file in your java installation.

Add below at the top of the file.



(If there are more than 1 java installation in your PC, put it in the one that your applet uses; if you are not sure how to find out which, just put it on all the java installations.)

(java.policy is very specific. You can give access to specific packages, specific actions, etc. That code above gives access to EVERYTHING, like deleting files in your harddisk, etc..)
 
reply
    Bookmark Topic Watch Topic
  • New Topic