Load property file in init(PortletConfig) method of JSR 286 portlet

I store my configuration in .properties file. Now I want to load this file only once, so I decided to load it in init(poerletConfig) method. But now I'm confused to where to put this file, so it can be loaded in this method. I'm using following code:
Properties properties = new Properties();
try {
properties.load(new FileInputStream("which_path_to_give_here")); // not sure where to put property file and how/which path to give here?
} catch (IOException e) {
     System.out.println(e.getMessage());
}

Friend i think you are trying to reinvent the wheel again...
To my knowledge liferay provides a utility class for FileUpload by default.
Guess U need to add portlet-ear.jar along with the application you programme.
Hope you could have seen admin portlet already where we would upload company logo.. hope you remeber tht....
I've Posted the code behind(ActionClass) it in the below post
http://forum.java.sun.com/thread.jspa?threadID=5160308&messageID=9610263#9610263
it would be great if you can make use of StrutsPortlet class provided by liferay and configure your porlet.xml accordingly & then write an PortletAction class & then create its action mapping in struts-config.xml.
and the reason why i'm stressing with that approach was sometimes The FileUpload Components may not be compatible different Portlet Containers
Hope that might help :)
and a small advice liferay does have their devoloper zone where you have user communities.Im sure you might get a better reply from their side too.
REGARDS,
RaHuL

Similar Messages

  • Loading property files from a class and not a servlet...

    Hi, I was wondering if anyone has a good solution for loading property files from a class instead of a servlet. I would like to load the property file similarly to how it is done from HttpServlet.
    Here is the large picture. I have a tag library that calls a class which needs to access a database. The class needs to know what DB to access so it needs to look at some property file. The problem is that I don't want to hardcode the properties or the path of where the property file exists. I hope this all makes sense.
    Thanks.
    -PV

    I use the getResource method in the java.lang.Class class. Read about this method in the api.
    Anyways this is roughly how it's : you must put your properties file in the classpath. Then in your class :
    Properties prop = new Properties();
    URL url = this.getClass().getResource("/config/db.properties");
    prop.load(url.openStream());In this case, you must put the "config" (where you've written your db.properties file) directory's parent in the classpath.

  • How do I load property files and images stored in the jar file?

    Hi
    So, if I have a structure like this:
    /com.myfirm.myproject.SomeClass
    /images/
    /properties/
    And I pack this structure into a jar file, how do I then access the images under "/images/" and the property files under "/properties/"? A link to a good tutorial on this would be perfect, or a description/hint/howto :)

    Im having problems even loading direcly from the directory..? I have this structure:
    src (source dir)
    classes (classes dir)
    lang/textRb_en_US.properties (the file I want to load)
    Then I have this code:
    Locale currentLocale = new Locale("en", "US");
    ResourceBundle textRb = ResourceBundle.getBundle("/lang/textRb", currentLocale);But it gives me a "java.util.MissingResourceException: Can't find bundle for base name /lang/textRb, locale en_US". I start my application from within Eclipse, and I have tried to move "lang/textRb_en_US.properties" into the classes dir, but same error.
    Im confused as to there Java looks for ressources, and I need this to work no matter where I put my classes/jar. Could you help me out here?

  • Best practice for property file

    I am trying one small code which uses values from property file.
    public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, java.io.IOException
          InputStream inputStream = servletContext.getResourceAsStream(/WEB-INF/test.properties);
          PrintWriter out         = response.getWriter();
           Properties prop = new Properties();
           prop.load(inputStream);
           inputStream.close();
          String nameprop = prop.getProperty("name");
          out.println(nameprop);
       }I am getting the value from property file, It's perfectly ok as far as test code is concerned. Above will open the inputStream for each thread, which is not needed so i modified it and put in inside init() method. That is also working, i believe this will give me some better performance.
    But can i extend it further? I load property file at application level and all my servlets make use of it?
    What is normal practice to read property file to get good performance? I serached forum, i found some info there but could not figure out exactly how people are doing it.
    Thanks in advance,
    regards
    Manisha

    Thanks to all posters,
    As mentioned by duffymo, I tried some code which i tested on my m/c and working fine. But just want to confirm, what i understood and wrote is correct.
    I wrote 1st servlet to get the property file and store into servlet context, 2nd servlet is just to test it.
    1st Servlet:
    package common;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    public class TestPropertyfiles_1 extends HttpServlet
    public void init(ServletConfig config) throws ServletException
       super.init(config);
       try{
            String PF_PATH = "/WEB-INF/test.properties";
            Properties prop = new Properties();
                            InputStream inputStream = config.getServletContext().getResourceAsStream(PF_PATH);
           prop.load(inputStream);
           inputStream.close();
           getServletContext().setAttribute("pf", prop);
       }catch(Exception e){}
    public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, java.io.IOException
            PrintWriter out         = response.getWriter();
            Properties tmpprop = (Properties) getServletContext().getAttribute("pf");
            String nameprop = tmpprop.getProperty("name");     
                out.println("name from property file" + nameprop);     
    }2nd servlet:
    package common;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    public class TestPropertyfiles_2 extends HttpServlet
         public void init(ServletConfig config) throws ServletException
            super.init(config);
    public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, java.io.IOException
            PrintWriter out         = response.getWriter();
            Properties tmpprop = (Properties) getServletContext().getAttribute("pf");
            String nameprop = tmpprop.getProperty("name");
                            out.println("name from property file - no 2" + nameprop);
    }This was initially giving problem if I access 2nd servlet first before accessing 1st servlet. I did some changes inside web.xml
    <servlet>
    <servlet-name>common.TestPropertyfiles_1</servlet-name>
    <servlet-class>common.TestPropertyfiles_1</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    And then all was ok.
    One thing came to my mind. I can have one common servlet just for all initialisation, this will not have any doGet/doPost.
    regards
    Manisha

  • Load xml file data in oracle 9i table

    Hi,
    I have oracle 9i R2 (9.2.0.8) and currently i am loading data using sql*loader as i am getting text file. I will be getting file in XML format shortly.
    I would like tp know if there is a sql*loader way to load xml file or another easy method that i can use it?
    If you can provide me very simplest way, i will really appreciate it.
    Thanks,

    Please refer
    http://download-uk.oracle.com/docs/cd/B12037_01/appdev.101/b10790/xdb25loa.htm

  • Load html errors undefined property File

    in the following code take 4 errors on 2 bold lines
    mdapp, Layer 'inputpage', Frame 1, Line 25 1046: Type was not found or was not a compile-time constant: File.
    mdapp, Layer 'inputpage', Frame 1, Line 26 1046: Type was not found or was not a compile-time constant: File.
    mdapp, Layer 'inputpage', Frame 1, Line 25 1120: Access of undefined property File.
    mdapp, Layer 'inputpage', Frame 1, Line 26 1120: Access of undefined property File.
    //Copy the html file outside the app directory
    var templateFile:File = File.applicationDirectory.resolvePath( "adview.html" );
    var workingFile:File = File.createTempFile();
    templateFile.copyTo( workingFile, true );
    try
        webView.loadURL( workingFile.url );
    where is my fault?

    applicationDirectory is used for files you package with your app. If you downloaded or generated the file then you might want applicationStorageDirectory.
    You also should check the .exists property before trying to do anything with a file.
    templateFile:File = File.applicationDirectory.resolvePath( "adview.html" );
    if (templateFile.exists)
        // exists, do stuff
    else
         trace('oops file does not exist');
    Never try to save to applicationDirectory either, use applicationStorageDirectory or one of the other temp cache paths in the documentation.

  • Loading jar files at execution time via URLClassLoader

    Hello�All,
    I'm�making�a�Java�SQL�Client.�I�have�practicaly�all�basic�work�done,�now�I'm�trying�to�improve�it.
    One�thing�I�want�it�to�do�is�to�allow�the�user�to�specify�new�drivers�and�to�use�them�to�make�new�connections.�To�do�this�I�have�this�class:�
    public�class�DriverFinder�extends�URLClassLoader{
    ����private�JarFile�jarFile�=�null;
    ����
    ����private�Vector�drivers�=�new�Vector();
    ����
    ����public�DriverFinder(String�jarName)�throws�Exception{
    ��������super(new�URL[]{�new�URL("jar",�"",�"file:"�+�new�File(jarName).getAbsolutePath()�+"!/")�},�ClassLoader.getSystemClassLoader());
    ��������jarFile�=�new�JarFile(new�File(jarName));
    ��������
    ��������/*
    ��������System.out.println("-->"�+�System.getProperty("java.class.path"));
    ��������System.setProperty("java.class.path",�System.getProperty("java.class.path")+File.pathSeparator+jarName);
    ��������System.out.println("-->"�+�System.getProperty("java.class.path"));
    ��������*/
    ��������
    ��������Enumeration�enumeration�=�jarFile.entries();
    ��������while(enumeration.hasMoreElements()){
    ������������String�className�=�((ZipEntry)enumeration.nextElement()).getName();
    ������������if(className.endsWith(".class")){
    ����������������className�=�className.substring(0,�className.length()-6);
    ����������������if(className.indexOf("Driver")!=-1)System.out.println(className);
    ����������������
    ����������������try{
    ��������������������Class�classe�=�loadClass(className,�true);
    ��������������������Class[]�interfaces�=�classe.getInterfaces();
    ��������������������for(int�i=0;�i<interfaces.length;�i++){
    ������������������������if(interfaces.getName().equals("java.sql.Driver")){
    ����������������������������drivers.add(classe);
    ������������������������}
    ��������������������}
    ��������������������Class�superclasse�=�classe.getSuperclass();
    ��������������������interfaces�=�superclasse.getInterfaces();
    ��������������������for(int�i=0;�i<interfaces.length;�i++){
    ������������������������if(interfaces[i].getName().equals("java.sql.Driver")){
    ����������������������������drivers.add(classe);
    ������������������������}
    ��������������������}
    ����������������}catch(NoClassDefFoundError�e){
    ����������������}catch(Exception�e){}
    ������������}
    ��������}
    ����}
    ����
    ����public�Enumeration�getDrivers(){
    ��������return�drivers.elements();
    ����}
    ����
    ����public�String�getJarFileName(){
    ��������return�jarFile.getName();
    ����}
    ����
    ����public�static�void�main(String[]�args)�throws�Exception{
    ��������DriverFinder�df�=�new�DriverFinder("D:/Classes/db2java.zip");
    ��������System.out.println("jar:�"�+�df.getJarFileName());
    ��������Enumeration�enumeration�=�df.getDrivers();
    ��������while(enumeration.hasMoreElements()){
    ������������Class�classe�=�(Class)enumeration.nextElement();
    ������������System.out.println(classe.getName());
    ��������}
    ����}
    It�loads�a�jar�and�searches�it�looking�for�drivers�(classes�implementing�directly�or�indirectly�interface�java.sql.Driver)�At�the�end�of�the�execution�I�have�found�all�drivers�in�the�jar�file.
    The�main�application�loads�jar�files�from�an�XML�file�and�instantiates�one�DriverFinder�for�each�jar�file.�The�problem�is�at�execution�time,�it�finds�the�drivers�and�i�think�loads�it�by�issuing�this�statement�(Class�classe�=�loadClass(className,�true);),�but�what�i�think�is�not�what�is�happening...�the�execution�of�my�code�throws�this�exception
    java.lang.ClassNotFoundException:�com.ibm.as400.access.AS400JDBCDriver
    ��������at�java.net.URLClassLoader$1.run(URLClassLoader.java:198)
    ��������at�java.security.AccessController.doPrivileged(Native�Method)
    ��������at�java.net.URLClassLoader.findClass(URLClassLoader.java:186)
    ��������at�java.lang.ClassLoader.loadClass(ClassLoader.java:299)
    ��������at�sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
    ��������at�java.lang.ClassLoader.loadClass(ClassLoader.java:255)
    ��������at�java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
    ��������at�java.lang.Class.forName0(Native�Method)
    ��������at�java.lang.Class.forName(Class.java:140)
    ��������at�com.marmots.database.DB.<init>(DB.java:44)
    ��������at�com.marmots.dbreplicator.DBReplicatorConfigHelper.carregaConfiguracio(DBReplicatorConfigHelper.java:296)
    ��������at�com.marmots.dbreplicator.DBReplicatorConfigHelper.<init>(DBReplicatorConfigHelper.java:74)
    ��������at�com.marmots.dbreplicator.DBReplicatorAdmin.<init>(DBReplicatorAdmin.java:115)
    ��������at�com.marmots.dbreplicator.DBReplicatorAdmin.main(DBReplicatorAdmin.java:93)
    Driver�file�is�not�in�the�classpath�!!!�
    I�have�tried�also�(as�you�can�see�in�comented�lines)�to�update�System�property�java.class.path�by�adding�the�path�to�the�jar�but�neither...
    I'm�sure�I'm�making�a/some�mistake/s...�can�you�help�me?
    Thanks�in�advice,
    (if�there�is�some�incorrect�word�or�expression�excuse�me)

    Sorry i have tried to format the code, but it has changed   to �... sorry read this one...
    Hello All,
    I'm making a Java SQL Client. I have practicaly all basic work done, now I'm trying to improve it.
    One thing I want it to do is to allow the user to specify new drivers and to use them to make new connections. To do this I have this class:
    public class DriverFinder extends URLClassLoader{
    private JarFile jarFile = null;
    private Vector drivers = new Vector();
    public DriverFinder(String jarName) throws Exception{
    super(new URL[]{ new URL("jar", "", "file:" + new File(jarName).getAbsolutePath() +"!/") }, ClassLoader.getSystemClassLoader());
    jarFile = new JarFile(new File(jarName));
    System.out.println("-->" + System.getProperty("java.class.path"));
    System.setProperty("java.class.path", System.getProperty("java.class.path")+File.pathSeparator+jarName);
    System.out.println("-->" + System.getProperty("java.class.path"));
    Enumeration enumeration = jarFile.entries();
    while(enumeration.hasMoreElements()){
    String className = ((ZipEntry)enumeration.nextElement()).getName();
    if(className.endsWith(".class")){
    className = className.substring(0, className.length()-6);
    if(className.indexOf("Driver")!=-1)System.out.println(className);
    try{
    Class classe = loadClass(className, true);
    Class[] interfaces = classe.getInterfaces();
    for(int i=0; i<interfaces.length; i++){
    if(interfaces.getName().equals("java.sql.Driver")){
    drivers.add(classe);
    Class superclasse = classe.getSuperclass();
    interfaces = superclasse.getInterfaces();
    for(int i=0; i<interfaces.length; i++){
    if(interfaces[i].getName().equals("java.sql.Driver")){
    drivers.add(classe);
    }catch(NoClassDefFoundError e){
    }catch(Exception e){}
    public Enumeration getDrivers(){
    return drivers.elements();
    public String getJarFileName(){
    return jarFile.getName();
    public static void main(String[] args) throws Exception{
    DriverFinder df = new DriverFinder("D:/Classes/db2java.zip");
    System.out.println("jar: " + df.getJarFileName());
    Enumeration enumeration = df.getDrivers();
    while(enumeration.hasMoreElements()){
    Class classe = (Class)enumeration.nextElement();
    System.out.println(classe.getName());
    It loads a jar and searches it looking for drivers (classes implementing directly or indirectly interface java.sql.Driver) At the end of the execution I have found all drivers in the jar file.
    The main application loads jar files from an XML file and instantiates one DriverFinder for each jar file. The problem is at execution time, it finds the drivers and i think loads it by issuing this statement (Class classe = loadClass(className, true);), but what i think is not what is happening... the execution of my code throws this exception
    java.lang.ClassNotFoundException: com.ibm.as400.access.AS400JDBCDriver
    at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:140)
    at com.marmots.database.DB.<init>(DB.java:44)
    at com.marmots.dbreplicator.DBReplicatorConfigHelper.carregaConfiguracio(DBReplicatorConfigHelper.java:296)
    at com.marmots.dbreplicator.DBReplicatorConfigHelper.<init>(DBReplicatorConfigHelper.java:74)
    at com.marmots.dbreplicator.DBReplicatorAdmin.<init>(DBReplicatorAdmin.java:115)
    at com.marmots.dbreplicator.DBReplicatorAdmin.main(DBReplicatorAdmin.java:93)
    Driver file is not in the classpath !!!
    I have tried also (as you can see in comented lines) to update System property java.class.path by adding the path to the jar but neither...
    I'm sure I'm making a/some mistake/s... can you help me?
    Thanks in advice,
    (if there is some incorrect word or expression excuse me)

  • Read from a property file which is in a zip

    I have the problem, that I can�t read a property file in a zip. A class which I ca get in the same zip needs this property to init.
    I call this in a batchfile.
    The message is like:
    c:/xx/core.zip!/com/xx/Prop.properties
    Path of the zip Path of the Property in zip
    Syntax or name or path are not correct.
    Where is the problem?
    Thanks in advance
    Frank

    hm, am not sure I follow but
    it is not possible to instantiate the class. I only use this class. >Java will find the class in the same zip and path, but the property->File will not be loaded while a FileInputStream wonts to open it.FileInputStream can't be used to open a zipped file, you can get an InputStream from the ressources variable by using URL.openStream method and feed this into Properties.load
    if you post some code here that you are able to change, then people might be able to help more :)
    asjf

  • Modifying property file at run time

    Hi all..
    I have been using properties file for handling few configurations in my project.
    whenever i need a change in the file, i had to change it in corresponding file, create a jar file and then introspect it into project and then publish the project.
    Is there any other way of achieving it.... can we modify the property file at run time just like we do for JSP pages...
    Or any other better way of doing this.. pls suggest..
    (am using 10g OBPM)
    Have a nice time...
    Regds,
    Viswanath

    Sharma,
    write a java class that reads a property file from the external path. make the jar file non-versionable in case you need to update that later. if you are on J2ee container all you need to do it drop the file @ domain root and u shd be good to go.
    sample code I am doing this for log4j.properties and application propertied.
    public class BPMLoggerUtil {
         // Initializing the default Logger //
         private static Logger logger = null;
         private static final String DEFAULT_PATH = "resources/log4j.properties";
         private static HashMap map = new HashMap();
         * This is the init method
         * @param propertyPath
         public static void init(String propertyPath){
              try {
                   if((logger = (Logger) map.get(propertyPath)) == null){
                        Properties properties = new Properties();
                        properties.load(LoggerUtil.class.getClassLoader().getResourceAsStream(propertyPath));
                        PropertyConfigurator.configure(properties);
                        logger = Logger.getLogger(PropertiesHelper.getProperty("resources.test", "AppName"));
                        map.put(propertyPath, logger);
              } catch(Exception ex) {
                   ex.printStackTrace();
         }

  • FILENOTFOUNDEXCEPTION while reading property files in Tomcat 6------Help me

    Hi All
    I am planning to migrate my web application from iplanet 4.1 to tomcat 6. In this process I need to read the properties files initially.
    for eg: i got the property files in a iPlanet:
    Config directory---
    abc.properties.---
    abc.log--
    In tomcat I configured them in web.xml saying that.
    <servlet>
    <servlet-name>ABC</servlet-name>
    <servlet-class>com.ijk.abc</servlet-class>
    <init-param>
    <param-name>Loan</param-name>
    <param-value>/WEB-INF/config</param-value>
    </init-param>
    <init-param>
    <param-name>loan.props</param-name>
    <param-value>/WEB-INF/config/abc.props</param-value>
    </init-param>
    <init-param>
    <param-name>loan.log</param-name>
    <param-value>/WEB-INF/config/abc.log</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>ABC</servlet-name>
    <url-pattern>/</url-pattern>
    </servlet-mapping>
    I need to read initially all the property files and then proceed.
    While configuring in this way, it am getting error saying that
    abc.props or abc.log..............(FILE NOT FOUND EXCEPTION)
    Can anyone suggest me how to configure them.
    Thanks in Advance.

    Thanks for your response, Actually we dont have the source code for that because it is very old code, but i m using decompiler in which i can get some informtaion.
    OS used for iPlanet is Unix but now I need to deploy this application in tomcat in windows server 2003.
    Servlet clss:
    SERVLET CLASS:
    Class com.ijk.abc implements extends HttpServlet  implements PropertyKeys
    private IClickManager m_im;
    public void init(ServletConfig paramServletConfig)
        throws ServletException
        Utils.info("Servlet initialization");
        try {
          super.init(paramServletConfig);
          Utils.info("ServerInfo: " + getServletContext().getServerInfo());
          PGroup localPGroup = this.m_im.claimPG();
          Utils.trace("Got " + localProcessorGroup + " for initialization");
          this.m_im.gatherProperties(localProcessorGroup);-----------this is where it is calling the property files.
          this.m_im.freePG(localPGroup);
          Utils.trace("Released " + localPGroup + " for new Properties");
          localPGroup = this.m_im.claimPG();
          Utils.trace("Got " + localPGroup + " for new Properties");
          try
            ConHandler localDBHandler = (ConHandler)localPGroup.getDBHandler("config.dbhandler");
            this.m_im.setNumPGs(localDBHandler.getNumPGroups());
          catch (Exception localException1) {
            Utils.info("NON FATAL ERROR: failed to set number of PGs", localException1);
          try
            Session.createAndStartSessionTask(localPGroup);
            localPGroup.resumeAllTasks();
          catch (Exception localException2) {
            Utils.info("NON FATAL ERROR: failed to start tasks", localException2);
          this.m_im.freePG(localPGroup);
          Utils.trace("Released " + localPGroup + " for initialization");
          Utils.info("Servlet initialization finished");
        catch (FatalServletError localFatalServletError) {
          Utils.error("FatalServletError: ", localFatalServletError);
          throw new UnavailableException(this, localFatalServletError.toString());
        catch (Error localError) {
          Utils.error("Error: ", localError);
          throw localError;
    ==========================================================
    public void gatherProperties(ProcessorGroup paramProcessorGroup)
        Object localObject;
        this.m_props.clear();
        String str1 = this.m_servlet.getInitParameter("loan.dir");
        if (str1 == null) {
          str1 = System.getProperty("server.root", System.getProperty("user.dir", "."));
        this.m_props.put("loan.dir", str1);
        String str2 = this.m_servlet.getInitParameter("abc.log");
        setLogFile(str2);
        try
          String str3 = this.m_servlet.getInitParameter("abc.props");
          if (str3 == null)
            str3 = "abc.props";
          localObject = str1 + File.separator + str3;
          Utils.info("Reading properties from file: " + ((String)localObject));
          Utils.loadProperties(this.m_props, new BufferedInputStream(new FileInputStream((String)localObject)));
        catch (IOException localIOException) {
          Utils.info("NON FATAL WARNING: Could not read props file", localIOException);--while running i m getting this error
        Utils.info("Reading properties from Servlet Parameters");
        Enumeration localEnumeration = this.m_servlet.getInitParameterNames();
        while (localEnumeration.hasMoreElements()) {
          localObject = (String)localEnumeration.nextElement();
          this.m_props.put(localObject, this.m_servlet.getInitParameter((String)localObject));
        Utils.info("Reading properties from DB");
        try {
          localObject = (ConDBHandler)paramProcessorGroup.getDBHandler("config.dbhandler");
          String str5 = ((ConDBHandler)localObject).getPropertiesFile();
          Utils.loadProperties(this.m_props, new ByteArrayInputStream(str5.getBytes()));
        catch (Exception localException) {
          Utils.info("NON FATAL WARNING: Could not read props file", localIOException);--while running i m getting this error
        String str4 = this.m_props.getProperty("smtp.host");
        if (str4 != null) MailUtils.setSMTPHost(str4.trim());
        if (str2 == null) {
          str2 = this.m_props.getProperty("abc.log");
          setLogFile(str2);
         runInitializers(paramPGroup);
        Utils.info("New Properties:", this.m_props);
        this.m_rroots = StringUtils.getPathsFromList(this.m_props.getProperty("resource.path", "/com/loan/resources/:/"));
        clearAllPGs();
    =================================================================
    the above is the servlet class and the method which is using to read the property files from root directory in Unix.
    ie../opt/mywebapp/loan/abc.props,abc.log
    loan is the directory in which two property files are placed.
    i just want to where to place property files in tomcat so that its going to read the property files.
    Right now, i placing it in the WEBAPPS/MYWEBAPPLICATION/WEB-INF/LOAN/abc.props,abc.logs.
    Its giving me errors such as FILENOTFOUNDEXCEPTION or cannot read the property files.
    The main problem is ...I donot have the complete source code. while decompiling i m not able view complete source code.
    Please help me regarding this.........
    Thanks in advance.

  • JSP Registry could not locate runtime property file

              At runtime, my JSP is throwing an exception claiming to be not able to find the property
              file. I have found the exact property file in the jar located on the server. I've
              tried extracting it and placing it in different places and adding the file and directory
              to the WebLogic classpath. I'm not sure what else to try.
              Here's the exception:
              Loading from CLASSPATH cat_test4_cat_pkg_Cat_pkgModule.properties
              java.lang.RuntimeException: JSP Registry could not locate runtime property file:
              cat_test4_cat_pkg_Cat_pkgModule.properties
              at java.lang.Throwable.fillInStackTrace(Native Method)
              at java.lang.Throwable.fillInStackTrace(Compiled Code)
              at java.lang.Throwable.<init>(Compiled Code)
              at java.lang.Exception.<init>(Compiled Code)
              Thanks.
              

    When you generate a webapp or use the JSP element wizard , a property file is created for you that contains some startup parameters. This file needs to be available in the classpath. This errors comes up becuase the file is not avalable in the classpath.

  • Urgent - Servlet with Property file

    Hi all,
    I have a servlet which ueses a property file to get the Database information such as Driver, URL etc. The content of the property file is
    dbDriver=sun.jdbc.odbc.JdbcOdbcDriver
    dbDSN=jdbc:odbc:Sundar
    dbUser=
    dbPassword=
    The servlet has the following code to get connection with the DB
    Connection con;
    Statement stmt;
         String s = null;
         String dbDriver="";
         String dbDSN="";
         String dbUser="";
         String dbPassword="";     
         public void init()
         try {
    String propsfilename = "db.props";
    InputStream is = getClass().getResourceAsStream("/" + propsfilename);
         Properties p = new Properties();
         p.load(is);
         dbDriver = p.getProperty("dbDriver");
         dbDSN = p.getProperty("dbDSN");
         dbUser = p.getProperty("dbUser");
         dbPassword = p.getProperty("dbPassword");
    } catch (Exception e) {
              throw new RuntimeException("UNABLE TO INITIALIZE, EXITING...");
    public String DataBaseConnection()
         init();          
    try
         Class.forName(dbDriver);               
         con = DriverManager.getConnection(dbDSN,dbUser,dbPassword);
    stmt = con.createStatement();
    catch (ClassNotFoundException e1)
    e1.printStackTrace();
    catch (SQLException e2)
    e2.printStackTrace();
    The following exception is thrown when i access the servlet through the browser.
    java.lang.ClassNotFoundException: sun/jdbc/odbc/JdbcOdbcDriver
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Class.java:120)
         at DataTrans.DataBaseTrans.DataBaseConnection(DataBaseTrans.java:52)
         at sitespider.searchlinks(sitespider.java:207)
         at sitespider.doGet(sitespider.java:42)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
         at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1013)
         at allaire.jrun.servlet.JRunSE.runServlet(../servlet/JRunSE.java:925)
         at allaire.jrun.servlet.JRunNamedDispatcher.forward(../servlet/JRunNamedDispatcher.java:34)
         at allaire.jrun.servlet.Invoker.service(../servlet/Invoker.java:84)
         at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1013)
         at allaire.jrun.servlet.JRunSE.runServlet(../servlet/JRunSE.java:925)
         at allaire.jrun.servlet.JRunRequestDispatcher.forward(../servlet/JRunRequestDispatcher.java:88)
         at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1131)
         at allaire.jrun.servlet.JvmContext.dispatch(../servlet/JvmContext.java:330)
         at allaire.jrun.jrpp.ProxyEndpoint.run(../jrpp/ProxyEndpoint.java:382)
         at allaire.jrun.ThreadPool.run(../ThreadPool.java:272)
         at allaire.jrun.WorkerThread.run(../WorkerThread.java:75)
    I am using the following servers
    IIS 5.0 with JRun 3.1
    Adv tanx
    Sundar

    Hi
    I tested your code . The problem is that the property file have some spaces after the string. Use The trim(); function or check the blank spaces in the property file.
    hope it will help
    Mallesh

  • Applet can't Load a file from outside it's JAR??

    My loading code: (note: I have also tried ...getResourceAsStream("menu.properties");... )
    codeBase = getCodeBase();
    InputStream is = getClass().getResourceAsStream( new URL( codeBase, "menu.properties" ).toString() );
    if( is == null )
      System.err.println( "Couldn't load Menubar property file:: " + new URL( codeBase, "menu.properties" ).toString());
    else this.properties.load( is );
    is is always null. When 'menu.properties' is inside the JAR that contains my applet class files it loads it with the direct method (getResourceAsStream("menu.properties");) and everything is good.... but when it is outside the JAR no dice.
    Anybody see what is wrong or know something I need to know before I can do this?
    Thanks alot,
    seth

    >
    My loading code: (note: I have also tried
    ...getResourceAsStream("menu.properties");.. )
    codeBase = getCodeBase();
    InputStream is = getClass().getResourceAsStream( new
    URL( codeBase, "menu.properties" ).toString() );
    if( is == null )
    System.err.println( "Couldn't load Menubar property
    y file:: " + new URL( codeBase, "menu.properties"
    ).toString());
    else this.properties.load( is );
    is is always null. When 'menu.properties' is
    inside the JAR that contains my applet class files it
    loads it with the direct method
    (getResourceAsStream("menu.properties");) and
    everything is good.... but when it is outside the JAR
    no dice.
    Anybody see what is wrong or know something I need to
    know before I can do this?
    Thanks alot,
    seth
    Solved my own problem:
    docBase = getDocumentBase();
    InputStream is = new URL( docBase, "menu.properties" ).openStream();

  • Character '\' is lost when reading a String from a property file.

    Hi all,
    I have encrypted information inside a property file, but when loading properties in my program, the String object used to store the value is changed by the lost of all �\� characters
    # EIS password saved in the property file
    password=WPLqQE0DlVF8Sg\=\=
    #Value loaded in my String object
    WPLqQE0DlVF8Sg==
    Why is this happening? I use java.util.Properties java class to store and load my properties, and it is supposed to do it with the same encoding (ISO 8859-1).
    Please, can someone explain me why this happened and how to solve it?
    Best regards.

          public static void main(String[] args) throws IOException {
               OutputStream props = new FileOutputStream("test.properties");
               Properties p = new Properties();
               p.put("password", "pass=word#is!dumb");
               p.put("user", "    I am a Dummy");
               p.store(props, "Java forum demo props file");
               props.close();
               /* Properties file after store
                * user=\    I am a Dummy
                * password=pass\=word\#is\!dumb
               Properties post = new Properties();
               post.load(new FileInputStream("test.properties"));
               for(Iterator it = post.entrySet().iterator(); it.hasNext();)
                System.out.println(it.next());
                * After load from test.properties
                * user=    I am a Dummy
                * password=pass=word#is!dumb
          }Notice that the special chars are only in the file, not actually in the props. If you think otherwise, I don't know what to say. The \ is a special character that is used to escape other special chars, including itself. You can't create a string in java containing only one backslash, as java assumes the next char is being escaped. when you create a string in Java with one backslash, you have to have 2 backslashes. If you are storing data in the property file using something other than store, than you need to ensure that you are escaping all special charachters that the store method does
    ~Tim

  • Updating Property File

    Hi, i want to update the property file which is in //web-inf//classes folder. i can load the file using getResourceAsStream() method. Is there any way to create the OutputStream for that property file?.
    Thanks in advance.

    Read the java.util.Properties API [1] and its tutorials [2] here at Sun.com.
    [1] http://www.google.com/search?q=java.util.Properties+api+1.5.0+site:sun.com
    [2] http://www.google.com/search?q=java.util.Properties+tutorial+site:sun.com
    There is a store() method.

Maybe you are looking for

  • Photo fails to open when I click on a thumbnail. Why?

    Many photos which are visible in a thumbnail - from an Event - will not open. Instead I get a black screen, on which is a black/grey exclamation mark. The date is visible but not the image. Why is this and what can I do?

  • ECC to CRM Mapping Issue for vendor data

    Hi, I am facing an issue for replicating vendor data from ECC to CRM. One of the vendor is not confirmed at ECC side and one vendor's time zone is not maintain in the master of time zone in CRM side. This may be the issue. But Where exact we can see

  • Oracle 7.3.4 to Oracle 8/8i

    We have an existing VB application with ORACLE 7.3.4 as the Database. The customer is contemplating migrating to ORACLE 8/8i. What are the issues that may come up when we do this migration? If any of you have undertaken similar work in your previous

  • RAC 9i to 11g 3 node cluster upgradation.

    Hi, I have been given the requirement to migrate a 9i RAC 3 node database( 9i cluster) to 11g R2 RAC database iam looking for a document or steps to do this activity. any help on this is highly appreciated. should I upgrade the cluster first and then

  • Change language in wiki and personal pages

    The default pages when a user starts his own wiki and personal pages are in english. I need to change it to start in Portuguese, even if I need to edit the php files (files that I have no clue where they are). Please, can anybody help me?