java - unit testing Spring Web app with JConnect -


i having issue attempt unit test dao in webapp. have spring configuration set create datasource bean using sybase jconnect jdbc driver. problem can bean created when run app webapp.

in trying run unit tests, receive:

java.lang.classnotfoundexception: com.sybase.jdbc3.jdbc.sybdriver

to further explain, here directory structure:

src    main      -java        - ...java files etc     - resources         -applicationcontext.xml         -other config files     - webapp         -web-inf            -jconn3.jar   <---- putting here works, test doesn't have web-inf folder!    -test      -java      -resources 

so how allow jconn3.jar recognized @ runtime unit tests? have tried putting in main/resources directoru, causes failure regardless of whether i'm running webapp or not. can see jconn3.jar gets copied target/classes directory on build, why jar not found @ runtime? seems way work keep in web-inf directory, how unit test dao depends on it.

i using spring mvc , maven. note cannot add maven dependency since jar not in repository, nor have option add remote repo.

so sum up, need have jar on build path both running webapp , unit testing since both need jar dao. how achieve when placing in resources folder doesn't seem help.

you have put jconn3.jar in execution classpath of tests. if you're using maven seems you're doing have add dependency corresponding driver in pom. since sybase jdbc driver not available in central maven have upload local repository using command this:

guide installing 3rd party jars

mvn install:install-file -dfile=<path-to-file> -dgroupid=<group-id> \     -dartifactid=<artifact-id> -dversion=<version> -dpackaging=<packaging> 

once have done can add dependency jar same way other jar in maven central

<dependency>     <groupid>group-id></groupid>     <artifactid>artifact-id</artifactid>     <version>version</version> </dependency> 

from point on sybase driver jar included in tests execution classpath...

you adding jar web-inf directory , don't need to. maven smart enough deduce dependencies jar files need go inside war can remove web-inf location. don't worry, when execute mvn package jar driver wind in war file


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -