My understandings are -
- Classes in java.awt package create internal threads for some processing (not very sure which are such cases/classes). Also
- In J2EE, it is not at all recommended to create threads from the EJB container from the application program or any tool/library used to build the application logic.
Summing up these points - is it at all recomended to use java.awt packages from EJB container ?
Any point/clarification will be really helpful.
What are you trying to do here?
what in the world makes you to use AWT inside a container??@#$%
Specification says that EJB must not manage execution threads. It doesn't have matter wich way of thread management you are going to use.
Furthermore, using AWT within EJB tier is not a very good idea. This means that your EJB will not be able to work (and to compile) untill you have AWT libraries in the classpath for your server side (this is not always the case).
In the above, I assumed that you didn't want to manage AWT GUI from EJB. If you did, then you should consider changing design of your system.
Thanks for your reply.
Actually all I'm trying to do from the EJB (actually from MDB) is to call a report generation/content creation tool (Jasper Report - an open source tool) for creating a mail content. Further down the line I'm sending the mail using Java Mail API. The mail contet getting generated typiaclly contain 1/2 imgaes.
The Jasper Report tool is a content creation tool, which gives you back final content using XML based template and any data source. It can gives back content in different formats - HTML, PDF etc.
Now, to all my surprise, I suddenly found that this tool internally uses certain AWT classes for creating the content. The specific classes being used are -
Since we are already using this tool, I wanted to know whether there are any real hard in using these awt classes from EJB container.
Any furtheer suggestion/pointer would be really helpful
I'm not a big specialist in AWT. But from the most general point of view, I think you will not have problems (not taking into account classpath dependency on AWT library) even if AWT creates threads until you don't use those threads in your EJB code. If AWT uses its own threads internaly, it's ok.
But you may find problems if you are doing some job in AWT callbacks invoked by those additional threads. This may cause deadlocks and problems with security and transactions. This is because container usually accosiates security and transaction contexts with the threads it uses to serve clients requests. It cannot do this for threads created by AWT.