473,756 Members | 2,558 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 10841
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
4201
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
12763
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
12646
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
1454
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
1439
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
3090
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
1846
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
7081
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
2575
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
9287
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10046
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9886
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9722
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...
0
8723
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5155
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
5318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3369
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2677
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.