Menu

Problem with path for my servlet app

2004-02-19
2013-01-10
  • Melvin Wong

    Melvin Wong - 2004-02-19

    I have huge problems with file paths for jcrontab.properties, log4j.properties and crontab file.

    You see, I'm running Tomcat 5.0 and the default/current directory is always pointing to C:\tomcat\bin, where C:\tomcat is my tomcat directory. And I can't store my files there because my app will be virtually hosted by some hosting company. I tried to use the ClassLoader.getResourceStream() thing as mentioned in the HOW-TO....but can't seem to get it working.

    I can't seem to understand how I can find all the right paths for my jcrontab to work.  I need to store all my properties files under ....../webapps/crontab/WEB-INF/.

    BTW, I'm developing my app under Win XP, but the hosting platform will be Linux.

    Please help, cos I've cracked my Java-less brain already.....

    Mel.

     
    • akini

      akini - 2004-04-11

      Dont know the inner parts of Crontab whether you can pass in the any arbitraty Properties instance  "Crontab ct = new Crontab(myProp);". If not, then hack the sourcecode as its an opensource ;-)

      In startupservlet you could use "getServletContext().getRealPath("/")" to identify a fullpath of the webapp. It should give you "c:/tomcat/webapps/crontab" name. Then just load your properties and instantiate Crontab.

       
    • akini

      akini - 2004-04-11

      Just downloaded the source and cheched Crontab.java source. Instantiate it and call "ct.init(pathToMyPropWithinWebapp);" method and it should take care of the everything.

       
    • jloken

      jloken - 2005-10-13

      Perhaps a bit on the late side, but here goes...<br>
      If you deploy jcrontab within a webserver, for instance Tomcat, do NOT use the jcrontab.jar file. Rather simply copy/paste the class file hierarchy to the relevant webapps/x/WEB-INF/classes folder. Jcrontab will then be able to access other classes deployed in the webapp. <br>
      However, I am not able to run NativeExec, for instance org.jcrontab.NativeExec dir.exe without getting an "java.io.IOException: CreateProcess: dir.exe error=2" exception....
      Hope this helps

       

Log in to post a comment.

MongoDB Logo MongoDB