You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Angelo Chen <an...@yahoo.com.hk> on 2008/03/31 10:21:28 UTC

t5: properties file location

Hi,

This question might not be absolutely Tapestry 5 related, here it is:

I have a Tapestry 5 application and I'd like to put a info.properties under
resources directory where log4j.properties is located, however if I access
it in the service with this code:

new FileInputStream("resources/m2.properties")

I got a "No such file or directory", what is the correct way of accessing
this file under a t5 service? Thanks.

Angelo


-- 
View this message in context: http://www.nabble.com/t5%3A-properties-file-location-tp16393437p16393437.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: t5: properties file location

Posted by Angelo Chen <an...@yahoo.com.hk>.
Hi Cordenier,

Thanks, root path works.  there is a 'resources' under src/main, but when
package with maven, there is no resources in the final jar, log4j.properties
and m2.properites all go to the root. 

Angelo


Cordenier Christophe wrote:
> 
> Hello,
> 
> I think it is always preferable to refer to the root pat : "/"
> 
> A good way to access root class path may be something like this :
> 
> getClass().getResource("/resources/m2.properties"), there is also a
> getResourceAsStream("/resources/m2.properties") method to get and input
> stream from classpath. Note that in this case, you must have a "resources"
> directory under your classpath.
> 
> 

-- 
View this message in context: http://www.nabble.com/t5%3A-properties-file-location-tp16393437p16395304.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: t5: properties file location

Posted by Christian Edward Gruber <ch...@gmail.com>.
Yeah, you have to think of not /src/main as the root, but as /src/main/ 
*/ as multiple roots which, in the case of jars, for example, are  
merged into one location.  That's generally true of maven project  
layouts.

Christian.

On 31-Mar-08, at 05:50 , Angelo Chen wrote:
>
> Hi Cordenier,
>
> Thanks, root path works.  there is a 'resources' under src/main, but  
> when
> package with maven, there is no resources in the final jar,  
> log4j.properties
> and m2.properites all go to the root.
>
> Angelo
>
>
> Cordenier Christophe wrote:
>>
>> Hello,
>>
>> I think it is always preferable to refer to the root pat : "/"
>>
>> A good way to access root class path may be something like this :
>>
>> getClass().getResource("/resources/m2.properties"), there is also a
>> getResourceAsStream("/resources/m2.properties") method to get and  
>> input
>> stream from classpath. Note that in this case, you must have a  
>> "resources"
>> directory under your classpath.
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/t5%3A-properties-file-location-tp16393437p16395303.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: t5: properties file location

Posted by Angelo Chen <an...@yahoo.com.hk>.
Hi Cordenier,

Thanks, root path works.  there is a 'resources' under src/main, but when
package with maven, there is no resources in the final jar, log4j.properties
and m2.properites all go to the root. 

Angelo


Cordenier Christophe wrote:
> 
> Hello,
> 
> I think it is always preferable to refer to the root pat : "/"
> 
> A good way to access root class path may be something like this :
> 
> getClass().getResource("/resources/m2.properties"), there is also a
> getResourceAsStream("/resources/m2.properties") method to get and input
> stream from classpath. Note that in this case, you must have a "resources"
> directory under your classpath.
> 
> 

-- 
View this message in context: http://www.nabble.com/t5%3A-properties-file-location-tp16393437p16395303.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: t5: properties file location

Posted by Cordenier Christophe <Ch...@atosorigin.com>.
Hello,

I think it is always preferable to refer to the root pat : "/"

A good way to access root class path may be something like this :

getClass().getResource("/resources/m2.properties"), there is also a getResourceAsStream("/resources/m2.properties") method to get and input stream from classpath. Note that in this case, you must have a "resources" directory under your classpath.

Hope this helps

Cheers
Christophe

-----Message d'origine-----
De : Angelo Chen [mailto:angelochen960@yahoo.com.hk]
Envoyé : lundi 31 mars 2008 10:21
À : users@tapestry.apache.org
Objet : t5: properties file location


Hi,

This question might not be absolutely Tapestry 5 related, here it is:

I have a Tapestry 5 application and I'd like to put a info.properties under
resources directory where log4j.properties is located, however if I access
it in the service with this code:

new FileInputStream("resources/m2.properties")

I got a "No such file or directory", what is the correct way of accessing
this file under a t5 service? Thanks.

Angelo


--
View this message in context: http://www.nabble.com/t5%3A-properties-file-location-tp16393437p16393437.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org




Ce message et les pièces jointes sont confidentiels et réservés à l'usage exclusif de ses destinataires. Il peut également être protégé par le secret professionnel. Si vous recevez ce message par erreur, merci d'en avertir immédiatement l'expéditeur et de le détruire. L'intégrité du message ne pouvant être assurée sur Internet, la responsabilité du groupe Atos Origin ne pourra être recherchée quant au contenu de ce message. Bien que les meilleurs efforts soient faits pour maintenir cette transmission exempte de tout virus, l'expéditeur ne donne aucune garantie à cet égard et sa responsabilité ne saurait être recherchée pour tout dommage résultant d'un virus transmis.

This e-mail and the documents attached are confidential and intended solely for the addressee; it may also be privileged. If you receive this e-mail in error, please notify the sender immediately and destroy it. As its integrity cannot be secured on the Internet, the Atos Origin group liability cannot be triggered for the message content. Although the sender endeavours to maintain a computer virus-free network, the sender does not warrant that this transmission is virus-free and will not be liable for any damages resulting from any virus transmitted.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org