-2

enter image description hereAm facing weird issue while trying to launch my web application

Could not find resource sqlMapConfig.xml

my project use maven with an embedded Tomcat : i did try to add the file under class path , i did try to add
the sqlMapConfig.xml file into Resources but that didnt work.. what is weird that if i try to do maven update project from eclipse and try to launch the application from the eclipse sometimes the project found the config file but that is not always the case , I need to build the package and launch the jar by using maven and cmd.... below a screen shot of my code eclipse hierarchy

main class

initialize the sqlmap Sqlconfig is under db package

Neeldz
  • 131
  • 2
  • 13

3 Answers3

0

Put it back into /resources and do:

String resource = "classpath:sqlMapConfig.xml"
Alexey Soshin
  • 16,718
  • 2
  • 31
  • 40
  • i did and i still have the same error i will add a new screen shot so if the is any missing link could help thx anw – Neeldz Sep 20 '16 at 18:11
0

I did figure it out my problem but still not understanding why maybe cause of my lack of maven experience :

all i had to do was just update maven project from eclipse then do the mvn package from cmd it seems that mvn compile were corrupting my files but as i was saying that i have no clue why yet.

Neeldz
  • 131
  • 2
  • 13
0

Here / before config file and put this file in resources folder

private static String path= "/sqlmap-config.xml";

public static SqlMapClient getSqlMapInstance() throws IOException {
        Reader reader = Resources.getResourceAsReader(path);
        sqlMapClient = SqlMapClientBuilder.buildSqlMapClient(reader);

        return sqlMapClient;

    }

NOTE: make sure your sqlmap-config.xml is located in classpath resoures folder.

MangduYogii
  • 935
  • 10
  • 24