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 Javier Leyba <xl...@gmail.com> on 2006/08/29 13:09:25 UTC

Resource load problem

Hi

I' ll use iBatis in my JBoss application and want to keep all
configuration files in my conf directory so I did:

static {
		try {
			String resource = System.getProperty("jboss.server.home.dir")
								+ "/conf/SqlMapConfig.xml";
			Reader reader = Resources.getResourceAsReader(resource);
			sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
		} catch (Exception e) {
			e.printStackTrace();
			throw new RuntimeException(
					"Error initializing MyAppSqlConfig class. Cause: " + e);
		}


But when I call the application I get the error message:

12:52:06,764 INFO  [STDOUT] java.io.IOException: Could not find
resource /home/jcm/jboss-4.0.3SP1/server/javier01/conf/SqlMapConfig.xml

but if open a telent console and do

vi /home/jcm/jboss-4.0.3SP1/server/javier01/conf/SqlMapConfig.xml from
elsewhere I can open the file without problems.

Any idea ?

Thanks in advance

J


-- 
Javier Leyba
Barcelona - Spain
http://blog.leyba.com.ar

Re: Resource load problem

Posted by Larry Meadors <lm...@apache.org>.
On 8/31/06, Javier Leyba <xl...@gmail.com> wrote:
> Because I use to have all my applications config files in one place,
> and for JBoss, I think the conf directory is the right place.
>
> Am I wrong ?

Depends on what your goal is: If the goal is to write JBoss
applications, no; If the goal is to write portable applications, yes.

Larry

RE: Resource load problem

Posted by "Chen, Tim" <Ti...@NielsenMedia.com>.
Yes you are wrong.
I use iBatis and JBOSS and my config is in my ear/war
Don't put anything in JBoss's conf that you don't intend to be Jboss
specific

-----Original Message-----
From: Javier Leyba [mailto:xleyba@gmail.com] 
Sent: Thursday, August 31, 2006 2:48 AM
To: user-java@ibatis.apache.org
Subject: Re: Resource load problem

On 8/30/06, Nathan Maves <na...@gmail.com> wrote:
> Out of curiosity why would you do this?
>

Hi

Because I use to have all my applications config files in one place, and
for JBoss, I think the conf directory is the right place.

Am I wrong ?

--
Javier Leyba
Barcelona - Spain
http://blog.leyba.com.ar


Re: Resource load problem

Posted by Javier Leyba <xl...@gmail.com>.
On 8/30/06, Nathan Maves <na...@gmail.com> wrote:
> Out of curiosity why would you do this?
>

Hi

Because I use to have all my applications config files in one place,
and for JBoss, I think the conf directory is the right place.

Am I wrong ?

-- 
Javier Leyba
Barcelona - Spain
http://blog.leyba.com.ar

Re: Resource load problem

Posted by Nathan Maves <na...@gmail.com>.
Out of curiosity why would you do this?

On 8/30/06, Javier Leyba <xl...@gmail.com> wrote:
> On 8/29/06, Larry Meadors <lm...@apache.org> wrote:
> > If you use a filename, it is no longer considered a resource.
> >
> > You could use this, though:
> >
> > String smcPath = System.getProperty("jboss.server.home.dir")
> >   + "/conf/SqlMapConfig.xml";
> > Resources.getUrlAsReader("file://" + smcPath);
> >
>
> I've solved the problem placing my config file in the classpath
> because I read api docs where I saw all methods are related to
> classpath..
>
> Is this real ? How could I read my config from a path that isn´t in classpath ?
>
> Thanks in advance
>
>
>
> --
> Javier Leyba
> Barcelona - Spain
> http://blog.leyba.com.ar
>

Re: Resource load problem

Posted by Javier Leyba <xl...@gmail.com>.
On 8/29/06, Larry Meadors <lm...@apache.org> wrote:
> If you use a filename, it is no longer considered a resource.
>
> You could use this, though:
>
> String smcPath = System.getProperty("jboss.server.home.dir")
>   + "/conf/SqlMapConfig.xml";
> Resources.getUrlAsReader("file://" + smcPath);
>

I've solved the problem placing my config file in the classpath
because I read api docs where I saw all methods are related to
classpath..

Is this real ? How could I read my config from a path that isn´t in classpath ?

Thanks in advance



-- 
Javier Leyba
Barcelona - Spain
http://blog.leyba.com.ar

Re: Resource load problem

Posted by Larry Meadors <lm...@apache.org>.
If you use a filename, it is no longer considered a resource.

You could use this, though:

String smcPath = System.getProperty("jboss.server.home.dir")
  + "/conf/SqlMapConfig.xml";
Resources.getUrlAsReader("file://" + smcPath);

Larry


On 8/29/06, Javier Leyba <xl...@gmail.com> wrote:
> Hi
>
> I' ll use iBatis in my JBoss application and want to keep all
> configuration files in my conf directory so I did:
>
> static {
>                 try {
>                         String resource = System.getProperty("jboss.server.home.dir")
>                                                                 + "/conf/SqlMapConfig.xml";
>                         Reader reader = Resources.getResourceAsReader(resource);
>                         sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
>                 } catch (Exception e) {
>                         e.printStackTrace();
>                         throw new RuntimeException(
>                                         "Error initializing MyAppSqlConfig class. Cause: " + e);
>                 }
>
>
> But when I call the application I get the error message:
>
> 12:52:06,764 INFO  [STDOUT] java.io.IOException: Could not find
> resource /home/jcm/jboss-4.0.3SP1/server/javier01/conf/SqlMapConfig.xml
>
> but if open a telent console and do
>
> vi /home/jcm/jboss-4.0.3SP1/server/javier01/conf/SqlMapConfig.xml from
> elsewhere I can open the file without problems.
>
> Any idea ?
>
> Thanks in advance
>
> J
>
>
> --
> Javier Leyba
> Barcelona - Spain
> http://blog.leyba.com.ar
>