I\'m working on Junit test file which loads SQL file and loads it into Oracle:
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
I was getting this error as the jar that has this class was not added to my classpath. Exception was
Exception in thread "main" javax.naming.NoInitialContextException: Cannot instantiate
class: org.apache.naming.java.javaURLContextFactory [Root exception is java.lang.Class
NotFoundException: org.apache.naming.java.javaURLContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.(InitialContext.java:175)
at ContextLoaderTest.setDataSourceInformation(ContextLoaderTest.java:51)
at ContextLoaderTest.main(ContextLoaderTest.java:34)
Caused by: java.lang.ClassNotFoundException: org.apache.naming.java.javaURLContextFact
ory
You need to add the catalina
jar file. For that add following in your Maven dependencies -
org.apache.tomcat
catalina
6.0.43
Note artifact name has changed now. Artifact name is tomcat-catalina
instead of 'catalina '
org.apache.tomcat
tomcat-catalina
8.0.15
. So use latest version from
http://mvnrepository.com/artifact/org.apache.tomcat/tomcat-catalina
than
http://mvnrepository.com/artifact/org.apache.tomcat/catalina