Announcement Announcement Module
Collapse
No announcement yet.
Getting FileNotFoundException for context file Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting FileNotFoundException for context file

    Hi,

    Stacktrace:
    Code:
    Caused by: javax.ejb.EJBException: Error in ejbCreate:: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [beanRefContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [beanRefContext.xml] cannot be opened because it does not exist
    java.io.FileNotFoundException: class path resource [beanRefContext.xml] cannot be opened because it does not exist
    Here is my ejb-jar.xml entries
    Code:
    		    <env-entry>
    				<env-entry-name>ejb/BeanFactoryPath</env-entry-name>
    				<env-entry-type>java.lang.String</env-entry-type>
    				<env-entry-value>beanRefContext.xml</env-entry-value>
    			</env-entry>
    beanRefContext.xml is present my EJBModule.jar when i do a build. While one applicationContext.xml is in WEB-INF folder.

    I understand that beanRefContext.xml is not in Classpath so it is giving FileNotFoundException. So what are the ways to resolve this issue.

    thanks
    Chintan

  • #2
    Hi,

    I was able to solve problem by giving full path for env-entry value. here is change i made,
    Code:
    <env-entry>
    				<env-entry-name>ejb/BeanFactoryPath</env-entry-name>
    				<env-entry-type>java.lang.String</env-entry-type>
    				<env-entry-value>file:/F:/eclipse/workspace/LIKETest/business/conf/beanRefContext.xml</env-entry-value>
    			</env-entry>
    If i am giving full path then it works. But i dont want to give full path as it creates hard-coding.

    How can i put this entry into classpath so that i need not do hardcoding?

    Regards
    Chintan

    Comment


    • #3
      As you file is included in the Project . You may use "classpath:[Folder]filename" instead of hard coding it with the real path.

      Regards
      Kalyan

      Comment


      • #4
        Package the file in a JAR along with any other Spring application context you decide to use and add this jar to your App Lib directory along with your other JARS

        Comment


        • #5
          Hardcoding the complete path in ejb-jar.xml is not right. I would suggest place the "beanRefContext.xml" in root of the ejb jar file. And the other xml files (eg: ejb-jar.xml and jboss.xml etc) in the meta-inf directory.

          That way, the FileNotFoundException should get resolved.

          Comment

          Working...
          X