aspose file tools*
The moose likes Applets and the fly likes Applet freezes with itext Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Applet freezes with itext" Watch "Applet freezes with itext" New topic
Author

Applet freezes with itext

Adam Pioro
Greenhorn

Joined: Aug 13, 2010
Posts: 8
I've got an applet that works perfectly but when it tries to call method in a class that imports itext component it freezes. Why is that so?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

What's in the Java console after that happens?
Adam Pioro
Greenhorn

Joined: Aug 13, 2010
Posts: 8
Exception in thread "AWT-EventQueue-2" java.lang.NoClassDefFoundError: com/lowagie/text/pdf/PdfPageEvent
at Raporty$1.actionPerformed(Unknown Source)
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.AWTEventMulticaster.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.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: com.lowagie.text.pdf.PdfPageEvent
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 26 more
Caused by: java.io.IOException: open HTTP connection failed:http://localhost:8080/HPMS/com/lowagie/text/pdf/PdfPageEvent.class
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 29 more
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

So presumably you didn't mention the iText jar in the archive attribute of your applet element?
Adam Pioro
Greenhorn

Joined: Aug 13, 2010
Posts: 8
Ok now it works.
But now I have itext.jar in my program.jar and added second time as applet archive. Is there a way I could add something like archive="program/itext.jar" to avoid copying it twice?
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
But now I have itext.jar in my program.jar

That's not how jar files work - they can't be inside of other jar files if you expect to use the classes contained in them.
Adam Pioro
Greenhorn

Joined: Aug 13, 2010
Posts: 8
Ok, but I added itext.jar as library in program.jar.
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
I'm not sure what you mean by that; can you elaborate?
Adam Pioro
Greenhorn

Joined: Aug 13, 2010
Posts: 8
I have netbeans project and I have to add itext.jar as library there or it won't compile. But when I export whole project as program.jar and want to use it as applet I have to add itext.jar again as archive.
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
Whatever you do in NetBeans only concerns compilation; it has no bearing on what happens at runtime.
Adam Pioro
Greenhorn

Joined: Aug 13, 2010
Posts: 8
Ok, but why my jar is 1mb larger when I add itext library? Those itext classes should be somewhere there in my program.jar I think.
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
It's possible NetBeans adds the iText jar file to your application's jar file; you can use the "jar" tool to find out what's in that file.

But that's not what NetBeans should be doing. The proper way to deploy extra jar files with an applet is by listing them as part of the archive attribute.
 
 
subject: Applet freezes with itext