• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Create Image in servlet WITHOUT invoking java.awt.Toolkit - Can it be done?

 
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, folks Ive been beating my head on the desk over this one for two days! What I have going is a "resize after upload" app Im working on that uploads the images to the server and then resizes them to a max width or height of 500px and optimizes them.. I had it working perfectly on my win2k box but then went to test on my Linux production server ... BOOM, NFG.

After some reading and investigation with my server guy we pinpointed it to the fact the Xwindows server is NOT installed on the server so anytime any class attempts a reference to the Toolkit it blows up.. Ive tried ImageIcon, Toolkit.getDefaultToolkit().getImage etc etc etc..

So someone has HAD to run into this before ... how in GODS NAME do I get a Valid Image object that I can resize etc without invoking a class that requires the Tookit? And no we are NOT installing the XWindows on the server because its sucks up SO much in resources its just not worth it.

Thanks for any help someone might offer!
 
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just upgrade to 1.4. Swing doesn't use the operating system to draw stuff. There are other ways around the problem though, if you can't upgrade. They mostly involve other toolkits that don't use awt to do drawing.
 
DC Dalton
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
we are using 1.4 and still have the problem. this is the exception:

500 Servlet Exception

||

java.lang.NoClassDefFoundError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at java.awt.Toolkit$2.run(Toolkit.java:748)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:739)
at ResizeImages.doPost(ResizeImages.java:25)
at ResizeImages.doGet(ResizeImages.java:91)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:126)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:113)
at com.caucho.server.cache.CacheFilterChain.doFilter(CacheFilterChain.java:211)
at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:177)
at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:221)
at com.caucho.server.hmux.HmuxRequest.handleRequest(HmuxRequest.java:392)
at com.caucho.server.port.TcpConnection.run(TcpConnection.java:315)
at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:353)
at com.caucho.util.ThreadPool.run(ThreadPool.java:302)
at java.lang.Thread.run(Thread.java:534)

with either this code:

Image image = Toolkit.getDefaultToolkit().getImage(sc.getRealPath("/dlrImages/1000/")+images[x]);

or this:

Image image = new javax.swing.ImageIcon(sc.getRealPath("/dlrImages/1000/")+images[x]).getImage();
[ July 07, 2005: Message edited by: DC Dalton ]
 
Ranch Hand
Posts: 1211
Mac IntelliJ IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try -



You can find more by googling for Headless Linux.

Cheers.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep, and if you search his formum for the same you'll find a refernce to a jar I found which simulates the missing AWT classes.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic