Hibernate and log4j config under Tomcat. - JDBC JAVA

This is a discussion on Hibernate and log4j config under Tomcat. - JDBC JAVA ; "Under Tomcat 3.x and 4.x, you should place the log4j.properties under the WEB-INF/classes directory of your web-applications. Log4j will find the properties file and initialize itself. This is easy to do and it works." "The XML configuration file is placed ...

+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11

Hibernate and log4j config under Tomcat.

  1. Default Hibernate and log4j config under Tomcat.

    "Under Tomcat 3.x and 4.x, you should place the log4j.properties under the
    WEB-INF/classes directory of your web-applications. Log4j will find the
    properties file and initialize itself. This is easy to do and it works."

    "The XML configuration file is placed in the context classpath
    (WEB-INF/classes), as hibernate.cfg.xml"

    I don't know what's Tomcat's problem but in both cases, despite what the
    documentation says, placing the config files in WEB-INF/classes didn't
    work.
    For log4j I ended up using an initialization servlet.
    For Hibernate, I placed the xml file in several folders after some
    googling:

    WEB-INF/classes ; WEB-INF/classes/<path to class file> ; WEB-INF/src ;
    <tomcat_home>/conf

    Nothing worked and this time Tomcat explicitly told me that the file is
    not to be found. I ended up having to specify an absolute path to at least
    see that the code I'm actually interested in works.

    I don't know what's Tomcat's problem... or mine...

    Rico.

  2. Default Re: Hibernate and log4j config under Tomcat.

    "Rico" <ras_nas@yahoo.com> wrote in message
    newsan.2005.02.18.02.04.14.391000@yahoo.com...
    > "Under Tomcat 3.x and 4.x, you should place the log4j.properties under the
    > WEB-INF/classes directory of your web-applications. Log4j will find the
    > properties file and initialize itself. This is easy to do and it works."
    >
    > "The XML configuration file is placed in the context classpath
    > (WEB-INF/classes), as hibernate.cfg.xml"
    >
    > I don't know what's Tomcat's problem but in both cases, despite what the
    > documentation says, placing the config files in WEB-INF/classes didn't
    > work.
    > For log4j I ended up using an initialization servlet.
    > For Hibernate, I placed the xml file in several folders after some
    > googling:
    >
    > WEB-INF/classes ; WEB-INF/classes/<path to class file> ; WEB-INF/src ;
    > <tomcat_home>/conf
    >
    > Nothing worked and this time Tomcat explicitly told me that the file is
    > not to be found. I ended up having to specify an absolute path to at least
    > see that the code I'm actually interested in works.
    >
    > I don't know what's Tomcat's problem... or mine...
    >
    > Rico.

    Likely yours. I just set up a fresh Hibernate install on Tomcat 5.5 (with Log4j)
    with no problems. Define what you mean by "didn't work".



  3. Default Re: Hibernate and log4j config under Tomcat.

    On Thu, 17 Feb 2005 23:31:04 -0600, Ryan Stewart wrote:
    > "Rico" <ras_nas@yahoo.com> wrote in message


    >> "The XML configuration file is placed in the context classpath
    >> (WEB-INF/classes), as hibernate.cfg.xml"


    >> For Hibernate, I placed the xml file in several folders after some
    >> googling:
    >>
    >> WEB-INF/classes ; WEB-INF/classes/<path to class file> ; WEB-INF/src ;
    >> <tomcat_home>/conf
    >>
    >> Nothing worked and this time Tomcat explicitly told me that the file is
    >> not to be found. I ended up having to specify an absolute path to at
    >> least see that the code I'm actually interested in works.
    >>
    >> I don't know what's Tomcat's problem... or mine...
    >>
    >> Rico.

    > Likely yours. I just set up a fresh Hibernate install on Tomcat 5.5
    > (with Log4j) with no problems. Define what you mean by "didn't work".


    As I said, for Hibernate under Tomcat (4.1.18 and 4.1.31), no matter where
    I put the hibernate.cfg.xml, including WEB-INF/classes, I got the message
    that the file is not to be found when we reach the following code:

    sessionFactory = new Configuration().configure()
    .buildSessionFactory();

    2005-02-18 15:28:00,968 WARN http-8080-Processor4
    net.sf.hibernate.cfg.Configuration - /hibernate.cfg.xml not found

    I've considered trying Tomcat 5.0.x but it seems that first I need to
    figure out which ones and adapt a couple of settings in server.xml and/or
    web.xml to get it to stop crashing.

    Rico.

  4. Default Re: Hibernate and log4j config under Tomcat.

    "Rico" <ras_nas@yahoo.com> wrote in message
    newsan.2005.02.18.07.52.22.250000@yahoo.com...
    > As I said, for Hibernate under Tomcat (4.1.18 and 4.1.31), no matter where
    > I put the hibernate.cfg.xml, including WEB-INF/classes, I got the message
    > that the file is not to be found when we reach the following code:
    >
    > sessionFactory = new Configuration().configure()
    > .buildSessionFactory();
    >
    > 2005-02-18 15:28:00,968 WARN http-8080-Processor4
    > net.sf.hibernate.cfg.Configuration - /hibernate.cfg.xml not found
    >
    > I've considered trying Tomcat 5.0.x but it seems that first I need to
    > figure out which ones and adapt a couple of settings in server.xml and/or
    > web.xml to get it to stop crashing.
    >

    What version of Hibernate are you using? When I remove the config file, I get
    this in the log: (line breaks inserted to prevent wrap and logging set to INFO
    level)
    INFO [http-8080-Processor25] cfg.Environment (<clinit>:483)
    - Hibernate 2.1.8
    INFO [http-8080-Processor25] cfg.Environment (<clinit>:512)
    - hibernate.properties not found
    INFO [http-8080-Processor25] cfg.Environment (<clinit>:543)
    - using CGLIB reflection optimizer
    INFO [http-8080-Processor25] cfg.Environment (<clinit>:572)
    - using JDK 1.4 java.sql.Timestamp handling
    INFO [http-8080-Processor25] cfg.Configuration (configure:909)
    - configuring from resource: /hibernate.cfg.xml
    INFO [http-8080-Processor25] cfg.Configuration
    (getConfigurationInputStream:881)
    - Configuration resource: /hibernate.cfg.xml
    WARN [http-8080-Processor25] cfg.Configuration
    (getConfigurationInputStream:885)
    - /hibernate.cfg.xml not found
    ERROR [http-8080-Processor25] persistence.HibernateUtil (<clinit>:19)
    - Initial SessionFactory creation failed.
    net.sf.hibernate.HibernateException: /hibernate.cfg.xml not found

    Does that look like what you're getting? I assume you're using some build tool.
    Are you sure that the config file is being built to the right place?



  5. Default Re: Hibernate and log4j config under Tomcat.

    On Fri, 18 Feb 2005 06:53:49 -0600, Ryan Stewart wrote:
    > What version of Hibernate are you using? When I remove the config file,
    > I get this in the log: (line breaks inserted to prevent wrap and logging
    > set to INFO level)
    > INFO [http-8080-Processor25] cfg.Environment (<clinit>:483)
    > - Hibernate 2.1.8
    > INFO [http-8080-Processor25] cfg.Environment (<clinit>:512)
    > - hibernate.properties not found
    > INFO [http-8080-Processor25] cfg.Environment (<clinit>:543)
    > - using CGLIB reflection optimizer
    > INFO [http-8080-Processor25] cfg.Environment (<clinit>:572)
    > - using JDK 1.4 java.sql.Timestamp handling
    > INFO [http-8080-Processor25] cfg.Configuration (configure:909)
    > - configuring from resource: /hibernate.cfg.xml
    > INFO [http-8080-Processor25] cfg.Configuration
    > (getConfigurationInputStream:881)
    > - Configuration resource: /hibernate.cfg.xml
    > WARN [http-8080-Processor25] cfg.Configuration
    > (getConfigurationInputStream:885)
    > - /hibernate.cfg.xml not found
    > ERROR [http-8080-Processor25] persistence.HibernateUtil (<clinit>:19)
    > - Initial SessionFactory creation failed.
    > net.sf.hibernate.HibernateException: /hibernate.cfg.xml not found
    >
    > Does that look like what you're getting? I assume you're using some
    > build tool. Are you sure that the config file is being built to the
    > right place?


    I was using 2.1.6 and I upgraded to 2.1.8. The above is almost exactly
    what I still get. I am positive that I have a file hibernate.cfg.xml in my
    application's WEB-INF/classes folder.
    It's the same config file that was at the root of the Eclipse project that
    didn't require an absolute path to find it.

    Rico.

  6. Default Re: Hibernate and log4j config under Tomcat.

    On Fri, 18 Feb 2005 10:04:17 +0800, Rico wrote:
    > "Under Tomcat 3.x and 4.x, you should place the log4j.properties under the
    > WEB-INF/classes directory of your web-applications. Log4j will find the
    > properties file and initialize itself. This is easy to do and it works."
    >
    > "The XML configuration file is placed in the context classpath
    > (WEB-INF/classes), as hibernate.cfg.xml"
    >
    > I don't know what's Tomcat's problem but in both cases, despite what the
    > documentation says, placing the config files in WEB-INF/classes didn't
    > work.
    > For log4j I ended up using an initialization servlet.
    > For Hibernate, I placed the xml file in several folders after some
    > googling:
    >
    > WEB-INF/classes ; WEB-INF/classes/<path to class file> ; WEB-INF/src ;
    > <tomcat_home>/conf
    >
    > Nothing worked and this time Tomcat explicitly told me that the file is
    > not to be found. I ended up having to specify an absolute path to at least
    > see that the code I'm actually interested in works.
    >
    > I don't know what's Tomcat's problem... or mine...
    >
    > Rico.


    Believe me, I've really had to keep trying before getting to this point:

    Tomcat can now see hibernate.cfg.xml and log4j.properties which are in my
    WEB-INF/classes folder as per the documentation.
    What isn't in the documentation is whether the absolute path for the web
    application needs to be
    <CATALINA_HOME>/webapps/<app_folder>/WEB_INF/classes

    because from what I observe, only then things work as they are supposed to.
    If I am to use another installation path for the application, I'm stuck
    with e.g using initialization servlet or probably a ResourceBundle to pass
    the path to Hibernate's Configuration class ?

    Rico.

  7. Default Re: Hibernate and log4j config under Tomcat.

    "Rico" <ras_nas@yahoo.com> wrote in message
    newsan.2005.02.19.15.48.58.625000@yahoo.com...
    > Believe me, I've really had to keep trying before getting to this point:
    >
    > Tomcat can now see hibernate.cfg.xml and log4j.properties which are in my
    > WEB-INF/classes folder as per the documentation.
    > What isn't in the documentation is whether the absolute path for the web
    > application needs to be
    > <CATALINA_HOME>/webapps/<app_folder>/WEB_INF/classes
    >

    No, it does not.

    > because from what I observe, only then things work as they are supposed to.
    > If I am to use another installation path for the application, I'm stuck
    > with e.g using initialization servlet or probably a ResourceBundle to pass
    > the path to Hibernate's Configuration class ?
    >

    What do you mean by "another installation path"? What path, and how do you set
    it up for Tomcat to access it?



  8. Default Re: Hibernate and log4j config under Tomcat.

    On Sat, 19 Feb 2005 23:27:05 -0600, Ryan Stewart wrote:
    > "Rico" <ras_nas@yahoo.com> wrote in message
    >> Believe me, I've really had to keep trying before getting to this point:
    >>
    >> Tomcat can now see hibernate.cfg.xml and log4j.properties which are in
    >> my WEB-INF/classes folder as per the documentation. What isn't in the
    >> documentation is whether the absolute path for the web application
    >> needs to be
    >> <CATALINA_HOME>/webapps/<app_folder>/WEB_INF/classes
    >>

    > No, it does not.
    >
    >> because from what I observe, only then things work as they are supposed
    >> to. If I am to use another installation path for the application, I'm
    >> stuck with e.g using initialization servlet or probably a
    >> ResourceBundle to pass the path to Hibernate's Configuration class ?
    >>

    > What do you mean by "another installation path"? What path, and how do
    > you set it up for Tomcat to access it?


    C:\\myWebApp

    <Context path="/something" docBase="C:\\myWebApp" />

    In such a case, Tomcat cannot find
    C:\myWebApp\WEB-INF\classes\hibernate.cfg.xml

    Same goes for
    C:\myWebApp\WEB-INF\classes\log4j.properties

    Though from the way I understand the documentation they're supposed to be
    found.
    It's when I use the following installation folder that e.g
    Hibernate's no-args configure() succeeds as Tomcat can find the
    hibernate.cfg.xml in:

    <CATALINA_HOME>/webapps/<app_folder>/WEB_INF/classes

    Rico.

  9. Default Re: Hibernate and log4j config under Tomcat.

    "Rico" <ras_nas@yahoo.com> wrote in message
    newsan.2005.02.20.13.12.15.750000@yahoo.com...
    > <Context path="/something" docBase="C:\\myWebApp" />

    Try docBase="C:\myWebApp".



  10. Default Re: Hibernate and log4j config under Tomcat.

    On Sun, 20 Feb 2005 08:34:47 -0600, Ryan Stewart wrote:
    > "Rico" <ras_nas@yahoo.com> wrote in message


    >> <Context path="/something" docBase="C:\\myWebApp" />

    > Try docBase="C:\myWebApp".


    humm... any particular reason why we'd expect that to make a difference?

+ Reply to Thread
Page 1 of 2 1 2 LastLast

Similar Threads

  1. Tomcat 6.0.10 with log4j 1.2.14
    By Application Development in forum Java
    Replies: 2
    Last Post: 08-19-2007, 06:32 AM
  2. Re: Tomcat 6.0.10 with log4j 1.2.14
    By Application Development in forum Java
    Replies: 0
    Last Post: 08-15-2007, 07:24 AM
  3. Tomcat 6.0.10 with log4j 1.2.14
    By Application Development in forum Java
    Replies: 0
    Last Post: 08-15-2007, 04:52 AM
  4. tomcat log4j
    By Application Development in forum Java
    Replies: 3
    Last Post: 07-31-2007, 02:58 PM
  5. Hibernate config in Tomcat
    By Application Development in forum JDBC JAVA
    Replies: 1
    Last Post: 02-21-2006, 09:51 AM