Forums Register Login

Writing to XML file in ejbStore()

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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 ]
+Pie Number of slices to send: Send
 

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.
Every time you till, you lose 30% of your organic matter. But this tiny ad is durable:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 570 times.
Similar Threads
java.util.Properties loadXMLFile()
create xml from xsd using xstream
Java Objects to XML
XML and properties file.
XML file based on DTD
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 15:21:55.