Hi,

You need to replace the "../../MyPropFolder/MyPropFolder.txt" with
"./MMyPropFolder/MyPropFolder.txt".

This should get it to work. The reason for the issues is that the resources
directory is already on the classpath if you built the project using Maven.

Hence your path sould be set with respect to the resources directory.

Hope this helps.

Cheers,

Ashwin...


[email protected] wrote:
> 
> Hi,
> 
> I have implemented a MessageExchangeListener to integrate my java class
> with servicemix.
> I have to access a property file from this class. The class file say
> MyListener is in package MyPackage.
> I created a folder called MyPropFolder in resources folder and inside
> MyPropFolder I have MyPropFile.txt
> The folder structure of source is as follows 
> MyBean
>       src
>               main
>                       java
>                               MyPackage
>                                       MyListener.java
>                       resources
>                               MyPropFolder
>                                       MyPropFile.txt
> 
> When I create a service assembly and see inside the zip archive created
> the structure looks as follows:
> MyBean.zip
>       MyPackage
>               MyListener.class
>       MyPropFolder
>               MyPropFile.txt
> 
> MyListener.class tries to access the property file as follows:
> BufferedReader in = new BufferedReader(new
> FileReader("../../MyPropFolder/MyPropFolder.txt"));
> 
> I get the following Exception
> java.io.FileNotFoundException: ..\..\MyPropFolder\MyPropFolder.txt (The
> system cannot find the path specified)
>         at java.io.FileInputStream.open(Native Method)
>         at java.io.FileInputStream.<init>(FileInputStream.java:106)
>         at java.io.FileInputStream.<init>(FileInputStream.java:66)
>         at java.io.FileReader.<init>(FileReader.java:41)
>         at MyPackage.MyListener.onMessageExchange(MyListener.java:61)
>         at
> org.apache.servicemix.bean.BeanEndpoint.onProviderExchange(BeanEndpoint.java:235)
>         at
> org.apache.servicemix.bean.BeanEndpoint.process(BeanEndpoint.java:211)
>         at
> org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:538)
>         at
> org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:490)
>         at
> org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLifeCycle.java:46)
>         at
> org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:610)
>         at
> org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:172)
>         at
> org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:167)
>         at
> org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134)
>         at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
>         at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
>         at java.lang.Thread.run(Thread.java:595)
>               
> What am I doing wrong? How do I read a file with relative URL?
> 
> 
> 


-----
--- 
Ashwin Karpe, Principal Consultant, PS - Opensource Center of Competence 
Progress Software Corporation
14 Oak Park Drive
Bedford, MA 01730
--- 
+1-972-304-9084 (Office) 
+1-972-971-1700 (Mobile) 
---- 
Blog: http://opensourceknowledge.blogspot.com/


-- 
View this message in context: 
http://www.nabble.com/Reading-file-with-relative-URL-from-Bean-tp21560027p21562099.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Reply via email to