java.lang.ClassNotFoundException - java

I have embedded an applet (jar file)in a html page
Now when I am trying to access the web page , it is giving the following error.
<APPLET CODE="com.xxx.tru.ReadNFCSerialNumber" NAME="Read" ID="Read" MAYSCRIPT alt="Photo Id" ARCHIVE="\test.jar, \ojdbc14.signed.jar, \ojdbc14_g.signed.jar" WIDTH="100%" HEIGHT="100%" HSPACE="1" VSPACE="1">
</APPLET>
load: class com.xxx.tru.ReadNFCSerialNumber not found.
java.lang.ClassNotFoundException: com.xxx.tru.ReadNFCSerialNumber
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed:http://localhost/popit/POPit/com/xxx/tru/ReadNFCSerialNumber.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)
... 7 more
Exception: java.lang.ClassNotFoundException: com.xxx.tru.ReadNFCSerialNumber
What am i doing wrong??

The web browser is trying to load your class from the URI http://localhost/popit/POPit/com/xxx/tru/ReadNFCSerialNumber.class instead of your jar file. The contents of the ARCHIVE attribute looks suspicious to me. Is it really supposed to be a comma-and-space delimited list? Also, the backslashes in front of the file names look suspicious:
ARCHIVE="\test.jar, \ojdbc14.signed.jar, \ojdbc14_g.signed.jar"
I would suggest you look into fixing the ARCHIVE attribute and then see if the web browser will load the class file form the jar as you want it to do.

the CODEBASE attribute is missing. just a thought.code base

Related

how to convert HTML files to PDF in Java?

I am trying to develop an application which takes a html file or url as input and renders the same as PDF file. I am using yahp for this purpose. I have imported the yahp.jar file, however I am stuck with the following exception:
java.lang.ClassNotFoundException: org.allcolor.yahp.cl.converter.CHtmlToPdfFlyingSaucerTransformer
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.allcolor.yahp.converter.CClassLoader.findClass(CClassLoader.java:1495)
at org.allcolor.yahp.converter.CClassLoader.findClass(CClassLoader.java:1477)
at org.allcolor.yahp.converter.CClassLoader.loadClass(CClassLoader.java:2056)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.allcolor.yahp.converter.CYaHPConverter.getTransformer(CYaHPConverter.java:383)
at org.allcolor.yahp.converter.CYaHPConverter.convertToPdf(CYaHPConverter.java:246)
at HtmlToPDF.htmlToPdfFile(HtmlToPDF.java:74)
at HtmlToPDF.main(HtmlToPDF.java:52)
SEVERE: Error while getting transformer 'org.allcolor.yahp.cl.converter.CHtmlToPdfFlyingSaucerTransformer' ! : org.allcolor.yahp.cl.converter.CHtmlToPdfFlyingSaucerTransformer
org.allcolor.yahp.converter.IHtmlToPdfTransformer$CConvertException
at org.allcolor.yahp.converter.CYaHPConverter.convertToPdf(CYaHPConverter.java:255)
at HtmlToPDF.htmlToPdfFile(HtmlToPDF.java:74)Done
at HtmlToPDF.main(HtmlToPDF.java:52)
Caused by: java.lang.NullPointerException
at org.allcolor.yahp.converter.CYaHPConverter.convertToPdf(CYaHPConverter.java:247)
... 2 more
Destroying YAHP ClassLoader Tree
Exception in thread "AWT-Windows" java.lang.IllegalStateException: Shutdown in progress
at java.lang.ApplicationShutdownHooks.add(Unknown Source)
at java.lang.Runtime.addShutdownHook(Unknown Source)
at sun.awt.windows.WToolkit.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
iText “XML Worker” allows developers to convert XML files to PDF documents in a programmer-friendly way. iText can also convert HTML to PDF with the CSS style implemented on HTML elements.
Look at this

Java Applet in .Net Web Application Issue

How can I put a Java Applet in my .Net Web Application ?
I'm trying the following code
<applet code="com.griaule.fingerprintsdk.appletsample.FormMain"
archive="C:\Users\lucas\workspace\applet-chave\bin\SignedFingerprintSDKJava.jar, C:\Users\lucas\workspace\applet-chave\bin\SignedFingerprintSDKJavaAppletSample.jar, C:\Users\lucas\workspace\applet-chave\bin\sqljdbc4.jar" height="550" width="550">
</applet>
but i got the following error
java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at sun.plugin.util.ProgressMonitorAdapter.setProgressFilter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.setupProgress(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at sun.plugin.util.ProgressMonitorAdapter.setProgressFilter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.setupProgress(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at sun.plugin.util.ProgressMonitorAdapter.setProgressFilter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.setupProgress(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
If I insert into my .net project the .jar, occurs the error IllegalArgumentException, if I insert file:\ before the path of the jar files, occurs the error SecurityException like I said in comments.
Java applet is configured using HTML tags, so reference to .Net is irrelevant here.
I guess that your problem is in manner you are configuring the classpath defined in attribute archive. The jar references specified there must be relative to your codebase. They cannot be absolute file paths on your machine.
You should write something like
first.jar,second.jar
and put the jars in place accessible over HTTP

java.net.MalformedURLException for applet url

I have signed my applet and it is in jar.
I have added the below code in my jsp to embedd applet
<applet name="viewerApplet" id="TViewerApplet" width="100%" height="500" code="TViewerApplet.class" codebase="/WEB-INF/lib" mayscript="mayscript" archive="C:/Eclipse_Workspace/Velocity/BSLI_MIS_VELOCITY/WebContent/WEB-INF/lib/SSignedTAppletViewer.jar">
but I get below exception
java.net.MalformedURLException: unknown protocol: c
Edit:
Now I am using
<applet name="viewerApplet" id="TViewerApplet" width="100%" height="500" code="TViewerApplet.class" align="baseline" codebase="." mayscript="mayscript" archive="SSignedTAppletViewer.jar,cmbview81.jar">
New Exception
load: class TViewerApplet.class not found.
java.lang.ClassNotFoundException: TViewerApplet.class
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)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed:http://10.160.118.171:8086/BSLI_MIS_VELOCITY/TViewerApplet/class.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)
... 9 more
Exception: java.lang.ClassNotFoundException: TViewerApplet.class
archive="C:/Eclipse_Workspace/Velocity/BSLI_MIS_VELOCITY/WebContent/WEB-INF/lib/SSignedTAppletViewer.jar"
There are two problems with this.
The archive attribute is a path relative (an HREF) to the codebase, whereas that points to a file path (as opposed to a file: based URL - hence unknown protocol: c). But use a relative path.
/WEB-INF/lib/ is typically reserved for the server and has no public access. You need to put the Jar somewhere else. I generally use /lib/.
Update
TViewerApplet is in SSignedTAppletViewer.jar
Yes its is in package com.mind
Now jar is in same folder where jsp resides
I have checked with jar -tvf ,class is in the jar
Good. Putting that all together results in an applet element like this:
<applet
name="viewerApplet"
id="TViewerApplet"
width="100%"
height="500"
code="com.mind.TViewerApplet"
align="baseline"
codebase="."
mayscript="mayscript"
archive="SSignedTAppletViewer.jar,cmbview81.jar">
</applet>
The only change is in the code attribute, from TViewerApplet.class to com.mind.TViewerApplet - the .class is not necessary, but the package is.

JUpload issue on jsp page

Im getting:
load: class wjhk.jupload2/JUploadApplet.class not found.
java.lang.ClassNotFoundException: wjhk.jupload2.JUploadApplet.class
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)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed:http://test1/EAMAPP84/data/docuploads/ROADS/NoamTest/wjhk/jupload2/JUploadApplet/class.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)
... 9 more
Exception: java.lang.ClassNotFoundException: wjhk.jupload2.JUploadApplet.class
on the java consule.
the applet is called:
<applet
code="wjhk.jupload2/JUploadApplet.class"
codebase="\EAMAPP84\data\docuploads\ROADS\NoamTest"
archive="JUpload.jar"
width="650"
height="400">
<param name="actionURL"
value="\\test1\EAMAPP84\data\docuploads\ROADS\NoamTest">
</applet>
while the jar is sitting in the given directory.
the wierd thing is, when i create a simple html file using this it works, butwhen using it in my jsp page i get this error.
anyone?
The code attribute should point to the fully qualified name of the class (the same as you would use in import statement of a normal Java class).
code="wjhk.jupload2.JUploadApplet"
The exception is by the way also hinting that:
java.lang.ClassNotFoundException: wjhk.jupload2.JUploadApplet.class
(the .class part doesn't belong there at all)
and also here:
java.io.IOException: open HTTP connection failed:http://test1/EAMAPP84
/data/docuploads/ROADS/NoamTest/wjhk/jupload2/JUploadApplet/class.class
(note the /class.class part which is obviously wrong)
code="wjhk.jupload2/JUploadApplet.class"
Should probably be..
code="wjhk.jupload2.JUploadApplet"

class not found exception and IO exception while run applet on web

This is my jsp file body tag.
<body>
<jsp:plugin type="applet" code="SApplet.class"
codebase="C:\Program Files\apache-tomcat-6.0.18\webapps\testweb\WEB-INF\classes"
width="400"
height="300" jreversion="1.6"></jsp:plugin>
</body>
I want to run my applet on web application, but i got following error that will fetch on one small window.I can't get any error on console.
Java Plug-in 1.6.0_20
Using JRE version 1.6.0_20-b02 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\Sandy
----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------
load: class SApplet.class not found.
java.lang.ClassNotFoundException: SApplet.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed:http://localhost:8080/testweb/SApplet/class.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)
... 7 more
Exception: java.lang.ClassNotFoundException: SApplet.class
load: class SApplet.class not found.
java.lang.ClassNotFoundException: SApplet.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed:http://localhost:8080/testweb/SApplet/class.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)
... 7 more
Exception: java.lang.ClassNotFoundException: SApplet.class
Your code base is written wrong. It should be a relative web path.
In your case it should be something like testweb/applet-classes. But put all applet classes there, not under WEB-INF. WEB-INF is a place where you should store classes that run on server side. This folder may be not accessible from web. The applet classes are downloaded by JVM that is running into browser, so WEB-INF may be not visible for it.
Better way is even pack your applet classes into jar file and put it even under root of your application. In this case your code base will look like codebase='myapplet.jar'

Categories

Resources