LDAP JNDI Tomcat 6 Realm

I am trying to use a JNDIRealm in Tomcat 6 to connect to an active directory server. My server.xml realm tag looks like:
<Realm className="org.apache.catalina.realm.JNDIRealm" connectionName="CN=M123456,OU=Users,OU=NNN,DC=nnnn,DC=nnnnnn,DC=org" connectionPassword="xxxxxxxx" connectionURL="ldap://xxxxxx.xxxxxxxx.xxx:389" userPattern="CN={0}, OU=Users, OU=NNN, DC=nnnn, DC=nnnnn, DC=org" />
When I test my application on my local server, my user name and password don't work. I get no error messages in my local server console. Any ideas on how to debug or correct?
My LDAP information looks like (with selected values shown after "->" symbol):
cn=M123456, OU=NNN, DC=nnnn, DC=nnnnnn, dc=org
homeMDB
badPasswordTime
badPwdCount
objectGUID
telephoneNumber
msExchHomeServerName
st
msExchMailboxGuid
whenChanged
info
name -> M123456
physicalDeliveryOffice Name
lastLogon
departmentNumber
accountExpires
employeeID
description
primaryGroupID
employeeNumber
homeMTA
legacyExchangeDN
userPrincipalName -> [email protected]
sAMAccountName -> M123456
showInAddressBook
uSNCreated
mailNickname
l
businessCategory
msExchPolicesIncluded
pwdLastSet
mDBUseDefaults
logonCount
countryCode
distinguishedName -> CN=M123456,OU=Users,OU=NNN, DC=nnnn, DC=nnnnnn, DC=org
homeDirectory -> \\nnnn.nnnnn.org\nnnhome\users20m2\M123456
msExhOmaAdminWirelessEnable
memberOf
msExhALObjectVersion
whenCreated
userParameters
serialNumber
proxyAddresses
sn
givenName
codePage
homeDrive
objectClass
employeeType
textEncodedORAddress
cn -> M123456
instanceType
initials
msNPAllowDialin
uid -> M123456
displayName
objectCategory
sAMAccountType
uSNChanged
title
objectSid
msExchMailboxSecurityDescriptor
mail
userAccountControl
lastLogonTimestamp
msExchUserAccountControl
scriptPath

Hi All,
I've worked out the problem... It was all to do with Vista / Windows 2008 TCP Auto-Tuning. See this article.
Cheers,
Steve

Similar Messages

  • JSF - Tomcats Realm - General Question

    Hi @ ll,
    I've written a wep app in JSF.
    Evererything works fine. Also the autentification by Tomcats JDBC Realm.
    My problem is. only the login is not written in JSF, cause every form get id prefix.
    I know its "normal" in in JSF.
    But Tomcat expect a submit "j_security_check" without a prifix like "_id0:".
    I don't know to figure it out.
    I've had a look into the Jaas dokumentation. It will take some hours/days to lean it.
    And I think Jaas is overdosed for my very simple webapp.
    Now my general Questen:
    Is it posible to write a simple form based login in Java Server Pages to use Tomcats Realm?
    Is there a simple alternative to Jaas?
    THX 4 your advise.
    esion

    It's not possible with the default set of components.
    That said, there may be a component set that provides a form-based authentication component, but off the top of my head I'm no aware of one.
    It wouldn't be that difficult to roll your own either.

  • LDAP JNDI bootstrap info at each cluster node

    Any suggestions on the best way to distribute LDAP JNDI bootstrap
              information (host:port/DN/pwd/searchbase) to each node in the cluster? I've
              thought of deploying individual bootstrap files, but then I'd have to
              encrypt them and I don't like the idea of these files authentication files
              laying around on (potentially) distributed hosts. Clustered EJBs could use
              an abstraction layer that hides this stuff from them, but the abstraction
              layer needs the bootstrap info before accessing LDAP through JNDI.
              I feel like there's some simple, elegant manner of doing this, but I'm
              missing it because my head is full of LDAP searchbases and filter syntax....
              

    Any suggestions on the best way to distribute LDAP JNDI bootstrap
              information (host:port/DN/pwd/searchbase) to each node in the cluster? I've
              thought of deploying individual bootstrap files, but then I'd have to
              encrypt them and I don't like the idea of these files authentication files
              laying around on (potentially) distributed hosts. Clustered EJBs could use
              an abstraction layer that hides this stuff from them, but the abstraction
              layer needs the bootstrap info before accessing LDAP through JNDI.
              I feel like there's some simple, elegant manner of doing this, but I'm
              missing it because my head is full of LDAP searchbases and filter syntax....
              

  • URGENT HELP NEEDED ... Tomcat Realm and JRE1.4 plug-in problem

    I have tried the Security Realm of Tomcat. Since I do not have
    an LDAP server, I decided to use the Tomcat-users.xml file in
    Tomcat\conf directory.
    I added the following lines of code in the web.xml file.
    <security-constraint>
    <web-resource-collection>
    <web-resource-name>Entire Application</web-resource-name>
    <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
    <!-- NOTE: This role is not present in the default users file -->
    <role-name>webviewer</role-name>
    </auth-constraint>
    </security-constraint>
    <login-config>
    <auth-method>BASIC</auth-method>
    <realm-name>Tomcat Manager Application</realm-name>
    </login-config>
    The <role-name> "webviewer" is added into "Tomcat-Users.xml" as the following:
    <tomcat-users>
    <user name="test" password="password" roles="webviewer" />
    </tomcat-users>
    So, now when we type the url: http://localhost:8080/adbpdbre/default.htm, TOMCAT shows a dialog box asking for UserName: and Password:Now, only when we give the username and password, it shows the page. This is exactly what we want.
    But the problem now is, this default.htm page, has 5 links to 5 applets. The first time that I click on one of these links, the JRE plug of 1.4 shows a dialog again asking for the username and password. Till I dont provide the username and password the system doesnt go ahead and applet doesnt load. I do not want the JRE to ask me for the username/passwords again..How to avoid this ?
    Can you give me some more information on this. Ultimately in the production usage, we will be using LDAP and not Tomcat's memory realm.
    URGENT HELP NEEDED ... I need to get back to my client on this.
    Help would be v. much appreciated.

    In the config file, you 're essentially saying that you want Tomcat to prompt for usr/passw on every request (url-pattern = /*) made by a 'webviewer', and that's exactly what Tomcat is doing.
    Consider using specific url-patterns & roles for resources to be protected. If for now, all you need is to protect the first page, use a more specific url-pattern.
    Just an advice : if you'll be using LDAP in production, do not waste time with Tomcat's Security Realm and the BASIC authentication type, since the two have not much in common. Start reading doc on LDAP, and code a prototype, or even better, a vertical slice of the app (i.e a proof of concept).

  • LDAP + SSL + tomcat- Please help!

    Please help I searched the whole site, i m new to JNDI, Security and E-directory, all I got was confusion, and lots of exception.
    Here's my problem, I trying to run a web application on tomcat web server. I have a login.html, for users to login to my application. Currently all username and password are stored Novell e-directory. Currently I have the following Code.
    <%@page import="javax.naming.*"%>
    <%@page import="javax.naming.directory.*"%>
    <%@page import="java.util.*"%>
    <%@page import=" java.lang.*"%>
    <%@page import="java.security.*"%>
    <%
    String uid = request.getParameter("user");
    // Set up the environment for creating the initial context
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, "ldap://10.1.1.199:636/o=hcfhe");
    env.put(Context.SECURITY_PRINCIPAL, "cn=ldapbrowse, ou=it, o=hcfhe");
    env.put(Context.SECURITY_CREDENTIALS, "ldapbrowse");
    env.put(Context.SECURITY_PROTOCOL,"ssl");
    env.put(Context.SECURITY_AUTHENTICATION, "simple");
    env.put("java.naming.ldap.factory.socket","javax.net.ssl.SSLSocketFactory");
    env.put("java.naming.ldap.version","3");
    System.setProperty("javax.net.ssl.keyStore", "c://j2sdk1.4.0//jre//lib//security//cacerts");
    System.setProperty("javax.net.ssl.keyStorePassword", "changeit");
    System.setProperty("javax.net.ssl.trustStore", "c://j2sdk1.4.0//jre//lib//security//cacerts");
    System.setProperty("javax.net.debug","all");
    // Create the initial context
    try {
    DirContext ctx = new InitialDirContext(env);
    System.out.println("Is it binding..................");
    SearchControls ctls = new SearchControls();
    ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
    NamingEnumeration results = ctx.search("", "(cn="+ uid +")", ctls);
    SearchResult sr = (SearchResult)results.nextElement();
    String dn = sr.getName();
    //String mycon = ((SearchResult)answer.next()).getName();
    System.out.println("DN" + dn);
    // ... do something useful with ctx
    if(dn != null) {
    response.sendRedirect("index2.html");
    ctx.close();
    } catch (NamingException e) {
    System.err.println("Problem getting attribute:" + e);
    e.printStackTrace();
    %>
    I am trying to authenticate my users over SSL to e-directory, and HERE'S where i am totally lost(BTW i can connect to my LDAP directory without SSL. My Network adminsistrator has given me a certificate from the server called SSLMASTER.DER, which I tried install in file called CACERTS in java_home\jre\lib\security using keytool. An it seems like its there using keytool -list command.
    and edited the server.xml:
    <Connector className="org.apache.tomcat.service.PoolTcpConnector">
    <Parameter name="handler" value="org.apache.tomcat.service.http.HttpConnectionHandler"/>
    <Parameter name="port" value="8443"/>
    <Parameter name="socketFactory" value="org.apache.tomcat.net.SSLSocketFactory"/>
    <!--<Parameter name="keystore" value="C:/jakarta-tomcat-3.2.4/conf/.keystore" />-->
    <Parameter name="keystore" value="C:/j2sdk1.4.0/jre/lib/security/cacerts" />
    <Parameter name="keypass" value="changeit"/>
    <Parameter name="clientAuth" value="true"/>
    </Connector>
    Now I start re-start tomcat, and type in the following URL
    http://localhost:8080/college_register/uk/ac/havering-college/index122.html, then i enter the username and password, when submitted it goes to the above java code or even if i do https://localhost:8443/college_register/uk/ac/havering-college/index122.html. I still get the error below.
    javax.naming.CommunicationException: simple bind failed: 10.1.1.199:636. Root e
    xception is javax.net.ssl.SSLHandshakeException: Couldn't find trusted certifica
    te
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.b(DashoA6275)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
    at com.sun.net.ssl.internal.ssl.ClientHandshaker.a(DashoA6275)
    at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(DashoA62
    75)
    at com.sun.net.ssl.internal.ssl.Handshaker.process_record(DashoA6275)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
    at com.sun.net.ssl.internal.ssl.AppOutputStream.write(DashoA6275)
    at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:69
    at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:127)
    at com.sun.jndi.ldap.Connection.writeRequest(Connection.java:385)
    at com.sun.jndi.ldap.LdapClient.ldapBind(LdapClient.java:309)
    at com.sun.jndi.ldap.LdapClient.authenticate(LdapClient.java:168)
    at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2516)
    at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:263)
    at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.jav
    a:76)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
    62)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243
    at javax.naming.InitialContext.init(InitialContext.java:219)
    at javax.naming.InitialContext.<init>(InitialContext.java:195)
    at javax.naming.directory.InitialDirContext.<init>
    please tell me what else i need to do.

    Get a copy of your ldap server's public certificate. Use keytool to import (and create) that cert into a truststore. Configure the ssl props to use the new truststore.

  • Please help me!!! error in run time about connecting ldap in Tomcat 4

    I had a class which used to connect to ldap which is bellow:
    import java.util.*;
    import javax.naming.*;
    import javax.naming.directory.*;
    public class ADLogin
    protected Hashtable env = new Hashtable();
    String _hostname="sisqn074";
    String _port="389";
    public ADLogin()
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.SECURITY_AUTHENTICATION, "simple");
    public boolean authenticate(String username , String password, String domainName)
    boolean b=false;
    try{
    env.put(Context.SECURITY_PRINCIPAL, username.trim() +domainName.trim());
    env.put(Context.SECURITY_CREDENTIALS, password);
    InitialContext ctx = new InitialDirContext(env);
    b=true;
    catch( AuthenticationException e){
    e.printStackTrace();
    b=false;
    catch(NamingException e){
    e.printStackTrace();
    b=false;
    finally{
    //System.out.println("finally");
    return b;
    //set port
    public void setPort(String aport){
    _port=aport;
    //set host name
    public void setHostname(String aName){
    _hostname=aName;
    //initialize
    public boolean initialize(String aHostname,String aPort)
    setPort(aPort);
    setHostname(aHostname);
    env.put(Context.PROVIDER_URL, "ldap://" + hostname + ":" + port);
    return true;
    and I run those codes in tomcat 4.1.21
    now I have a problem , when I use the authenticate method, I use a invalid username which should triger an exception when binding, if the passoword is null , there are no expections and the authenticate would return true on invalid username.
    Those codes is ok in IBM WeBsphere.
    Who can help me ?
    please and thanks.

    hi
    not passing the password, on some directory servers provide u wid an
    annonymous bind and thats what is happening.
    better get this value checked by a javascript for not allowing
    empty password fields
    cheers
    v0d00

  • Access to a Tomcat Realm

    HI! I am trying to get the following code to run, but I still get a nullpointer exception.
    This code is in a servlets init method, and should be loaded on tomcats startup.
    Server server = ServerFactory.getServer();
    //Note, this assumes the Container is "Catalina"
    Service service = server.findService("Catalina");
    Engine engine = (Engine) service.getContainer();
    Host host = (Host) engine.findChild(engine.getDefaultHost());
    //Note, this assumes your context is "myContext"
    Context context = (Context) host.findChild("myContext");
    Realm realm = context.getRealm();I've set the privileged parameter in the webapp/webcontent/meta-inf/context.xml file.
    Why I could'nt access this classes?? Where is my misstake?
    Thank you for your answer!

    Yeah, it looks like we may have to alter the client code to basically pass their login via a "form"....but we'd rather not do that.
    BTW, this is a SOAP server we'll building...so not only would it been a real pain to alter the client's XML output (and therefore our corresponding remote method), but the login data would be even more in plain view.
    :: still searching for a wildard possibility ::

  • How can I use LDAP for Tomcat authentication ?

    Hi
    I have an implementation of apache 1.3.20 with tomcat 3.2.3. I an doing
    auth. with a ldap server wihich works prefectly with apache
    mod_auth_ldap (module). When i am trying to read the environment
    variables with a cgi , REMOTE_USER returns me the authentificated user
    but when i am doing a getremoteuser() in my servlet with tomcat , it
    returns NULL Why ?
    I came accross this page when looking for material and
    http://www.peacetech.com/java/files/apache/tomcat/
    did the following
    1) Downloaded - jndi_auth_beta1.jar, Extracted jndi_auth.jar file which contained
    class files and plcaed them inside my tomcat/lib directory
    2) Then i have updated the server.xml file of my Tomcat, that i wanted to use LDAPRealm
    <RequestInterceptor className="com.peacetech.webtools.tomcat.LdapRealm"
    debug="1"
    directoryUrl = "ldap://csee.usf.edu:389"
    searchBaseContext = "o=usf.edu"
    searchFilter = "uid={0}"
    searchScopeAsString = "sub"
    securityAttributes = "securityEquals"
    attributesReadByOwner = "true"
    connectionMaxPoolSize = "10"
    ldapVersion = "3" />
    Then i had shutdown and restarted the server after some initial hickups, then i have tried to open some sample JSP and sevlets in the examples directory of my server. But i was not asked for any UserId/Password. Was wondering if i have done anything wrong ??
    Thanks
    Arun

    Maybe you should look at JAAS for that. I think it could help you.
    http://java.sun.com/products/jaas/
    C

  • Using LDAP as security realm

    Hi,
    Our goal is to use LDAP(Iplanet Directory Server 5.0) as a security Realm
    for Weblogic Personalization and Commerce 3.5.
    Using the WLCS console, I've modified the config.xml file and following
    elements are added:
    <LDAPRealm AuthProtocol='simple' Credential='admin'
    GroupDN='ou=groups,dc=netnumina,dc=com' GroupIsContext='false'
    GroupUsernameAttribute='uniquemember'
    LDAPURL='ldap://sanand.netnumina.com:389' Name='wlcsLDAPRealm'
    Principal='uid=admin,ou=administrators,ou=topologymanagement,o=netscaperoot'
    UserAuthentication='local' UserDN='ou=people,dc=netnumina,dc=com'
    UserNameAttribute='uid'/>
    <CachingRealm BasicRealm='wlcsLDAPRealm' CacheCaseSensitive='true'
    Name='wlcsCachingRealm'/>
    But when we try to restart the WLCS, it throws java exceptions that context
    is not initialized and I get the following error
    <Jun 15, 2001 3:41:28 PM EDT> <Emergency> <Server> <Unable to initialize the
    ser
    ver: 'Fatal initialization exception
    Throwable: weblogic.security.ldaprealm.LDAPException: could not get
    context - wi
    th nested exception:
    [java.lang.reflect.InvocationTargetException - with target exception:
    [javax.naming.AuthenticationException: [LDAP: error code 49 - Invalid
    Credential
    s]]]
    weblogic.security.ldaprealm.LDAPException: could not get context - with
    nested e
    xception:
    I tried using Windows NT as a security realm but that gave me errors too.
    Does anyone has any experience using anything other than the default Realm?
    Any help would be appreciated. Thanks!
    Asim Raja
    [email protected]

    I'm not sure, but I suspect you can't
    since this would create a circular dependency -
    your realm would rely on the upper level security
    checking calls but those calls would rely on your
    realm.
    My suggestion is to give it a try and see what
    happens.
    -Tom
    Ozcan ADIYAMAN <[email protected]> wrote:
    Hi ,
    I am implementing a simple custom security realm using LDAP as the
    security store and I can see the users, groups and acls from the admin
    console.
    My question is (a custom realm newbie question) ;
    Is it possible to use weblogic.security.acl.Security with my custom
    realm to check permissions, get the current user,etc.,
    OR
    is this class ONLY used with default realms (when ACL is stored in a
    file) ?
    Thanks
    Ozcan

  • LDAP JNDI Error

    Hi all,
    I am trying to just print out fields from JNDI Module Groups which are inside Active Directory. The following is the code I use:-
    for each ad in User
    do
    logMessage "Entered User Name IF loop"
    logMessage " User Name =====: " + ad.givenName
    logMessage" User Name =====: " + ad.uid
    logMessage " User Name =====: " + ad.userPrincipalName
    //requestedByLastName = ad.givenName
    end
    I get the following error:-
    The method 'Person' from class 'Person_Details.Default_1_0.Instance' could not be successfully executed.
    Caused by: [LDAP: error code 4 - Sizelimit Exceeded]
    Could anyone please let me know what exactly is this error because I am doing nothing but printing out values from the AD to ALBPM logMessages..

    Aaaarrgghhhh....
    In your code you have
    // Get all the attributes of named object
    Attributes answer = ctx.getAttributes( "cn=*anna*");If you are just retrieving an object rather than performing a search, you need to use the full distinguished name which means it will be something like:
    Attributes answer = ctx.getAttributes( "cn=Anna,ou=People,dc=osu,dc=edu");And if you ever get around to writing code that performs a search, DO NOT use a search filter of the form:
    "cn=*Anna*"as your query ends up just being a stupid wild card query and will probably not be able to take advantage of any indexes that are present on the DIT.
    You queries will time out and you network admins will become quite angry.

  • LDAP & JNDI

    I'm using the following text in my dn entry while trying to access an LDAP server:
    oEnv.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    oEnv.put(javax.naming.Context.PROVIDER_URL, m_sProviderUrl);
    oEnv.put(javax.naming.Context.SECURITY_AUTHENTICATION, "simple");
    oEnv.put(javax.naming.Context.SECURITY_PRINCIPAL, "uid=user1,dc=domain,dc=com");
    oEnv.put(javax.naming.Context.SECURITY_CREDENTIALS, sPassword);
    This does not work... But if I change the "uid" with "cn":
    (javax.naming.Context.SECURITY_PRINCIPAL, "cn=First Last,dc=domain,dc=com");
    I can access the LDAP server, and the authorization is successful.. Any idea why is that?
    Am I doing something wrong in accessing the LDAP server? Or is there something not configured correctly on my LDAP server??

    beavis,
    If you just want to authenticate the user maybe you could lookup the user's cn first(by using any already authenticated user whose cn is known), then authenticate again using the cn of the user to compose a distinguished name.
    I use kerberos to authenticate with the AD and the user's Windows login id would be used instead.....
    I use the following code to search for a particular user instead of looping around....
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, "ldap://company.com");
    env.put(Context.SECURITY_AUTHENTICATION, "GSSAPI");
    try
    DirContext ctx = new InitialDirContext(env);
    * user login id "userid" for searching
    String filterString = "sAMAccountName=" + userid;
    * specify your interested attributes for the return user
    String[] returnAttr = { "cn", "sAMAccountName" };     
    StringBuffer filterBuffer = new StringBuffer(filterString);
    SearchControls ctls = new SearchControls();
    ctls.setReturningAttributes(returnAttr);
    ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
    * userSearchBase is the distinguished name of the starting OU from where your
    * user will be searched.
    * e.g. "ou=People, dc=company, dc=com"
    NamingEnumeration results = ctx.search(userSearchBase, filterString, ctls);
    if ( results != null && results.hasMore() )
    Wish that could be helpful....

  • JNDI-Tomcat 5.5.17, Cannot create JDBC driver of class '' for connect URL '

    I wrote a jsp program using JNDI to get connected to MySql DB, but i got the error " Cannot load JDBC driver class 'com.mysql.jdbc.Driver' " while running the program.
    I'm using NetBean5.5 which has bundled TomCat5.5.17.
    I've refered to many tutorials and websites, but i still can't solve it, here's my configuration and codes:
    Imported mysql-connector-java-5.0.5-bin into lib directory.
    context.xml:
    <Context path="/WebApplication1">
    <Resource name="jdbc/jsp" auth="Container" type="javax.sql.DataSource"/>
    <ResourceParams name="jdbc/jsp">
    <parameter>
    <name>driverClassName</name>
    <value>com.mysql.jdbc.Driver</value>
    </parameter>
    <parameter>
    <name>url</name>
    <value>jdbc:mysql://localhost:3306/jsp</value>
    </parameter>
    <parameter>
    <name>username</name>
    <value>root</value>
    </parameter>
    <parameter>
    <name>password</name>
    <value>malaysia</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>
    </Context>
    i included the following in Web.xml:
    <resource-ref>
    <res-ref-name>jdbc/jsp</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>
    My JSP Code:
    Context initContext = new InitialContext();
    Context envContext = (Context)initContext.lookup("java:/comp/env");
    DataSource ds = (DataSource)envContext.lookup("jdbc/jsp");
    Connection conn = ds.getConnection();
    Thanks~~~~

    I think mysql jdbc library should add to the class library path of your project.
    Hope this helps.

  • JNDI: Tomcat 5.0 Pulling My HAIR OUT!

    I am working on a site for someone, and I had it set up and running in my development enviroment on Tomcat 6.0. The user ended up signing for a shared account on GODADDY and they use 5.0.27, so I am reworking some stuff to get this working. For some reason, I can not for the life of me get the Connection Pooling to work with this setup, I can make a direct connection. I truly appreciate any help that someone has, I have been all over the forums, I really don't see where I have anything set incorrectly:
    Here is the top half of the stack trace:
    org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
         at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:780)
         at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
         at com.garytech.dao.ConnectionPool.getConnection(ConnectionPool.java:35)
         at com.garytech.servlets.Test.doPost(Test.java:51)
         at com.garytech.servlets.Test.doGet(Test.java:35)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
         at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
         at java.lang.Thread.run(Thread.java:534)
    Caused by: java.sql.SQLException: No suitable driver
         at java.sql.DriverManager.getDriver(DriverManager.java:243)
         at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:773)
         ... 30 moreHere is the Context XML:
    <?xml version="1.0" encoding="UTF-8"?>
    <Context path="/GaryTech">
         <Resource name="jdbc/garytech" auth="Container" type="javax.sql.DataSource"/>
         <ResourceParams name="jdbc/garytech">
              <parameter>
               <name>factory</name>
               <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
             </parameter>
              <paramater>
                   <name>username</name>
                   <value>######</value>
              </paramater>
              <paramater>
                   <name>password</name>
                   <value>######</value>
              </paramater>
              <paramater>
                   <name>driverClassName</name>
                   <value>com.mysql.jdbc.Driver</value>
              </paramater>
              <paramater>
                   <name>url</name>
                   <value>jdbc:mysql://garytech.db.4239767.hostedresource.com?autoReconnect=true</value>
              </paramater>
         </ResourceParams>
    </Context>Here is the Resource Ref in the web.xml:
    <resource-ref>
        <description>DB Connection</description>
        <res-ref-name>jdbc/garytech</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>Here is just some code I threw in a servlet, to show how the direct connection is working and the connection pool is not, the ConnectionPool works fine in other implments, I have not modified that code. The commented out portion works fine, this just kinda was my way of knowing the MySql Driver is working fine and in the correct location. Any ideas PLEASE? :) Thanks!!
              try{
                   String url = "jdbc:mysql://garytech.db.4239767.hostedresource.com";
                   String uName = "";
                   String pwd = "";
                   //Class.forName("com.mysql.jdbc.Driver").newInstance();
                   //Connection connection = (Connection)DriverManager.getConnection(url, uName, pwd);
                   ConnectionPool cp = ConnectionPool.getInstance();
                   Connection connection = cp.getConnection();
                   if(connection != null){
                        System.out.println("connected");
                   connection.close();
              }catch(Exception e){
                   e.printStackTrace();
              }

    Hi Shawn,
    I am going crazy for last 15 days , but not found a solution . I called godaddy people , but no perfect answer . After looking at this thread I got my hopes back . Hopefully you read this message and will reply back.
    I am using godaddy Linux hosting shared environment unlimited with java support .
    I am able to connect to database directly through my JSP or servlet and able to get the result . I mean if I hard code the database connection string,userid and password . But if I use context.xml I am getting null pointer exception on the screen . As per the tomcat configuration install doc if you copy context.xml under META-INF/context.xml It will be picked by tomcat and writes it under conf\Catalina\localhost directory with your jar file name . In shared environment I am not getting a away to check this ..
    Is there any way to check the file copied properly or not to conf\Catalina\localhost directory?
    Or if it doesn't there any other way to implement connection pooling in Godaddy environment?
    and surprisingly the logs what they are asking me to check are under stats directory with error_logs directory . But that doesn't contain much information.Are there any other error logs I can check?
    You mentioned in the above message you were able to check the shared libraries they are hosting. How do I check it?
    Sorry for too many questions , But I am desperate .
    Thanks for your response .
    Regards
    Kiran

  • JAAS and JNDI (LDAP)

    Hello,
    I am using JAAS to connect to a Active Directory and login successfully (Authentication of the user). After the login, I want to get the users property like email address, phone number, ... from the Active Directory using JNDI. As I understand, to get connected to the AD with JNDI I have to use someting like:
    env.put(Context.SECURITY_AUTHENTICATION,"simple");
    env.put(Context.SECURITY_PRINCIPAL,ldapUserName);
    env.put(Context.SECURITY_CREDENTIALS,ldapUserPassword);
    My Problem is now, that I would like to take the user, which has connected to the AD with JASS for accessing the AD, but I do not have the ldapUserPassword from the JAAS Principal (the logged on user).
    Is ther a way to use the current logged in user as LDAP (JNDI) user, or another way, to access the requested proeprties?
    Thanks and Regards
    Stefan

    If had excatly the same problem.
    In my my case I had a domain "testdomain.mycompany.com" and a domain controller "domaincontroller.mycompany.com" (maybe this is a misconfiguration?)
    So I have set in the kerberos config file
    [realms]
            TESTDOMAIN.MYCOMPANY.COM = {
                    kdc = domaincontroller.mycompany.com
            }and the lpad connection url to "ldap://domaincontroller.mycompany.com/dc=testdomain,dc=mycompany,dc=com
    This resulted in the error you have descibed.
    Finally I put the following entry in the hosts file on my local PC
    192.168.0.10 domaincontroller.testdomain.mycompany.com (192.168.0.10 is the ip address of the domain controller) and then it worked!

  • Connecting JNDI with Tomcat

    Need help to conect a server application with Tomcat by JNDI

    exactly what are you trying to do with jndi & tomcat?

Maybe you are looking for

  • Unable to access CIFS shares using SSL Web portal

    Hello, i have deployed Cisco Clientless Web VPN on my ASA5515. I'm having an issue when I try to browse a file server (access CIFS shares) from the WEB VPN portal.   I am prompted for login, and after logging in  I get the "Error contacting host" imm

  • How do i set up generated app password for gmail

    Hi. I don't see an option for setting up generated app passwords for my gmail accounts on the iPad settings menu. (yahoo has a line for password on this screen) I have tried uninstalling and reinstalling (thinking maybe I should use the password on i

  • Please connect to internet, then try again.(Error code: 206) Contact Customer Support

    This is really bad, I tried several type of connection and I still get this. So I can't update or use some of the application. Can someone help me....PLEEEEASE!

  • [solved] Lost playback of musepack (.mpc)

    Whatever is causing this is very recent, it was working just a few days ago. I can still play musepack files through gstreamer via Quod Libet, but I used to be able to play them through MPD and audacious, too. I remember doing so as recently as a wee

  • Schedule Outgoing E-mail

    I can't find a way to delay sending e-mail from Mail by scheduling it for some future time or date. Is there a way to do this?