Announcement Announcement Module
Collapse
No announcement yet.
Ermmm... database access? Context initialization failed Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Ermmm... database access? Context initialization failed

    G'day all!

    I have a problem which might seems akward to some of you around! I'm no Java/Spring/Hibernate/what-so-ever expert. I've done some struts and I now have to take over this project using spring/hibernate wth a ms sql backend.

    I'm really not sure it's related to the database access... so give me a shout if I truly am totally in the wrong thread!

    Now here it goes...

    I got everything to complile fine, with all dependencies in proper dirs. but When I deploy the app to my local tomcat 5 server and run the app, I get the following error (extract from the log file, on screen error is the same):


    SEVERE: Context initialization failed

    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'mySessionFactory' defined in ServletContext resource [/WEB-INF/gddb-applicationContext-hibernate.xml]: Initialization of bean failed; nested exception is java.io.FileNotFoundException: class path resource [com/cmpmedica/gddb/datalayer/pojo] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/C:/Program%20Files/Apache%20Group/Tomcat%205.5/webapps/gddbstudio/WEB-INF/lib/com_gddb.jar!/com/cmpmedica/gddb/datalayer/pojo

    java.io.FileNotFoundException: class path resource [com/cmpmedica/gddb/datalayer/pojo] cannot be resolved to absolute file path because it does not reside in the file system:

    jar:file:/C:/Program%20Files/Apache%20Group/Tomcat%205.5/webapps/gddbstudio/WEB-INF/lib/com_gddb.jar!/com/cmpmedica/gddb/datalayer/pojo
    at org.springframework.core.io.ClassPathResource.getF ile(ClassPathResource.java:137)
    at org.springframework.orm.hibernate.LocalSessionFact oryBean.afterPropertiesSet(LocalSessionFactoryBean .java:454)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1065)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:343)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:260)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:221)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:145)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:276)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:317)
    at org.springframework.web.context.support.AbstractRe freshableWebApplicationContext.refresh(AbstractRef reshableWebApplicationContext.java:131)
    at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:224)
    at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:150)
    at org.springframework.web.context.ContextLoaderServl et.init(ContextLoaderServlet.java:81)
    ...
    ...
    and a bunch of stuff until the java.lang.Thread

    Now here is some config stuff;

    WEB-INF/gddb-applicationContext-hibernate.xml

    Code:
    	<bean id="myDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiName"><value>java&#58;comp/env/jdbc/gddb</value></property>
    	</bean>
    Code:
    	<bean id="mySessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
    		<property name="dataSource"><ref local="myDataSource"/></property>
    
        <property name="mappingDirectoryLocations">
          <list>
            <value>classpath&#58;/com/cmpmedica/gddb/datalayer/pojo</value>
          </list>
        </property>
    
    		<property name="hibernateProperties">
    			<props>
    				<prop key="hibernate.dialect">net.sf.hibernate.dialect.SQLServerDialect</prop>
    				<prop key="hibernate.query.substitutions">true</prop>
    				<prop key="hibernate.show_sql">true</prop>
    			</props>
    		</property>
    	</bean>

    I don't believe there is anything relevant in the WEB-INF/gddbstudio-servlet.xml (500+ lines file) nor in the WEB-INF/web.xml one, but let me know if they could help.

    Now, I've had a good look at the error and it seems like a pojo class is not found (am I right?!). So I went into the webapps folder and looked to see if the mentioned files were there, and they are; I've got the "C:\Program Files\Apache Group\Tomcat 5.5\webapps\gddbstudio\WEB-INF\lib\com_gddb.jar" file and it does contain the "com/cmpmedica/gddb/datalayer/pojo" folder and all pojo files in it.

    I have tried copying the com_gddb.jar just about everywhere, extracting its content as well, (*obviously* restarting tomcat and/or reloading the app everytimes) and I must say... I'm clueless!

    Again I'm no expert, I do understand how things are being linked up but any info you may provide on the subject would be gratefully appreciated!

    Also, thought you should know that this is an app that was running fine on some other computer (which I don't have access to), so my guess would be that it's related to the server, but I had to setup all over again the working environment and the lib resources in the IDE, so I might've forgot something... hopefully not too trivial!!



    Thanks for any help that may be provided! Every ideas are more than welcome!


    Cheers!

    SEb!


    [edit]This wouldn't have anything to do with the spaces in the file name, would it?![/edit]

  • #2
    Re: Ermmm... database access? Context initialization failed

    The problem is that Hibernate can't find the mapping files. Mapping files are xml files usually with the extension *.hbm.xml.

    It tries to find them here:
    Code:
    <property name="mappingDirectoryLocations">
          <list>
            <value>classpath&#58;/com/cmpmedica/gddb/datalayer/pojo</value>
          </list>
        </property>
    Apparently they are not properly packaged in your jar file. Can you check if there are any hbm.xml files in the jar?

    Comment

    Working...
    X