Lost of Parameter file in web application

Hi,
We develop a java (1.5) application running on Tomcat (5.5 and 6.0).
In this application, we use a parameter file in YAML format.
Everything works perfectly except when the tomcat server is restarted.
At this point, the application is no more able to reach the parameter file.
We have to re-deploy the whole application to be able to use the parameter file.
But we lost it again when the server is restarted.
We don't know if the problem is coming from our tomcat configuration or from our java code.
The problem is seen on Tomcat 5.5, 6.0 and on Linux and Mac OS X.
So, it must come from our code.
Do you have an idea ?
Thanks
Here is the code where the parameter file is read:
final private String YAMLpath = "truc" + File.separator + "META-INF" + File.separator + "Parameters.yaml";
try
               Scanner openYAML55 = new Scanner(new File(this.YAMLpath) ); //For Tomcat5.5
               this.readParameterFile(openYAML55);
               openYAML55.close();
          catch(FileNotFoundException f)
               f.printStackTrace();
private void readParameterFile(Scanner paramFile)
     while(paramFile.hasNextLine())
               Pattern paramLine = Pattern.compile("(\\w+)\\s*:\\s*(.*)");
               Matcher paramArg = paramLine.matcher(paramFile.nextLine());
               if ( paramArg.matches() )
if ( paramArg.group(1).trim().equals("dbase") )
                         this.dbase = paramArg.group(2).replaceAll("\"", "").trim();
                    else if ( paramArg.group(1).trim().equals("dbport") )
                         this.dbport = Integer.parseInt( paramArg.group(2).replaceAll("\"", "").trim() );
                    else if ( paramArg.group(1).trim().equals("dbhost") )
                         this.dbhost = paramArg.group(2).replaceAll("\"", "").trim();
          this.bgeeRoot = this.serverRoot + this.bgeeRoot;
          this.homePage = this.serverRoot + this.homePage;
}

How about simply loading the file or obtaining its input stream as a resource using ClassLoader.getResource[AsStream]? Direct file access to parts of a web app... my oh my.

Similar Messages

  • How to create a file under web application root from java program

    how to create a file under web application root from java program like an action class?

    like an action class?Huh? What exactly is your requirement?
    Creating a file is usually done with java.io API. Read the java.io tutorials how to play with files.

  • Advantages and disadvantages creation of war file in web application......

    Hi friends.... I'm new to java....
    according to my little knowledge creating a war file is optional,
    but i don't know if we directly deployed web application like servlet application in the web server(ex: webapps in TOMCAT)
    what problems may get if my computer system not in the network and what problems may get if my computer system in the network....i know we must create a war file for appropriate application if the server is in remote place....
    please reply.....thank you

    Isn't it easier to deploy one file than it is to deploy dozens, hundreds, even thousands?

  • Error executing batch file within web application

    Hi all,
    I am trying to execute a batch file from within my web application (struts 1.2).
    The batch file is being kept inside the 'src' folder. The batch file contains only one command to open NOTEPAD.
    The code inside my Action class is:
    URL url = getClass().getResource("/test.bat");
    java.io.File file = new java.io.File(url.getPath()) ;
    String path = file.getCanonicalPath();
    r.exec(path);
    I have deployed this on tomcat and get an error like this:
    java.io.IOException: Cannot run program "C:\Program%20Files\Apache%20Software%20Foundation\Tomcat%206.0\webapps\CIGTAFAPP\WEB-INF\classes\test.bat": CreateProcess error=2, The system cannot find the file specified
    The problem is not with the batch file because when I try to execute the file directly from the classes folder, it opens up the notepad editor.
    I have a specific requirement where I need to create/read this batch file from within the project structure.
    Can someone please help me with this?
    Regards

    The entire content of the file is as below:
    set javaTestProjectPath=D:\projects\CIGTAF\LRTestCases
    C:
    cd %javaTestProjectPath%
    set path=C:\Program Files\Java\jdk1.6.0_21\bin
    set classpath=%javaTestProjectPath%\bin;%javaTestProjectPath%\lib\selenium-server-standalone-2.20.0.jar;%javaTestProjectPath%\lib\testng-6.4.jar;%javaTestProjectPath%\lib\junit-4.10.jar;%javaTestProjectPath%\lib\poi-3.6-20091214.jar;%javaTestProjectPath%\lib\mail.jar
    javac -verbose %javaTestProjectPath%\src\com\core\testscripts\Mailsetup.java -d %javaTestProjectPath%\bin
    javac -verbose %javaTestProjectPath%\src\com\core\testscripts\MailAuthenticator.java -d %javaTestProjectPath%\bin
    javac -verbose %javaTestProjectPath%\src\com\core\testscripts\ReadData.java -d %javaTestProjectPath%\bin
    javac -verbose %javaTestProjectPath%\src\com\core\testscripts\ReadWriteExcelResults.java -d %javaTestProjectPath%\bin
    javac -verbose %javaTestProjectPath%\src\com\core\testscripts\SeleniumFramework.java -d %javaTestProjectPath%\bin
    java org.testng.TestNG %javaTestProjectPath%\SelXD-Config.xml -d %javaTestProjectPath%\test-output
    none of these are getting executed.
    regards
    Edited by: 887789 on May 4, 2012 1:46 AM

  • How to create a war file of web application

    Hi Techies
    How to create a war file of the web application?
    And plz tell me the utilities used for it.

    hi,
    To compress a 'abc' web application into a "Web Archive" file named abc.war, follow the steps below:
    1> Open a command prompt and cd to the application's dir:
    <TOMCAT_HOME>\webapps\abc
    2> Use the java archive command 'jar' to bundle up your application:
    jar -cvf abc.war *
    3> Move this to any other server and work with it!! :)
    -- Abdel Raoof Olakara
    http://olakara.googlepages.com

  • Problem with Uploading files in Web applications with the iPad

    Hello,
    I have a question. How can I upload a word file in the gmx-Mailserver with my IPad? I can only find the picture library. In this library i cannot upload a word-file or other files-types. I use Safari. The same problem exists by other web applications.
    Thanks for your help.
    Kami2013

    I think I just did something wrong myself. I was finally able to upload the file. However, I wrote the following procedure in my package but wasn't able to download the file from the report. Do I need to grant any privilege from the system user?
    Also, does anyone know how to convert a BLOB table into 11g Securefiles table?
    Thanks.
    <pre>
    procedure download_birth_cert(p_vrds_birth_cert_pk in number) is
    v_mime VARCHAR2(48);
    v_length NUMBER;
    v_file_name VARCHAR2(4000);
    Lob_loc BLOB;
    begin
    select mime_type, blob_content, file_name, dbms_lob.getlength(blob_content)
    into v_mime, lob_loc, v_file_name, v_length
    from vrds_birth_cert
    where vrds_birth_cert_pk = p_vrds_birth_cert_pk;
    -- set up HTTP header
    -- use an NVL around the mime type and
    -- if it is a null set it to application/octect
    -- application/octect may launch a download window from windows
    owa_util.mime_header(nvl(v_mime,'application/octet'), FALSE);
    -- set the size so the browser knows how much to download
    htp.p('Content-length: ' || v_length);
    -- the filename will be used by the browser if the user does a save as
    htp.p('Content-Disposition: attachment; filename="'||substr(v_file_name,instr(v_file_name,'/')+1)|| '"');
    -- close the headers
    owa_util.http_header_close;
    -- download the BLOB
    wpg_docload.download_file( Lob_loc );
    exception
    when others then
    null;                    
    end download_birth_cert;
    </pre>

  • Opening a file in web application

    Hi,
    I have a Web application and I need to open a file using a File object.I am unable to open the file unless I specify the complete path of the file including the name of the drive in which it recides.But this will make the application dependent on the folder structure in the system in which it is deployed.I want to make it independent of the folder structure.I placed the file in the same folder as the java class which tries to open it.But still it is not working unless the folder structure is specified.Please help.
    Thanks,
    Neelambary

    check ServletContext.getResource documentation
    it allows you to retrieve a file within your webapp directory

  • How to select a Hibenrate configuration file for web application/junit?

    Dear all,
    I am using hibernate for a web application.
    I have two configuration files: one ("hibernate-jta.cfg.xml") uses a data source and the other ("hibernate.cfg.xml") directly uses jdbc.
    private static String CONFIG_FILE = "hibernate-jta.cfg.xml"; private static String CONFIG_FILE_WITHOUT_DATASOURCE = "hibernate.cfg.xml";
    When I deplyed my applcation to an application server, I need to use the first one. When I run junit test, I need to use the second one.
    How can I design a mecanism to switch between the two configuration files according the the case: web application or java stand alone application?
    Configuration cfg = new Configuration(); cfg.configure(CONFIG_FILE);
    Thanks.
    Pengyou

    My solution is to add a new public method "initFactoryForJunit() " in the Static singleton.
    In the junit test, this method will be invoked in order to load a second configuration file.
    public class ThreadsafeSessionFactory {
         private static Logger log = Logger
                   .getLogger(ThreadsafeSessionFactory.class);
         private static String CONFIG_FILE = "hibernate-jta.cfg.xml";
         private static String CONFIG_FILE_FOR_JUNIT = "hibernate.cfg.xml";
         private static final Configuration cfg = new Configuration();
         private static org.hibernate.SessionFactory sessionFactory;
         public static SessionFactory getInstance() {
              log.info("getInstance()");
              if (sessionFactory == null) {
                   ThreadsafeSessionFactory.initFactory();
              return sessionFactory;
         /*public synchronized Session openSession() {
              log.debug("openSession()");
              return sessionFactory.getCurrentSession();
         public synchronized Session getCurrentSession() {
              log.debug("getCurrentSession()");
              return sessionFactory.getCurrentSession();
         private static void initFactory() {
              log.debug("initFactory()");
              if (sessionFactory == null) {
                   try {
                        Configuration cfg = new Configuration();
                        cfg.configure(CONFIG_FILE);
                        String factoryJndiName = cfg
                                  .getProperty(Environment.SESSION_FACTORY_NAME);
                        if (factoryJndiName != null) {
                             log.debug("using jndi factory");
                             cfg.buildSessionFactory();
                             sessionFactory = (SessionFactory) (new InitialContext())
                                       .lookup(factoryJndiName);
                        } else {
                             log.info("using default factory");
                             sessionFactory = cfg.buildSessionFactory();
                             log.info("after using default factory");
                   } catch (Exception ex) {
                        ex.printStackTrace();
                        log.error("failed creating session factory");
                        throw new HibernateException(
                                  "initFactory(): failed initializing configuration");
         public static void initFactoryForJunit() {
              log.debug("initFactory()");
              if (sessionFactory == null) {
                   try {
                        Configuration cfg = new Configuration();
                        cfg.configure(CONFIG_FILE_FOR_JUNIT);
                        String factoryJndiName = cfg
                                  .getProperty(Environment.SESSION_FACTORY_NAME);
                        if (factoryJndiName != null) {
                             log.debug("using jndi factory");
                             cfg.buildSessionFactory();
                             sessionFactory = (SessionFactory) (new InitialContext())
                                       .lookup(factoryJndiName);
                        } else {
                             log.info("using default factory");
                             sessionFactory = cfg.buildSessionFactory();
                             log.info("after using default factory");
                   } catch (Exception ex) {
                        ex.printStackTrace();
                        log.error("failed creating session factory");
                        throw new HibernateException(
                                  "initFactory(): failed initializing configuration");
         public static void close() {
              if (sessionFactory != null)
                   sessionFactory.close();
              sessionFactory = null;
    }

  • Show browse files dialog by listing remote machin files in web application

    Hi all,
    I want to develop a web application which has "Browse Server" button to browse remote server. After selecting files and folders from remote server, need to read all files and folders from server and store that information in Database. Please provide some ideas and help regarding this.
    I think that i need to develop a custom component based on jfilechooser to connect to server and show the selection dialog like windows file upload.
    I don't no how to list server files and show as browse dialog to select and read those files.
    Thanks in advance.
    Regards,
    Venkata Subba Reddy

    Most web browsers can browse FTP. You can achieve what you want without writing a single line of code. How cool is that?

  • Call a web template with default parameter in  BEx Web Application D

    In BEx Web Application Designer, As in traditional way. Assume that I have a query which have parameters. When I create a web template using this query and excute it. the first page is displayed and I should input the parameters at this page(for example: "Period/Fiscal"). after I input the data and press Enter key. the <b>reporting page</b> is displayed.
    And Now I hope I can run the template at another way: the template should <b>direct go to the reporting page</b> with the preset parameters (for example: "Period/Fiscal = 2005.006").
    thanks

    Hi,
    Alternatively you may use command URL, to enforce the variable value during calling up the web template. For example:
    http://yourAppServer:yourPort/SAP/BW/BEx?CMD=LDOC&template_id=yourTemplate&var_name_1=myParameterVariable&var_value_ext_1=4711
    In the implementation you may create a web template that redirect the URL to above reporting link, so the user will directly see your reporting page.
    For detail you may check in the WAD documentation.
    Hope this helps.
    Message was edited by: Eddo

  • How to set up context parameter of a web application

    Hi,
    I am tring to deploy a ear file to J2EE Engine 7.1
    with the help of import feature of NWDS.
    Is there any option to set the value of the context parameters defined in web.xml inside the ear.
    Regards,
    Chitra

    Thanks for your response.
    Th e version no. of IE Tab is 4.0.20130422 and it is from https://addons.mozilla.org/en-US/firefox/addon/ie-tab/
    Look forward your reply.Thank you in advance.

  • Passing a parameter from a web application to the sub report.

    Hi I am currently passing a parameter from the webpage into the main crystal report.  I would like to pass this same parameter to the subreport but when I right click on the subreport from the main report I can find the parameter on the main report but there is nothing to link it to on the subreport (since this window just shows the dataset).  I also tried adding a parameter to the subreport but it does not show up in the link window on the (select data in subreport to link to).  I am using vs2005 and the crystal reports that comes with this.
    Thanks.

    Hi, Paul;
    There are many samples on our site that show passing parameters to both main reports and subreports. Have a search at
    https://www.sdn.sap.com/irj/scn/advancedsearch?cat=sdn_codesamples&query=vb+net&adv=false
    Regards,
    Jonathan

  • Run remote batch file from Web Application Server

    Hello,
    I've developyed a Java program and deployed it on WAS v7.1.
    My java program tries to run a remote batch file which is located on remote Windows file system (and not on the WAS file system itself).
    The batch file was launched on the remote server (I saw it on the Task Manager of the remote server), but the remote batch file actually wasn't run (it was stuck).
    In order to run the remote batch file from my java program that is deployed on the WAS I've created a batch file on the WAS file system which its contnet is:
    cd c:\jobs
    psexec.exe 
    iltlvt40 -u SAPServiceCE1 -p a2i2000! c:\automation\DiskSpace\runDiskSpace.bat
    The jobs folder contains the psexec.exe file (you can find more details about the psexec on this link: http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx).
    iltlvt40 is the remote server.
    SAPServiceCE1/a2i2000! is a user/password on the remote server which has a full permissions.
    My java program calls this batch file using the Runtime.exec() java method in order to run the remote batch file.
    Please guide me how to solve this problem?
    Best regards,
    Ahmad

    Hi,
    To which batch file you have meant to add some commands: for the local one or remote?
    I've added to the local one some different commands and it's works.
    I think there is a permission problem when we are trying to go out of the WAS file system.
    Best regards,
    Ahmad

  • Deploying web application to OC4J  - servlet class not found

    Hi,
    Im trying to deploy war file with web application,
    that I run before on Tomcat.
    During deployment procces everything seems to be OK.
    But when I try to log on web, I get 500 error...
    log file:
    07/07/12 15:10:14.562 webapp1: Servlet error
    javax.servlet.ServletException: Error instantiating servlet 'org.apache.jsp.index_jsp'. Servlet class org.apache.jsp.index_jsp not found in web-application webapp1
    where org.apache.jsp.index_jsp is path from web.xml and servlet index_jsp.class is in
    Web-Inf/classes/org/apache/jsp/ dir.
    Any Idea?
    Thanks a lot.
    H.

    Hi Steve,
    thanks for your answer, because my question is quite stupid, I know.
    But I'm not so much interested in pre-translated jsp files dependences on java container.
    Yes, my application use some parts of catalina lib, but I would like to just get index.jsp
    and this compiled class (org.apache.jsp.index_jsp.class) is "catalina lib free" I think?
    Or should I change my build.xml?
    Thanks.
    H.

  • Where I can find .WAR file for web UI?

    I would like to use jakarta project
    web container for webUI.How I can accomplish
    this?

    Hello, I mean tomcat of jakarta.apache.org project- it's web container but .war file is web application archive as specified in servlet 2.2 spec.
    Why? I need support for latest spec. servlet 2.2/jsp 1.2 that provided by tomcat 4.0 beta(as standalone it's working fine for me;)). I'll be more concrete
    I need sophisticated JSP rendering engine for:
    Using JSPs of developer guide:
    <
    Deploying Java Beans and JSPs
    All compiled Java Beans must be stored in the directory $ORACLE_HOME/ifs/custom_classes on the server where Oracle iFS is installed.
    The Oracle iFS product comes with a starting-point directory structure. One of the folders in that structure is reserved for holding JSPs: $ORACLE_HOME/ifs/jsp-bin. To have your JSP compile and execute properly in Oracle iFS, you must store the JSP in this folder. JSPs stored elsewhere will not be executed by the Oracle iFS JSP compiler.
    >
    I would like to use web UI as frontend and my JSPs/servlets as extension of this application. It's easy create custom web app if I have ready .WAR file-it's portable
    between web containers and well structured... For example this schema doesn't have such constraints as location of JSPs and beans support classes location is well known-
    WEB-INF/classes for .WAR structured file, in WEB-INF/lib can be placed different ifs libs and all is clean and portable;).
    I mean webUI must not be integrated part of ifs- it must be developer tool( extensible and reusable).By the way who give constraints on JSPs/classes location: HTTP server of ifs
    or webUI?
    It's very nice that IFS has such thing as webUI but that if I can use it as dead(stable) code:(. I need write myself webUI presenting IFS document structure but why?
    Web UI is future(IE 5.5/w3 and other standards based;) so why put on it such restrictions.
    Best regards.
    P.S I can infiltrate web app from ifs- but it's not right(I can do something wrong).If I can help you somehow tell me.
    null

Maybe you are looking for