[Building Sakai] Implement UserDirectoryProvider - How to read properties file

Aaron Zeckoski aaronz at vt.edu
Sun Jul 19 01:00:52 PDT 2009


You are probably trying to load the file via spring or via
classloader.getresource and because of the sakai classloader
environment for components it is failing. This is because of a
disconnect between the classloader which spring is using to load the
files (shared) and the one which has the file (your component
classloader). Take a look at this class from Sakai entitybroker utils
as a way to get around the issue in spring:
https://source.sakaiproject.org/svn/entitybroker/trunk/utils/src/java/org/sakaiproject/entitybroker/util/spring/ResourceFinder.java

If you want to load the file from outside of the jar/classloader then
you can copy it yourself manually or use maven to copy it when your
project is built. Then you just use typical java/spring stuff (nothing
related to sakai) to load up the properties file.

If you are not familiar with loading files (property or otherwise)
this should help:
http://www.rgagnon.com/javadetails/java-0434.html

Finally, if you want to load from a URL try something like this:
http://java.sun.com/docs/books/tutorial/networking/urls/readingURL.html

Hope that helps
-AZ


On Sun, Jul 19, 2009 at 5:47 AM, Phuc Bui<phucbui2006 at yahoo.com.vn> wrote:
> Dear all,
>
> I have implemented UserDirectoryProvider to read data from external
> database.
>
> Now, I use a file properties to store database connection configuration.
>
> But I cannot read this file (always get FileNotFoundException)
>
> The location of this file is as following pictures
>
> http://i400.photobucket.com/albums/pp88/bmphuc/propertiesFileLocation.jpg
>
> Moreover, when I built it the properties file was included in file jar. How
> can we place it outside file jar, so that we can change to configuration ?
>
>
>
> Thanks,
>
> Looking for your replies
>
> Phuc Bui
>
>
>
> _______________________________________________
> sakai-dev mailing list
> sakai-dev at collab.sakaiproject.org
> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>
> TO UNSUBSCRIBE: send email to sakai-dev-unsubscribe at collab.sakaiproject.org
> with a subject of "unsubscribe"
>
>



-- 
Aaron Zeckoski (azeckoski (at) vt.edu)
Senior Research Engineer - CARET - University of Cambridge
https://twitter.com/azeckoski - http://www.linkedin.com/in/azeckoski
http://aaronz-sakai.blogspot.com/ - http://tinyurl.com/azprofile


More information about the sakai-dev mailing list