Announcement Announcement Module
Collapse
No announcement yet.
java.io.FileNotFoundException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • java.io.FileNotFoundException

    Hi,
    I got the following error while working although both files are available and are in the same directory.
    Could anyone help me in that?
    Thanks in Advance.

    Error Trace:
    org.springframework.beans.factory.BeanDefinitionSt oreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext-spring-basic.xml]; nested exception is java.io.FileNotFoundException: HibernateMappingResources_gen.xml (No such file or directory)
    java.io.FileNotFoundException: HibernateMappingResources_gen.xml (No such file or directory)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.jav a:106)
    at java.io.FileInputStream.<init>(FileInputStream.jav a:66)
    at sun.net.www.protocol.file.FileURLConnection.connec t(FileURLConnection.java:70)
    at sun.net.www.protocol.file.FileURLConnection.getInp utStream(FileURLConnection.java:161)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityM anager.setupCurrentEntity(XMLEntityManager.java:97 3)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityM anager.startEntity(XMLEntityManager.java:905)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityM anager.startEntity(XMLEntityManager.java:843)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl.scanEntityReference(XMLDocume ntFragmentScannerImpl.java:1334)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl$FragmentContentDispatcher.dis patch(XMLDocumentFragmentScannerImpl.java:1756)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl.scanDocument(XMLDocumentFragm entScannerImpl.java:368)
    at com.sun.org.apache.xerces.internal.parsers.XML11Co nfiguration.parse(XML11Configuration.java:834)
    at com.sun.org.apache.xerces.internal.parsers.XML11Co nfiguration.parse(XML11Configuration.java:764)
    at com.sun.org.apache.xerces.internal.parsers.XMLPars er.parse(XMLParser.java:148)
    at com.sun.org.apache.xerces.internal.parsers.DOMPars er.parse(DOMParser.java:250)
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBu ilderImpl.parse(DocumentBuilderImpl.java:292)
    at javax.xml.parsers.DocumentBuilder.parse(DocumentBu ilder.java:98)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:130)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:83)
    at org.springframework.web.context.support.XmlWebAppl icationContext.loadBeanDefinitions(XmlWebApplicati onContext.java:114)
    at org.springframework.web.context.support.XmlWebAppl icationContext.loadBeanDefinitions(XmlWebApplicati onContext.java:82)
    at org.springframework.context.support.AbstractRefres hableApplicationContext.refreshBeanFactory(Abstrac tRefreshableApplicationContext.java:87)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:255)
    at org.springframework.web.context.support.AbstractRe freshableWebApplicationContext.refresh(AbstractRef reshableWebApplicationContext.java:131)
    at com._4s_.invoice.web.action.InvoiceControllerTest. setUp(InvoiceControllerTest.java:35)
    at junit.framework.TestCase.runBare(TestCase.java:125 )
    at junit.framework.TestResult$1.protect(TestResult.ja va:106)
    at junit.framework.TestResult.runProtected(TestResult .java:124)
    at junit.framework.TestResult.run(TestResult.java:109 )
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:2 08)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:421)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:305)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:186)


    The files are:[/u]

    applicationContext-spring-basic.xml:


    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE beans PUBLIC
    "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans.dtd" [
    <!ENTITY HibernateMappingResources SYSTEM "file:HibernateMappingResources_gen.xml">
    ]>

    <beans>

    <bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
    <property name="driverClassName">
    <value>com.mysql.jdbc.Driver</value>
    </property>
    <property name="url">
    <value>jdbc:mysql://localhost/myusers</value>
    </property>
    <property name="username"><value>root</value></property>
    <property name="password"><value></value></property>
    </bean>

    <!-- Hibernate SessionFactory -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
    <property name="dataSource"><ref bean="dataSource"/></property>
    <property name="mappingResources">
    <list>
    &HibernateMappingResources;
    </list>
    </property>

    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">net.sf.hibernate.dialect.M ySQLDialect</prop>
    <!--prop key="hibernate.show_sql">true</prop-->
    <!--prop key="hibernate.hbm2ddl.auto">update</prop-->
    </props>
    </property>
    </bean>


    <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
    <bean id="transactionManager" class="org.springframework.orm.hibernate.Hibernate TransactionManager">
    <property name="sessionFactory">
    <ref local="sessionFactory"/>
    </property>
    </bean>


    <!-- Transaction template for Managers, from:
    http://blog.exis.com/colin/archives/...ons-spring-11/ -->
    <bean id="txProxyTemplate" abstract="true"
    class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager"><ref bean="transactionManager"/></property>
    <property name="transactionAttributes">
    <props>
    <prop key="save*">PROPAGATION_REQUIRED</prop>
    <prop key="remove*">PROPAGATION_REQUIRED</prop>
    <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
    </props>
    </property>
    </bean>

    <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailS enderImpl">
    <property name="host"><value>${mail.host}</value></property>
    <property name="username"><value>${mail.username}</value></property>
    <property name="password"><value>${mail.password}</value></property>
    </bean>

    <!-- Configure Velocity for sending e-mail -->
    <bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEng ineFactoryBean">
    <property name="velocityProperties">
    <props>
    <prop key="resource.loader">class</prop>
    <prop key="class.resource.loader.class">
    org.apache.velocity.runtime.resource.loader.Classp athResourceLoader
    </prop>
    </props>
    </property>
    </bean>

    <bean id="mailMessage" class="org.springframework.mail.SimpleMailMessage" singleton="false">
    <property name="from"><value>${mail.default.from}</value></property>
    </bean>

    </beans>


    HibernateMappingResources_gen.xml:

    <value>com/_4s_/personnel/model/personnel.hbm.xml</value>
    <value>com/_4s_/invoice/model/Invoice.hbm.xml</value>
    <value>com/_4s_/invoice/model/ItemType.hbm.xml</value>
    <value>com/_4s_/invoice/model/ItemLine.hbm.xml</value>
    <value>com/_4s_/invoice/model/User.hbm.xml</value>
    <value>com/_4s_/invoice/model/Role.hbm.xml</value>
    <value>com/_4s_/invoice/model/Customer.hbm.xml</value>
    <value>com/_4s_/invoice/model/UserCookie.hbm.xml</value>
    <value>com/_4s_/invoice/model/Item.hbm.xml</value>

  • #2
    Have you tried modifying the path so that is relative to the root of the web application not to the application context configuration file?

    Rob

    Comment


    • #3
      Thanks,
      that works fine.

      Comment

      Working...
      X