JSLEE Discussions
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
How to read/refer external property/xml files
Forum Index » Rhino SLEE Discussions
Author Message
s.nagaraju


Joined: 02/03/2009 19:03:17
Messages: 51
Offline

Hi,

Is there any such similar way/procedure to refer property files as we refer external libraries.

The situation is , my SBB refers an external jar which i included using the library component.
This library uses some property files.I made jar out of all the property/xml files which my external jar refers
and included in my library component.but it did not work.

I included the property files(with the file name) in the RUNTIME_CLASSPATH of the rhinostart.bat file.
They were not picked.

Please suggest , if i went wrong and if there is any other process of achieving the same.

Thanks in advance

Regards,
Nagaraju
bsd

[Avatar]

Joined: 22/03/2008 00:37:15
Messages: 355
Location: Cambridge, UK
Offline

Hi,

If you deploy those files in a component deployable jar, such as an SBB or library, they will be available in that component classloader. In your scenario you should include those files in the library component you created.

To access the files you should get the resource from the current classloader. See below.For more information, have a look at the following article and at this thread.

bruno

Bruno Duarte
Technical Consultant
OpenCloud
[Email] [WWW]
s.nagaraju


Joined: 02/03/2009 19:03:17
Messages: 51
Offline

Hi Bruno,

The code you suggested works fine for reading property files,
but i am unable to read xml files.

I tried the following ways

DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc1 = builder.parse(ClassLoader.getSystemClassLoader().getResourceAsStream("Mapping.xml"));
Document doc2 = builder.parse(CustomClassLoader.getInstance().getSystemClassLoader().getResourceAsStream("Mapping.xml"));
Document doc3 = builder.parse(new FileInputStream("Mapping.xml"));
Document doc4 = builder.parse(getClass().getClassLoader().getResourceAsStream("Mapping.xml"));


Some are throwing resource not found and some java.security.AccessControlException: access denied.The xml file is accesable and redable.


2) Put the needed xml in a jar and add it to the classpath in the following ways.

3) a. Added the jar to the CLASSPATH variable in the start-rhino.bat.
b. Add to the RUNTIME_CLASSPATH also.
c. Added our own variable USER_CLASSPATH and tried the following way too
%JAVA% %OPTIONS% -classpath %USER_CLASSPATH% com.opencloud.rhino.node.Rhino -n 101 -s -p -f file:config\rhino-config.xml

Even trying all the ways, the xml file is not being picked up. I even tried the option of adding the location of xml files to the classpath.


Note : when the CLASSPATH was edited, the web console stopped functioning.

Please suggest

Thanks in advance

This message was edited 1 time. Last update was at 25/03/2009 02:18:30


Regards,
Nagaraju
bsd

[Avatar]

Joined: 22/03/2008 00:37:15
Messages: 355
Location: Cambridge, UK
Offline

Hi,

You should avoid changing the runtime classpath of Rhino. If you want to deploy a library with any kind of files, you should use the library component instead (as we previously discussed). Have a look here. If you just want to make available some property files to a component, you can also include those files in that component jar (eg, SBB). Library components allow you to create services completely portable and independent from the SLEE. This is also needed to easier support online upgrade scenarios.

The correct way to read the resource is "doc4" because you want to get it from the current classloader or from any of the parents classloaders.

Could you please try with a library component and with a fresh installation of Rhino?

bruno

Bruno Duarte
Technical Consultant
OpenCloud
[Email] [WWW]
s.nagaraju


Joined: 02/03/2009 19:03:17
Messages: 51
Offline

Hi Bruno,

I already tried with the library component.The xml file was not picked.

This time, as suggested, i tried the same with a fresh installation of Rhino.
Even this did not work.

DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc4 = builder.parse(getClass().getClassLoader().getResourceAsStream("Mapping.xml"));


The following error occured

document builder
java.lang.IllegalArgumentException: InputStream cannot be null
as it is not able to find the xml file.

----------------------------------------------------

As a seperate note,
We observed that the web console stopped functioning when the CLASSPATH in start-rhino.bat was edited.
We are able to everything using ant scripts.
Do we have any restrictions for this ?

Thanks in advance

Regards,
Nagaraju
bsd

[Avatar]

Joined: 22/03/2008 00:37:15
Messages: 355
Location: Cambridge, UK
Offline

Hi,

In a previous thread you mentioned how you were able to read text files. You should use the same approach to read XML files. The type of the file doesn't really matter.

The article How do I diagnose class loading problems? has a very good overview of how to understand the classloader hierarchy.

Could you please describe in as much detail as possible: which DUs you have, in which component is the resource you want to access and from what component you are trying to access it?

On the side note, by updating the Rhino runtime classpath you may have created some libraries inconsistency and, as a result, break the web console. What were your changes and what error are you getting?

Bruno

Bruno Duarte
Technical Consultant
OpenCloud
[Email] [WWW]
s.nagaraju


Joined: 02/03/2009 19:03:17
Messages: 51
Offline

Hi Bruno,

This is to explain my DU structure in detail.

I have an SBB DU for all the open cloud related things.This access business logic methods from a different jar which is deployed as a library component.

In the library component i have the business logic jar (business.jar) , the jar with only the XML files in it (xml.jar) and all the other dependent jars necessary for the business logic jar.

It is the business.jar that tries to access the XMl files from the xml.jar

Note: The business.jar is successfully referring to the other dependent jars in the library unit

Note: I also tried creating a different library component with only the xml.jar in it and referring it from the first library component.


Regarding the webconsole,
I haven't added anything that would conflict with other libraries and create inconsistency.I added only the xml.jar to the classpath.
I even tried adding the .xml file to the CLASSPATH.

I even tried adding my own variable without disturbing the CLASSPATH and used that variable while starting RHINO.

The error i get when i access the webconsole is
FATAL ERROR: 'Could not compile stylesheet'
2009-03-30 11:12:28.299 ERROR [rhino.management.web] <btpool0-3> Uncommitte
d response, returning error page.


Regards,
Nagaraju
bsd

[Avatar]

Joined: 22/03/2008 00:37:15
Messages: 355
Location: Cambridge, UK
Offline

Hi Nagaraju,

From your description it seems to be everything ok.

Please attach to this thread or send to our support email address the complete source code (and built DUs).

Regarding the webconsole, it seems you're using Rhino version 1.4.5 and Java 6, which is not supported. Please upgrade Rhino to 2.0 or downgrade Java to 1.5.

Bruno

Bruno Duarte
Technical Consultant
OpenCloud
[Email] [WWW]
 
Forum Index » Rhino SLEE Discussions
Go to:   
Powered by JForum 2.1.8 © JForum Team