473,726 Members | 2,262 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using Toolkit.getDefa ultToolkit().ge tImage() within JSP

I am attempting to upload a picture to a webserver and create a
thumbnail from the picture uploaded. The problem comes in when I
attempt to create an Image object from the File object (which is the
location of the uploaded picture)...I get the following error:

java.lang.NoCla ssDefFoundError
at java.lang.Class .forName0(Nativ e Method)
at java.lang.Class .forName(Class. java:130)
at java.awt.Toolki t$2.run(Toolkit .java:712)
at java.security.A ccessController .doPrivileged(N ative Method)
at java.awt.Toolki t.getDefaultToo lkit(Toolkit.ja va:703)
at _admin._addpict ure__jsp._jspSe rvice(/www/mcmanis.scharle mann.com/admin/addpicture.jsp: 89)
at com.caucho.jsp. JavaPage.servic e(JavaPage.java :74)
at com.caucho.jsp. Page.subservice (Page.java:485)
at com.caucho.serv er.http.FilterC hainPage.doFilt er(FilterChainP age.java:176)
at com.caucho.serv er.http.Invocat ion.service(Inv ocation.java:27 8)
at com.caucho.serv er.http.Servlet Server.serviceT op(ServletServe r.java:847)
at com.caucho.serv er.http.HttpReq uest.handleRequ est(HttpRequest .java:213)
at com.caucho.serv er.http.HttpReq uest.handleConn ection(HttpRequ est.java:158)
at com.caucho.serv er.TcpConnectio n.run(TcpConnec tion.java:140)
at java.lang.Threa d.run(Thread.ja va:536)
Basically here is what happens. I use a multipart/form-data html form
within my html page to upload the picture to the server. I have no
problem doing this. The picture is saved in a temporary location. I
then attempt to create a thumbnail from the picture with the code from
here: http://www.geocities.com/marcoschmid...thumbnail.html

The problem is...whether in a JavaBean...or directly in the JSP
page...the line where I try to create the Image with the Toolkit
throws the NoClassDefFound Error.
Line 87 in addpicture.jsp is:
Image image = Toolkit.getDefa ultToolkit().ge tImage(
file.getCanonic alPath());

where file is the object pointing to the temporary location of the
uploaded picture. If anyone has any idea how to fix/get arround this
problem I would appreciate any help. Thanks
Jul 17 '05 #1
1 10838
On 30 Aug 2003 20:58:00 -0700, gr**@dreamatlan tic.com (Greg Scharlemann)
two-finger typed:
I am attempting to upload a picture to a webserver and create a
thumbnail from the picture uploaded. The problem comes in when I
attempt to create an Image object from the File object (which is the
location of the uploaded picture)...I get the following error:

java.lang.NoCl assDefFoundErro r
at java.lang.Class .forName0(Nativ e Method)
at java.lang.Class .forName(Class. java:130)
at java.awt.Toolki t$2.run(Toolkit .java:712)
at java.security.A ccessController .doPrivileged(N ative Method)
at java.awt.Toolki t.getDefaultToo lkit(Toolkit.ja va:703)
at _admin._addpict ure__jsp._jspSe rvice(/www/mcmanis.scharle mann.com/admin/addpicture.jsp: 89)
at com.caucho.jsp. JavaPage.servic e(JavaPage.java :74)
at com.caucho.jsp. Page.subservice (Page.java:485)
at com.caucho.serv er.http.FilterC hainPage.doFilt er(FilterChainP age.java:176)
at com.caucho.serv er.http.Invocat ion.service(Inv ocation.java:27 8)
at com.caucho.serv er.http.Servlet Server.serviceT op(ServletServe r.java:847)
at com.caucho.serv er.http.HttpReq uest.handleRequ est(HttpRequest .java:213)
at com.caucho.serv er.http.HttpReq uest.handleConn ection(HttpRequ est.java:158)
at com.caucho.serv er.TcpConnectio n.run(TcpConnec tion.java:140)
at java.lang.Threa d.run(Thread.ja va:536)
Basically here is what happens. I use a multipart/form-data html form
within my html page to upload the picture to the server. I have no
problem doing this. The picture is saved in a temporary location. I
then attempt to create a thumbnail from the picture with the code from
here: http://www.geocities.com/marcoschmid...thumbnail.html

The problem is...whether in a JavaBean...or directly in the JSP
page...the line where I try to create the Image with the Toolkit
throws the NoClassDefFound Error.
Line 87 in addpicture.jsp is:
Image image = Toolkit.getDefa ultToolkit().ge tImage(
file.getCanonic alPath());

where file is the object pointing to the temporary location of the
uploaded picture. If anyone has any idea how to fix/get arround this
problem I would appreciate any help. Thanks

I think the problem here is, that you cannot use the Image subsystem (or
any AWT peering classes) when you are not running within the shell of an
X-Windows system.
So, you may need to have an initialized X-Windows running on the server for
this to work properly.

You could write your own algorithm so read the file, interpret the data and
create the proper data for an output file - all from the bytes you read.

JPEG but is a lot of algorithmic work, and while GIF is easiest to read, it
has a few peculiarities like animation that can make things harder.

Cheers.

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4198
by: Dado | last post by:
I create the jar with my classes, pictures and some txt files. The application is starting just fine if picture folder is out of the jar. If the folder picture is in the jar I don't see the pictures on my buttons and everywhere. How to solve that problem?
6
12761
by: ASPfool | last post by:
Hello everyone, Please help me before I throw my computer out of the window: I'm working on a web application in classic ASP (vbscript), which is making calls to some webservices. The calls are made using SOAP - i installed the SOAP3 toolkit on my windows 2k server to enable this. The webservice calls are returning String Arrays which I can't seem to do anything useful with. The call shown below returns a string array with two...
16
12643
by: thomas peter | last post by:
I am building a precache engine... one that request over 100 pages on an remote server to cache them remotely... can i use the HttpWebRequest and WebResponse classes for this? or must i use the MSHTML objects to really load the HTML and request all of the images on site? string lcUrl = http://www.cnn.com; // *** Establish the request
2
1453
by: noleander | last post by:
I'm trying to get Vis C++ std to compile using /O2 optimizing flag. Many people have suggested downloading the MS C++ 2003 Toolkit ... it supposedly has C++ compiler bins that one could use. I downloaded the 2003 Toolkit ... but the bin files are identical (size, date, contents) as my existing Vis C++ compiler. I have listed the file sizes below. Can someone who has downloaded the 2003 Toolkit see what file sizes and fiel dates ...
2
1437
by: Kris | last post by:
Hi All, I'm trying to use the GetImage method in a ASP.NET project that I've created but I keep getting an error stating: The name 'GetImage' does not exist in the class or namespace ... The project includes System.Drawing and I've even tried specifying the fully qualified name System.Drawing.ToolboxBitmapAttribute.GetImage but the
3
3087
by: Hitesh | last post by:
Hi, I am getting the response from another Website by using the HttpHandler in my current site. I am getting the page but all the images on that page are not appearing only placeholder are displayed. Can anybody know this issue and help me to resolve this. In past i received the response saying that i should download the image first and then parse the actual response and modify the src attribute of the
9
1845
by: JuniorProgrammer | last post by:
Please This is queit a task av been trying to solve. Could anyone please tell me how to read a blob from an SQL using a dataset and stuffing this image into the Image control of a webform. Any suggetion that would help would be highly appreciated. -- Iyke
1
7079
by: Manticure | last post by:
I want to get the R, G and B components as integers (0-255). I use this: Rectangle area = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()); BufferedImage bufferedImage = r.createScreenCapture(area); int pixel = bufferedImage.getRGB(x,y); But it returns some crazy 1 value of -65536 or something like that. How do I convert it to three individual integers R,G and B?
3
2572
by: mukeshrasm | last post by:
Hi i have a page "newlaunching.php" page on which image is displayed and when user clicks one of thumbnail its larger image comes to this page(newlaunching.php) from "getimage.php"page using ajax and it is working fine! now i want to get the "id" of the larger image from "getimage.php so that i could pass this value to "ADD to CART" button for which the product will be added to cart. By default on "ADD to CART" button by default's image id...
0
8889
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9116
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3228
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.