Hi,
I am a newbie to
Tomcat and am having this problem with configuring Tomcat to use SQL Server 2000 thru JNDI.I am getting a NoInitialContextException.
javax.naming.NoInitialContextException: Need to specify class name in environment or system properly,or as an
applet parameter, or in an application resource file:java.naming.factory.initial
at javax.naming.spi.Namingmanager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.initialContext.lookup(Unknown Source)
at AppLogin.jButton1ActionPerformed(AppLogin.java)
Here is the code I have done..
server.xml
-----------------------------
<GlobalNamingResources>
<Environment name="jdbc/sqlserver" type="javax.sql.DataSource"/>
<Resource name="jdbc/sqlserver" auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/sqlserver">
<parameter>
<name>driverClassName</name>
<value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>
</parameter>
<parameter>
<name>url</name>
<value>
jdbc:microsoft:sqlserver://localhost/Genesis_ProtoType</value>
</parameter>
<parameter>
<name>username</name>
<value>kona</value>
</parameter>
<parameter>
<name>password</name>
<value>kona</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>20</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>10</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>-1</value>
</parameter>
</ResourceParams>
------------------------------
web.xml of my application has the following code
<resource-ref>
<res-ref-name> jdbc/sqlserver</res-ref-name>
<res-type> javax.sql.DataSource</res-type>
<res-auth> Container</res-auth>
</resource-ref>
--------------------------------------------------------
My application code:
String sConStr = "java:comp/env";
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup(sConStr); --->problem
DataSource ds = (DataSource)envCtx.lookup("jdbc/sqlserver");
----------------------------------------------------------
Lookin at the exception I think I am missing a link somewhere.
Can anyone point me in the right direction?
thanks,
Karunakar Kona