Could not find resource error

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Could not find resource error

Janluc
Hi there,
I am a completely newbie with iBbatis, Eclipse, and even with Java development, so I hope you'll exercise a bit of patience with me :-)

There is my problem: I'm trying to integrate iBatis' sqlmaps  into an Eclipse plugin I am developing. I generated all the abator artifacts and a TestSqlConfig.java class which builds the SqlMapClient.
Then I wrote a "main" in my plugin's Application class which should simply add a record to one of the tables of my db.
But I keep getting those "Could not find resource SqlMapConfig.xml" wherever I put this file.

This is an extract from my TestSqlConfig class:

                        //FileReader reader = new FileReader("e:/SqlMapConfig.xml");
                        String resource = "SqlMapConfig.xml";
                        Reader reader = Resources.getResourceAsReader(resource);
                        sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

Note that SqlMapConfig.xml is in the "root" directory of my plugin (fr.grenoble.db).
I tried to copy it in the fr.grenoble.db/src/fr.grenoble.db folder where the TestSqlConfig class lies, or even in the plugin I created to bundle all iBatis' jars.
I tried different values for the string resource, like "fr.grenoble.db/SqlMapConfig.xml", "fr/grenoble/db/SqlMapConfig.xml", "/fr/grenoble/db/SqlMapConfig.xml" "/SqlMapConfig.xml", but had no luck in none of them.

The only way for it to load the SqlMapConfig.xml file is to use the FileReader solution, but the problem arises again when it needs to load the first map file.

Is anybody willing to help me in sorting things out?
Thanks in advance.

JL

java.io.IOException: Could not find resource SqlMapConfig.xml
        at com.ibatis.common.resources.Resources.getResourceAsStream(Resources.java:101)
        at com.ibatis.common.resources.Resources.getResourceAsStream(Resources.java:86)
        at com.ibatis.common.resources.Resources.getResourceAsReader(Resources.java:150)
        at fr.grenoble.db.TestSqlConfig.<clinit>(TestSqlConfig.java:31)
        at fr.grenoble.db.Application.run(Application.java:21)
        at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334)
        at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
        at org.eclipse.core.launcher.Main.run(Main.java:973)
        at org.eclipse.core.launcher.Main.main(Main.java:948)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Could not find resource error

Jeff Butler-2
I don't completely follow what you're trying to do, but there's obviously some classloader confusion.
 
Eclipse plugins run in their own class loaders.  The plugin classloader does not contain workspace classes in its path, so plugins cannot see workspace classes.  My guess is that you are getting caught up in some of that confusion.
 
Jeff Butler
 

 
On 3/20/06, Janluc <[hidden email]> wrote:

Hi there,
I am a completely newbie with iBbatis, Eclipse, and even with Java
development, so I hope you'll exercise a bit of patience with me :-)

There is my problem: I'm trying to integrate iBatis' sqlmaps  into an
Eclipse plugin I am developing. I generated all the abator artifacts and a
TestSqlConfig.java class which builds the SqlMapClient.
Then I wrote a "main" in my plugin's Application class which should simply
add a record to one of the tables of my db.
But I keep getting those "Could not find resource SqlMapConfig.xml" wherever
I put this file.

This is an extract from my TestSqlConfig class:

                       //FileReader reader = new FileReader("e:/SqlMapConfig.xml");
                       String resource = "SqlMapConfig.xml";
                       Reader reader = Resources.getResourceAsReader(resource);
                       sqlMap = SqlMapClientBuilder.buildSqlMapClient (reader);

Note that SqlMapConfig.xml is in the "root" directory of my plugin
(fr.grenoble.db).
I tried to copy it in the fr.grenoble.db/src/fr.grenoble.db folder where the
TestSqlConfig class lies, or even in the plugin I created to bundle all
iBatis' jars.
I tried different values for the string resource, like
"fr.grenoble.db/SqlMapConfig.xml", "fr/grenoble/db/SqlMapConfig.xml",
"/fr/grenoble/db/SqlMapConfig.xml" "/SqlMapConfig.xml", but had no luck in
none of them.

The only way for it to load the SqlMapConfig.xml file is to use the
FileReader solution, but the problem arises again when it needs to load the
first map file.

Is anybody willing to help me in sorting things out?
Thanks in advance.

JL

java.io.IOException: Could not find resource SqlMapConfig.xml
       at
com.ibatis.common.resources.Resources.getResourceAsStream(Resources.java:101)
       at
com.ibatis.common.resources.Resources.getResourceAsStream (Resources.java:86)
       at
com.ibatis.common.resources.Resources.getResourceAsReader(Resources.java:150)
       at fr.grenoble.db.TestSqlConfig.<clinit>(TestSqlConfig.java:31)
       at fr.grenoble.db.Application.run (Application.java:21)
       at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226)
       at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376)
       at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334)
       at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
       at org.eclipse.core.launcher.Main.run(Main.java:973)
       at org.eclipse.core.launcher.Main.main(Main.java:948)

--
View this message in context: http://www.nabble.com/Could-not-find-resource-error-t1310881.html#a3492688
Sent from the iBATIS - User - Java forum at Nabble.com.


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Could not find resource error

Janluc
Thanks Jeff, following your suggestions I investigated those arcane classloader issues and I came up with a partially satisfactory solution.

Let me try to explain what I was trying to do:
First I "bundled" all iBatis jars and the MySQL J/Connector jar into an Eclipse plugin, by using the "New Plugin from Existing Jars" wizard. I called it org.apache.ibatis.
Then I created my sample RCP test application to test the iBatis connection and normal db activities, I called it fr.grenoble.db. In this plugin I generated all the abator artifacts: the sqlmaps, the java classes and the dao classes.
After that, in this db plugin I created a simple Application.java whose only job is to insert a row in a table of the database.

But initially I kept getting those "resource not found errors" during runtime, so, after your suggestion, and digging into the documentation, I found that I would've probably needed to use some "buddy classloading" spells. So I added the line:

Eclipse-BuddyPolicy: registered

into the MANIFEST.MF of the org.apache.ibatis "plugin", and the line:

Eclipse-RegisterBuddy: org.apache.ibatis

into the MANIFEST.MF of the fr.grenoble.db plugin.

By doing that, the "resource not found" issue seemed to be solved.

But now, I get another error: when I try to use the

sqlMap.insert("abatorgenerated_insert", se);

in my Application.java class, I get this error message:

!ENTRY org.eclipse.osgi 2006-03-21 16:46:38.87
!MESSAGE Application error
!STACK 1
com.ibatis.sqlmap.client.SqlMapException: There is no statement named abatorgenerated_insert in this SqlMap.
        at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.getMappedStatement(SqlMapExecutorDelegate.java:288)
        at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:424)
        at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java:81)
        at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.insert(SqlMapClientImpl.java:58)
        at fr.grenoble.db.Application.run(Application.java:41)
        at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334)
        at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
        at org.eclipse.core.launcher.Main.run(Main.java:973)
        at org.eclipse.core.launcher.Main.main(Main.java:948)

However, I can see that statement in the system_element_SqlMap.xml file:

  <insert id="abatorgenerated_insert" parameterClass="fr.grenoble.db.model.SystemElement">
   
    insert into system_element (SE_ID, SE_PARENT_ID, SE_NAME, SE_TYPE,
      SE_DESCRIPTION)
    values (#seId:INTEGER#, #seParentId:INTEGER#, #seName:VARCHAR#,
      #seType:VARCHAR#, #seDescription:VARCHAR#)
  </insert>

I searched in the archive for similar errors and I found that I must use the
useStatementNamespaces="true" in my SqlMapConfig.xml, which I do, but I still get the same error.

Any clue?

Thanks again!

JL


Jeff Butler-2 wrote
I don't completely follow what you're trying to do, but there's obviously
some classloader confusion.

Eclipse plugins run in their own class loaders.  The plugin classloader does
not contain workspace classes in its path, so plugins cannot see workspace
classes.  My guess is that you are getting caught up in some of that
confusion.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Could not find resource error

Jeff Butler-2
Wow!  Great job on figuring this out.  You're so close...
 
I think the only thing you need to change is on your insert statement:
 
sqlMap.insert("NAMESPACE.abatorgenerated_insert", se);
 
Where NAMESPACE is the namespace of the generated SQL Map - you can see it on the <sqlMap> element in the XML file.  When you enable statement namespaces, all statement ids must be qualified like this.
 
Jeff Butler


 
On 3/21/06, Janluc <[hidden email]> wrote:

Thanks Jeff, following your suggestions I investigated those arcane
classloader issues and I came up with a partially satisfactory solution.

Let me try to explain what I was trying to do:
First I "bundled" all iBatis jars and the MySQL J/Connector jar into an
Eclipse plugin, by using the "New Plugin from Existing Jars" wizard. I
called it org.apache.ibatis.
Then I created my sample RCP test application to test the iBatis connection
and normal db activities, I called it fr.grenoble.db. In this plugin I
generated all the abator artifacts: the sqlmaps, the java classes and the
dao classes.
After that, in this db plugin I created a simple Application.java whose only
job is to insert a row in a table of the database.

But initially I kept getting those "resource not found errors" during
runtime, so, after your suggestion, and digging into the documentation, I
found that I would've probably needed to use some "buddy classloading"
spells. So I added the line:

Eclipse-BuddyPolicy: registered

into the MANIFEST.MF of the org.apache.ibatis "plugin", and the line:

Eclipse-RegisterBuddy: org.apache.ibatis

into the MANIFEST.MF of the fr.grenoble.db plugin.

By doing that, the "resource not found" issue seemed to be solved.

But now, I get another error: when I try to use the

sqlMap.insert("abatorgenerated_insert", se);

in my Application.java class, I get this error message:

!ENTRY org.eclipse.osgi 2006-03-21 16:46: 38.87
!MESSAGE Application error
!STACK 1
com.ibatis.sqlmap.client.SqlMapException: There is no statement named
abatorgenerated_insert in this SqlMap.
       at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.getMappedStatement (SqlMapExecutorDelegate.java:288)
       at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:424)
       at
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java :81)
       at
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.insert(SqlMapClientImpl.java:58)
       at fr.grenoble.db.Application.run(Application.java:41)
       at
org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:226)
       at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376)
       at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334)
       at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
       at org.eclipse.core.launcher.Main.run (Main.java:973)
       at org.eclipse.core.launcher.Main.main(Main.java:948)

However, I can see that statement in the system_element_SqlMap.xml file:

<insert id="abatorgenerated_insert"
parameterClass=" fr.grenoble.db.model.SystemElement">
   <!--
     WARNING - This element is automatically generated by Abator for
iBATIS, do not modify.
     This element was generated on Tue Mar 21 16:45:59 CET 2006.
   -->
   insert into system_element (SE_ID, SE_PARENT_ID, SE_NAME, SE_TYPE,
     SE_DESCRIPTION)
   values (#seId:INTEGER#, #seParentId:INTEGER#, #seName:VARCHAR#,
     #seType:VARCHAR#, #seDescription:VARCHAR#)
</insert>

I searched in the archive for similar errors and I found that I must use the
useStatementNamespaces="true" in my SqlMapConfig.xml, which I do, but I
still get the same error.

Any clue?

Thanks again!

JL



Jeff Butler-2 wrote:

>
> I don't completely follow what you're trying to do, but there's obviously
> some classloader confusion.
>
> Eclipse plugins run in their own class loaders.  The plugin classloader
> does
> not contain workspace classes in its path, so plugins cannot see workspace
> classes.  My guess is that you are getting caught up in some of that
> confusion.
>
--
View this message in context: http://www.nabble.com/Could-not-find-resource-error-t1310881.html#a3515034
Sent from the iBATIS - User - Java forum at Nabble.com.


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Could not find resource error

Janluc
Yeah! That worked! I am *so* proud of my first working sqlmap insert! I told everbody in my room and was looked in bewilderment...

From the Application.java class:

		SystemElement se = new SystemElement();
		se.setSeName("test");
		se.setSeType("test type");
		se.setSeDescription("description bla bla bla");
		try {
			sqlMap.insert("system_element.abatorgenerated_insert", se);
		} catch (SQLException e) {
			e.printStackTrace();
		}
After execution, in the mysql client app:
mysql> select * from system_element;
+-------+--------------+---------+-----------+-------------------------+
| SE_ID | SE_PARENT_ID | SE_NAME | SE_TYPE   | SE_DESCRIPTION          |
+-------+--------------+---------+-----------+-------------------------+
|     1 |         NULL | test    | test type | description bla bla bla |
+-------+--------------+---------+-----------+-------------------------+
1 row in set (0.00 sec)

*shouts of joy*

Thank you a lot, Jeff!

JL

Jeff Butler-2 wrote
Wow! Great job on figuring this out. You're so close... I think the only thing you need to change is on your insert statement: sqlMap.insert("NAMESPACE.abatorgenerated_insert", se); Where NAMESPACE is the namespace of the generated SQL Map - you can see it on the element in the XML file. When you enable statement namespaces, all statement ids must be qualified like this. Jeff Butler
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Could not find resource error

bkmartin
Hi there,

Today I'm having the same error that you resolved back in March of 2006.  Wondering if you could share some more clues with me - if you still are tuned into this thread?

Do you do all of the up-front connection stuff (establish the SQLmap, etc) in your Application class?
Also, do you keep your db connection stuff in a priority file?

How did you package this up (properties to be configured at deployment) - any pointers?

Thanks for any hints you can provide.  
In the meantime I'll add your Buddy class loading stuff.

Thank you,

Bryon

Janluc wrote
Yeah! That worked! I am *so* proud of my first working sqlmap insert! I told everbody in my room and was looked in bewilderment...

<p>From the Application.java class:

<pre>
                SystemElement se = new SystemElement();
                se.setSeName("test");
                se.setSeType("test type");
                se.setSeDescription("description bla bla bla");
                try {
                        sqlMap.insert("system_element.abatorgenerated_insert", se);
                } catch (SQLException e) {
                        e.printStackTrace();
                }
</pre>

After execution, in the mysql client app:

<pre>
mysql> select * from system_element;
+-------+--------------+---------+-----------+-------------------------+
| SE_ID | SE_PARENT_ID | SE_NAME | SE_TYPE   | SE_DESCRIPTION          |
+-------+--------------+---------+-----------+-------------------------+
|     1 |         NULL | test    | test type | description bla bla bla |
+-------+--------------+---------+-----------+-------------------------+
1 row in set (0.00 sec)
</pre>

<p>*shouts of joy*

<p>Thank you a lot, Jeff!

<p>JL

Jeff Butler-2 wrote
Wow!  Great job on figuring this out.  You're so close...

I think the only thing you need to change is on your insert statement:

sqlMap.insert("NAMESPACE.abatorgenerated_insert", se);

Where NAMESPACE is the namespace of the generated SQL Map - you can see it
on the <sqlMap> element in the XML file.  When you enable statement
namespaces, all statement ids must be qualified like this.

Jeff Butler
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Could not find resource error

RickyTurin
In reply to this post by Janluc

Janluc wrote
Hi there,
I am a completely newbie with iBbatis, Eclipse, and even with Java development, so I hope you'll exercise a bit of patience with me :-)

There is my problem: I'm trying to integrate iBatis' sqlmaps  into an Eclipse plugin I am developing. I generated all the abator artifacts and a TestSqlConfig.java class which builds the SqlMapClient.
Then I wrote a "main" in my plugin's Application class which should simply add a record to one of the tables of my db.
But I keep getting those "Could not find resource SqlMapConfig.xml" wherever I put this file.

This is an extract from my TestSqlConfig class:

                        //FileReader reader = new FileReader("e:/SqlMapConfig.xml");
                        String resource = "SqlMapConfig.xml";
                        Reader reader = Resources.getResourceAsReader(resource);
                        sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

Note that SqlMapConfig.xml is in the "root" directory of my plugin (fr.grenoble.db).
I tried to copy it in the fr.grenoble.db/src/fr.grenoble.db folder where the TestSqlConfig class lies, or even in the plugin I created to bundle all iBatis' jars.
I tried different values for the string resource, like "fr.grenoble.db/SqlMapConfig.xml", "fr/grenoble/db/SqlMapConfig.xml", "/fr/grenoble/db/SqlMapConfig.xml" "/SqlMapConfig.xml", but had no luck in none of them.

The only way for it to load the SqlMapConfig.xml file is to use the FileReader solution, but the problem arises again when it needs to load the first map file.

Is anybody willing to help me in sorting things out?
Thanks in advance.

JL

java.io.IOException: Could not find resource SqlMapConfig.xml
        at com.ibatis.common.resources.Resources.getResourceAsStream(Resources.java:101)
        at com.ibatis.common.resources.Resources.getResourceAsStream(Resources.java:86)
        at com.ibatis.common.resources.Resources.getResourceAsReader(Resources.java:150)
        at fr.grenoble.db.TestSqlConfig.<clinit>(TestSqlConfig.java:31)
        at fr.grenoble.db.Application.run(Application.java:21)
        at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334)
        at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
        at org.eclipse.core.launcher.Main.run(Main.java:973)
        at org.eclipse.core.launcher.Main.main(Main.java:948)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Could not find resource error

RickyTurin
In reply to this post by Janluc

Janluc wrote
Hi there,
I am a completely newbie with iBbatis, Eclipse, and even with Java development, so I hope you'll exercise a bit of patience with me :-)

There is my problem: I'm trying to integrate iBatis' sqlmaps  into an Eclipse plugin I am developing. I generated all the abator artifacts and a TestSqlConfig.java class which builds the SqlMapClient.
Then I wrote a "main" in my plugin's Application class which should simply add a record to one of the tables of my db.
But I keep getting those "Could not find resource SqlMapConfig.xml" wherever I put this file.

This is an extract from my TestSqlConfig class:

                        //FileReader reader = new FileReader("e:/SqlMapConfig.xml");
                        String resource = "SqlMapConfig.xml";
                        Reader reader = Resources.getResourceAsReader(resource);
                        sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

Note that SqlMapConfig.xml is in the "root" directory of my plugin (fr.grenoble.db).
I tried to copy it in the fr.grenoble.db/src/fr.grenoble.db folder where the TestSqlConfig class lies, or even in the plugin I created to bundle all iBatis' jars.
I tried different values for the string resource, like "fr.grenoble.db/SqlMapConfig.xml", "fr/grenoble/db/SqlMapConfig.xml", "/fr/grenoble/db/SqlMapConfig.xml" "/SqlMapConfig.xml", but had no luck in none of them.

The only way for it to load the SqlMapConfig.xml file is to use the FileReader solution, but the problem arises again when it needs to load the first map file.

Is anybody willing to help me in sorting things out?
Thanks in advance.

JL

java.io.IOException: Could not find resource SqlMapConfig.xml
        at com.ibatis.common.resources.Resources.getResourceAsStream(Resources.java:101)
        at com.ibatis.common.resources.Resources.getResourceAsStream(Resources.java:86)
        at com.ibatis.common.resources.Resources.getResourceAsReader(Resources.java:150)
        at fr.grenoble.db.TestSqlConfig.<clinit>(TestSqlConfig.java:31)
        at fr.grenoble.db.Application.run(Application.java:21)
        at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334)
        at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
        at org.eclipse.core.launcher.Main.run(Main.java:973)
        at org.eclipse.core.launcher.Main.main(Main.java:948)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Could not find resource error

RickyTurin
In reply to this post by Janluc

Janluc wrote
Hi there,
I am a completely newbie with iBbatis, Eclipse, and even with Java development, so I hope you'll exercise a bit of patience with me :-)

There is my problem: I'm trying to integrate iBatis' sqlmaps  into an Eclipse plugin I am developing. I generated all the abator artifacts and a TestSqlConfig.java class which builds the SqlMapClient.
Then I wrote a "main" in my plugin's Application class which should simply add a record to one of the tables of my db.
But I keep getting those "Could not find resource SqlMapConfig.xml" wherever I put this file.

This is an extract from my TestSqlConfig class:

                        //FileReader reader = new FileReader("e:/SqlMapConfig.xml");
                        String resource = "SqlMapConfig.xml";
                        Reader reader = Resources.getResourceAsReader(resource);
                        sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

Note that SqlMapConfig.xml is in the "root" directory of my plugin (fr.grenoble.db).
I tried to copy it in the fr.grenoble.db/src/fr.grenoble.db folder where the TestSqlConfig class lies, or even in the plugin I created to bundle all iBatis' jars.
I tried different values for the string resource, like "fr.grenoble.db/SqlMapConfig.xml", "fr/grenoble/db/SqlMapConfig.xml", "/fr/grenoble/db/SqlMapConfig.xml" "/SqlMapConfig.xml", but had no luck in none of them.

The only way for it to load the SqlMapConfig.xml file is to use the FileReader solution, but the problem arises again when it needs to load the first map file.

Is anybody willing to help me in sorting things out?
Thanks in advance.

JL

java.io.IOException: Could not find resource SqlMapConfig.xml
        at com.ibatis.common.resources.Resources.getResourceAsStream(Resources.java:101)
        at com.ibatis.common.resources.Resources.getResourceAsStream(Resources.java:86)
        at com.ibatis.common.resources.Resources.getResourceAsReader(Resources.java:150)
        at fr.grenoble.db.TestSqlConfig.<clinit>(TestSqlConfig.java:31)
        at fr.grenoble.db.Application.run(Application.java:21)
        at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334)
        at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
        at org.eclipse.core.launcher.Main.run(Main.java:973)
        at org.eclipse.core.launcher.Main.main(Main.java:948)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Could not find resource error

RickyTurin
Hi Guys. I'm sorry for to have paste the previous e-mail.
My English is not very well, but I need to help for Ibatis.
I have the same problem with the same message (Could not found resource). Can you help me? Can you repeat how can solve the problem? What must I get to do?

Thanks a lot  
Loading...