You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by radha rukmani <ra...@yahoo.com> on 2006/03/02 16:53:41 UTC

Resource not found exception

Hi,
   
  I have an application developed in eclipse using ibatis which runs correctly. When i tried to jar this application(using the eclipse jar utility) and run it from a batch file, it throws me an exception saying that my resource is not found.  This is the error message
   
  2006-03-02 10:46:37,237 DEBUG [main] dao.ConfigData    (ConfigData.java:243)
 - Found config/GeCABatchProcess.ini - loading configuration
java.io.IOException: Could not find resource com\comp\drimm\FERTPlateTransfer\
xml\sqlMapConfig.xml
        at com.ibatis.common.resources.Resources.getResourceAsStream(Resources.j
ava:101)
        at com.ibatis.common.resources.Resources.getResourceAsStream(Resources.j
ava:86)
        at com.ibatis.common.resources.Resources.getResourceAsReader(Resources.j
ava:150)
        at com.comp.drimm.FERTPlateTransfer.AppSqlConfig.<clinit>(AppSqlConfig
.java:18)
   
  This is how i am calling the resource in the AppSqlConfig.java
     String resource="com\\comp\\drimm\\FERTPlateTransfer\\xml\\sqlMapConfig.xml";
   Reader reader=Resources.getResourceAsReader(resource);
   
  This works fine when i run in eclipse, could any one please let me know why it is not working when i call it from the batch file.
   
  This is my .bat file
  set rootpath=.\SignedJars
  set Classpath=%Classpath%;%rootpath%\FERTPlateTransfer.jar
echo %Classpath%
pause
  "C:\Program Files\Java\j2re1.4.2_01\bin\java" com.comp.drimm.FERTPlateTransfer.GeCABatchProcessMain 
  pause

  Thanks.

		
---------------------------------
Brings words and photos together (easily) with
 PhotoMail  - it's free and works with Yahoo! Mail.

Re: Resource not found exception

Posted by Nathan Maves <Na...@Sun.COM>.
AFAIK there are no issues with the Resources class built into  
ibatis.  We use it in multiple web applications as well as stand  
alone java applications.  Of which all of the .properties and .xml  
files are all included in the jar's.

What OS are you working on?

I would try to change your path to this...

String resource = "com/comp/drimm/FERTPLATETransfer/xml/ 
sqlMapConfig.xml"

Nathan

On Mar 2, 2006, at 8:53 AM, radha rukmani wrote:

> Hi,
>
> I have an application developed in eclipse using ibatis which runs  
> correctly. When i tried to jar this application(using the eclipse  
> jar utility) and run it from a batch file, it throws me an  
> exception saying that my resource is not found.  This is the error  
> message
>
> 2006-03-02 10:46:37,237 DEBUG [main] dao.ConfigData     
> (ConfigData.java:243)
>  - Found config/GeCABatchProcess.ini - loading configuration
> java.io.IOException: Could not find resource com\comp\drimm 
> \FERTPlateTransfer\
> xml\sqlMapConfig.xml
>         at com.ibatis.common.resources.Resources.getResourceAsStream 
> (Resources.j
> ava:101)
>         at com.ibatis.common.resources.Resources.getResourceAsStream 
> (Resources.j
> ava:86)
>         at com.ibatis.common.resources.Resources.getResourceAsReader 
> (Resources.j
> ava:150)
>         at com.comp.drimm.FERTPlateTransfer.AppSqlConfig.<clinit> 
> (AppSqlConfig
> .java:18)
>
> This is how i am calling the resource in the AppSqlConfig.java
>    String resource="com\\comp\\drimm\\FERTPlateTransfer\\xml\ 
> \sqlMapConfig.xml";
>    Reader reader=Resources.getResourceAsReader(resource);
>
> This works fine when i run in eclipse, could any one please let me  
> know why it is not working when i call it from the batch file.
>
> This is my .bat file
> set rootpath=.\SignedJars
> set Classpath=%Classpath%;%rootpath%\FERTPlateTransfer.jar
> echo %Classpath%
> pause
> "C:\Program Files\Java\j2re1.4.2_01\bin\java"  
> com.comp.drimm.FERTPlateTransfer.GeCABatchProcessMain
> pause
> Thanks.
>
> Brings words and photos together (easily) with
> PhotoMail - it's free and works with Yahoo! Mail.


Re: Resource not found exception

Posted by Gareth Moorst <ga...@yahoo.co.uk>.
Use getClass().getResource("/com/comp/drimm/FERTPlateTransfer/xml/sqlMapConfig.xml");
to get a URL to the resource, or getClass().getResourceAsStream to get an InputStream.

This works from inside jar files, but you need to make sure that the ml file is also in your jar

--- radha rukmani <ra...@yahoo.com> wrote:

> Hi,
>    
>   I have an application developed in eclipse using ibatis which runs correctly. When i tried to
> jar this application(using the eclipse jar utility) and run it from a batch file, it throws me
> an exception saying that my resource is not found.  This is the error message
>    
>   2006-03-02 10:46:37,237 DEBUG [main] dao.ConfigData    (ConfigData.java:243)
>  - Found config/GeCABatchProcess.ini - loading configuration
> java.io.IOException: Could not find resource com\comp\drimm\FERTPlateTransfer\
> xml\sqlMapConfig.xml
>         at com.ibatis.common.resources.Resources.getResourceAsStream(Resources.j
> ava:101)
>         at com.ibatis.common.resources.Resources.getResourceAsStream(Resources.j
> ava:86)
>         at com.ibatis.common.resources.Resources.getResourceAsReader(Resources.j
> ava:150)
>         at com.comp.drimm.FERTPlateTransfer.AppSqlConfig.<clinit>(AppSqlConfig
> .java:18)
>    
>   This is how i am calling the resource in the AppSqlConfig.java
>      String resource="com\\comp\\drimm\\FERTPlateTransfer\\xml\\sqlMapConfig.xml";
>    Reader reader=Resources.getResourceAsReader(resource);
>    
>   This works fine when i run in eclipse, could any one please let me know why it is not working
> when i call it from the batch file.
>    
>   This is my .bat file
>   set rootpath=.\SignedJars
>   set Classpath=%Classpath%;%rootpath%\FERTPlateTransfer.jar
> echo %Classpath%
> pause
>   "C:\Program Files\Java\j2re1.4.2_01\bin\java"
> com.comp.drimm.FERTPlateTransfer.GeCABatchProcessMain 
>   pause
> 
>   Thanks.
> 
> 		
> ---------------------------------
> Brings words and photos together (easily) with
>  PhotoMail  - it's free and works with Yahoo! Mail.



		
___________________________________________________________ 
NEW Yahoo! Cars - sell your car and browse thousands of new and used cars online! http://uk.cars.yahoo.com/