Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Writing to XML file in ejbStore()

 
H. Samarasekera
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I'm aware that it's 'Illegal' to access the filesystem through EJBs (File I/O)! But my doubt is, is this NOT possible (throws exception) or does it simply reduces portability?

Is it possible to write to an XML file from an ejbStore() method?

Thanks in advance,
koluwa
 
Olivier Dumont
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Koluwa,

Welcome to JavaRanch and this forum!

You're right that, among other programming restrictions, the EJB specs state (bottom of page 494):

An enterprise bean must not use the java.io package to attempt to access files and directories
in the file system.

The file system APIs are not well-suited for business components to access data. Business components should use a resource manager API, such as JDBC, to store data.


Now using other APIs than the java.io package may lead you - indirectly - to access the file system anyway.

But the same specs on page 496 lists the APIs that the container must make available to the enterprise bean instances at runtime. And among them you find ... JAXP 1.0!

So I guess that what you need is achievable without breaking any EJB rule.

Regards,

Olivier.
[ August 25, 2004: Message edited by: Olivier Dumont ]
 
alzamabar
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by C. Koluwa:
Hi all,

I'm aware that it's 'Illegal' to access the filesystem through EJBs (File I/O)! But my doubt is, is this NOT possible (throws exception) or does it simply reduces portability?

Is it possible to write to an XML file from an ejbStore() method?

Thanks in advance,
koluwa


Using the IO package is 'legal' but affects portability across EJB 2.0 compliant containers. As regards XML, yes, you can use xml libraries (like DOM) in your ejb methods (it doesn't have to be a specific one). The reason is that DOM and (SAX??) are contained in the JAXP API, which is a guaranteed API for EJB 2.0 compliant servers.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic