Neeldz
Neeldz

Reputation: 131

sqlMapConfig file not found

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

Upvotes: -2

Views: 857

Answers (3)

MangduYogii
MangduYogii

Reputation: 985

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.

Upvotes: 0

Neeldz
Neeldz

Reputation: 131

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.

Upvotes: 0

Alexey Soshin
Alexey Soshin

Reputation: 17691

Put it back into /resources and do:

String resource = "classpath:sqlMapConfig.xml"

Upvotes: 0

Related Questions