Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Can exec shell command only once from EJB  RSS feed

 
Marcin Glowacki
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

i want to convert pdf -> jpg using imagemagick or gs from EJB. Point is that it is working only first time, for next ones output file is empty (0 bytes). To convert files i'm using:



I was previously using convert from imagemagick but it also works only once. I thought about using ghost4j but there are some issues running it on 64 bit java. I've tried both ProcessBuilder and apache commons exec with same results.

I'm running Glassfish 3.1.2.2 on Debian.

I'm trying to fix it for the second day and i'm a bit tired... thanks for helping!
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36406
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Marcin,
Welcome to CodeRanch!

EJBs aren't intended to make command line calls. That doesn't explain this problem, but it does suggest something to try. Try running the same code from a servlet (or java main method in a loop for that matter) and see if the problem goes away.
 
Marcin Glowacki
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, the problem was somewhere else (sorry for not closing thread) - the exec command was executed when new file was created in the directory. The directory listener run convert command in the moment that file was created. But the point was that while uploading files their initial size is 0 bytes. The listener fired event too early and the convert (gs) gave an error. Making additional condition (waiting for size != 0) solved the problem!

And now exec works fine from EJB.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!