Help! - upload image in headless mode - server side

We are upgrading java 1.3 to java 1.4 in headless mode on Sun iPlanet.

We have an application in Production which has a servlet to upload the jpeg image into Oracle 8i database(blob) using JSwing and AWK libraries. In 1.3, the servlet is working with JFrame in a 揾eadless?environment, but in 1.4, it throws a java.awt.headless exception.

Here is the code where rises the exception:

=============

public class UploadLocalPicture extends HttpServlet

......

JFrame f = new JFrame();

f.addNotify();

Toolkit tk = Toolkit.getDefaultToolkit();

Image im = tk.createImage(b);

......

==============

What should we do to resolve our issue?

We found below from Sun.com bug database:

====================

Bug ID: 4281163

Release Fixed 1.4(merlin-beta) State Closed, fixed

Description :

Headless Java operation would mean that a server side Java program should be able to use the full J2SE or J2EE API without a GUI environment being present. This means that all AWT calls to manipulate components, graphics, fonts, printing etc. should be functional.

========================

Does this mean that with a properly configured os, the existing web application (server side programs) using AWT and JFC/Swing should work in the headless environment?

Thank you in advance,

Ping

[1401 byte] By [pingatalbanya] at [2007-11-26 15:17:16]
# 1
Why are you using a "headless" JFrame here, if all you're doing is uploading a jpeg?
Rodney_McKaya at 2007-7-8 10:57:46 > top of Java-index,Security,Cryptography...
# 2
Thank you for the response.This is a legacy code in production for years. Is there a way to solve this issue? Do we need to reconfig the server or do we need to rewrite the code?Ping
pingatalbanya at 2007-7-8 10:57:46 > top of Java-index,Security,Cryptography...
# 3

If you describe in more details what exactly it is you're doing on both server sides I will know how to answer your question better.

For example:

Are you reading the jpeg from the disk?

Are you sending bytes through the socket?

What are you doing with the data on the Oracle side?

Rodney_McKaya at 2007-7-8 10:57:46 > top of Java-index,Security,Cryptography...
# 4

If you describe in more details what exactly it is you're doing on both server sides I will know how to answer your question better.

For example:

Are you reading the jpeg from the disk?

Are you sending bytes through the socket?

What are you doing with the data on the Oracle side?

Thanks again for the reply.

Are you reading the jpeg from the disk? - yes

Are you sending bytes through the socket? - not sure

What are you doing with the data on the Oracle side? - yes

We have a servlet to read the jpeg from the disk from web user and then stream into the Oracle 8i database(blob). Here are the fragments of the code:

import javax.swing.ImageIcon;

import javax.swing.JPanel;

import java.sql.Blob;

import java.awt.Toolkit;

import java.awt.MediaTracker;

import java.awt.Image;

import java.awt.GraphicsEnvironment;

import java.awt.GraphicsConfiguration;

import java.awt.GraphicsDevice;

?.

public class UploadLocalPicture extends HttpServlet {

厖.

JPanel f = new JPanel();

f.addNotify();

Toolkit tk = Toolkit.getDefaultToolkit();

Image im = tk.createImage(b);

It raised the error at above.

Thank you,

Ping

pingatalbanya at 2007-7-8 10:57:46 > top of Java-index,Security,Cryptography...
# 5
You can load the image using ImageIO.read instead of using Toolkit.Post all the function code so I can see exactly what it does.
Rodney_McKaya at 2007-7-8 10:57:46 > top of Java-index,Security,Cryptography...