Announcement Announcement Module
Collapse
No announcement yet.
jdbc.properties not found Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • jdbc.properties not found

    I am having a problem with my spring application not able to find the jdbc.properties file when executing the code. On launch of the application with Tomcat, I get a valid message:

    "Apr 10, 2008 11:13:02 AM org.springframework.core.io.support.PropertiesLoad erSupport loadProperties
    INFO: Loading properties file from class path resource [WEB-INF/jdbc.properties]"

    But when I go to execute my database call on the web page I get:

    Code:
    org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [WEB-INF/jdbc.properties] cannot be opened because it does not exist
    Here is the complete stack trace. Ideas?

    Code:
    org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [WEB-INF/jdbc.properties] cannot be opened because it does not exist
    	at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:78)
    	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:554)
    	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:528)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:363)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    	at com.general.users.AuthenticationCommand.execute(AuthenticationCommand.java:36)
    	at com.nationwide.common.NWAction.execute(NWAction.java:271)
    	at com.nationwide.common.NWAction.execute(NWAction.java:154)
    	at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
    	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
    	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    	at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
    	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    	at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
    	at java.lang.Thread.run(Unknown Source)

  • #2
    Re use your application context, don't recreate it. If you want to run out of resources and run in all kinds of other issues you go that path..

    Judging by your stacktrace it looks like you are creating a new one (i.e new ClassPathXmlApplicationContext(..)). Simply use the one already available.

    Code:
    ApplicationContext context = new ClassPathXmlApplicationContext("some.xml");
    Don't do the above.

    Code:
    ApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());

    Comment


    • #3
      getServletContext

      Thanks for the help.


      Is there another way besides using "getServletContext"? I am doing this call within my struts command class and it looks like this method is not available to me.

      Comment


      • #4
        Yeah sorry has been a while since I used Struts .

        Code:
        getServlet().getServletContext();
        There is also a convenience class in spring called ActionSupport this provides some helper methods to gain easy access to the ApplicationContext. Next to that I suggest you read the reference guide regarding Spring and Struts integration.

        Comment


        • #5
          Thanks for the help.

          Comment

          Working...
          X