-
1. Re: Custom action config file
tfennelly May 27, 2008 5:30 AM (in response to blep)How are you trying to open these resource? Does the actual .esb deployment contain these cfg resource in the location you identified?
-
2. Re: Custom action config file
blep May 27, 2008 5:44 AM (in response to blep)Yes I try : of course, if I open a stream with "/cfg/cfg1.xml" as , it attempts to open a file in c:/cfg/cfg1.xml and if I try to get it from resources loaded by the context class loader, it returns a null object.
I checked with an archive manager, the directory and the files are there. -
3. Re: Custom action config file
tfennelly May 27, 2008 6:00 AM (in response to blep)Please show us the actual code you're using to open a stream to the resource.
-
4. Re: Custom action config file
blep May 27, 2008 7:38 AM (in response to blep)My custom action is :
public class WrapSxmlESB extends AbstractActionLifecycle{ [...] //constructor public WrapSxmlESB(ConfigTree cfg) throws Exception{ log.info("Entering WrapSxmlESB"); resourcesHref = cfg.getAttribute("resourceRef"); log.info("configHref = " + configHref); InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(configHref); try{ log.info("available : " + is.available()); }catch (NullPointerException e) { log.info("Is null by context class loader!!!!!"); } try{ is = new FileInputStream(configHref); log.info("available : " + is.available()); }catch (FileNotFoundException e) { log.info("File not found by input stream!!!!!"); } log.info("Outing WrapSxmlESB"); } [...]
My jboss-esb.xml contains:[...] <action name="action2" class="com.thales.poc.servingxml.WrapSxmlESB"> <property name="resourceRef" value="/cfg/fic-resource.xml"/> <property name="configRef" value="/cfg/servingxml.xml"/> </action> [...]
The ESB archive :$ jar tf embed_servingxml.esb | grep cfg cfg/ cfg/FIC00002.txt cfg/fic-resource.xml cfg/out.xml cfg/servingxml.xml
The JBoss logs during deployment :13:23:44,682 INFO [JBoss4ESBDeployer] create esb service, embed_servingxml.esb 13:23:44,776 INFO [embed_servingxml] Bound to JNDI name: queue/embed_servingxml 13:23:44,823 WARN [ScheduleMapper] Attrubute 'poll-frequency-seconds' is DEPRECATED. Please change your configuration to use 'schedule-frequency'. 13:23:44,823 INFO [AbstractFileGateway] No value specified for: max-millis-for-response - This will be an 'inbound-only' gateway 13:23:44,854 INFO [WrapSxmlESB] Entering WrapSxmlESB 13:23:44,854 INFO [WrapSxmlESB] configHref = /cfg/servingxml.xml 13:23:44,854 INFO [WrapSxmlESB] Is null by context class loader!!!!! 13:23:44,854 INFO [WrapSxmlESB] File not found by input stream!!!!! 13:23:44,854 INFO [WrapSxmlESB] Outing WrapSxmlESB
I'm quite sure it's a newbie issue! -
5. Re: Custom action config file
tfennelly May 27, 2008 7:49 AM (in response to blep)Could be a scoping issue. Kev?
Have you tried using the class classloader i.e. just doing 'getClass().getResourceAsStream("/cfg/servingxml.xml")'? -
6. Re: Custom action config file
blep May 27, 2008 8:11 AM (in response to blep)It works!!
Why did I look for a complex way instead of using a simple one??
Thank you very much for your help. -
7. Re: Custom action config file
kconner May 27, 2008 9:54 AM (in response to blep)It shouldn't have been a scoping issue as the context classloader would have been initialised before the lifecycle was created.
Could you wrap this into a simple testcase and send it to me? I would like to understand what is going on. -
8. Re: Custom action config file
kconner May 29, 2008 3:29 PM (in response to blep)Sorry, should have spotted the reason for this.
When asking a classloader for a resource it should not start with a leading '/'. If you change your resource from /cfg/servingxml.xml to cfg/servingxml.xml then it will work correctly with the context classloader. -
9. Re: Custom action config file
blep May 30, 2008 7:29 AM (in response to blep)I just tried with the test case I sent you and it's exactly the same.
FYI -
10. Re: Custom action config file
kconner May 30, 2008 7:45 AM (in response to blep)Your test case had a bug in it, it was using the wrong method from Classloader.
You need to change the method to use getResourceAsStream instead of getSystemResourceAsStream.
The code you pasted here was correct though. -
11. Re: Custom action config file
blep May 30, 2008 8:18 AM (in response to blep)Right, I just checked.
Sorry for that!