Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Writing to XML file in ejbStore()

 
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
 
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 ]
 
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.
 
To do a great right, do a little wrong - shakepeare. twisted little ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!