Tomcat configuration (mysql db)

Here are the specs:
C:\Program Files\netbeans-4.1\enterprise1\jakarta-tomcat-5.5.7\conf\server.xml file
<Server port="8005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
  <GlobalNamingResources>
    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
       description="User database that can be updated and saved"
           factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
          pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>
  <Service name="Catalina">
    <Connector port="8080"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               connectionTimeout="20000" disableUploadTimeout="true" />
    <Connector port="8009"
               enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
    <Engine name="Catalina" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>
      <Host name="localhost" appBase="webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">
          <Context path="/WEB/DBTest" docBase="DBTest"
        debug="5" reloadable="true" crossContext="true">
  <Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"
               maxActive="100" maxIdle="30" maxWait="10000"
               username="javauser" password="javadude" driverClassName="com.mysql.jdbc.Driver"
               url="jdbc:mysql://localhost:3306/javatest?autoReconnect=true"/>
</Context>
      </Host>
    </Engine>
  </Service>
</Server>C:\Program Files\netbeans-4.1\enterprise1\jakarta-tomcat-5.5.7\webapps\WEB\DBTest\WEB-INF\web.xml file
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">
  <description>MySQL Test App</description>
  <resource-ref>
      <description>DB Connection</description>
      <res-ref-name>jdbc/TestDB</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
  </resource-ref>
</web-app>
C:\Program Files\netbeans-4.1\enterprise1\jakarta-tomcat-5.5.7\webapps\WEB\DBTest\index.jsp file
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<sql:query var="rs" dataSource="jdbc/TestDB">
select id, foo, bar from testdata
</sql:query>
<html>
  <head>
    <title>DB Test</title>
  </head>
  <body>
  <h2>Results</h2>
<c:forEach var="row" items="${rs.rows}">
    Foo ${row.foo}<br/>
    Bar ${row.bar}<br/>
</c:forEach>
  </body>
</html>
Files under C:\Program Files\netbeans-4.1\enterprise1\jakarta-tomcat-5.5.7\webapps\WEB\DBTest\WEB-INF\lib folder:
commons-collections-3.1.jar
commons-dbcp-1.2.1.jar
commons-pool-1.2.jar
jstl.jar
mysql-connector-java-3.1.10-bin.jar
mysql-connector-java-3.1.10-bin-g.jar
standard.jar
ERROR that I get
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Unable to get connection, DataSource invalid: "org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'"
     org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:846)
     org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
     org.apache.jsp.DBTest.index_jsp._jspService(index_jsp.java:84)
     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'"
     org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(QueryTagSupport.java:276)
     org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(QueryTagSupport.java:159)
     org.apache.jsp.DBTest.index_jsp._jspx_meth_sql_query_0(index_jsp.java:103)
     org.apache.jsp.DBTest.index_jsp._jspService(index_jsp.java:59)
     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.7 logs.
Apache Tomcat/5.5.7What is the problem?

Good to hear you got it working.
Just as a comment on this, rather than editing server.xml, I find it easier to work with a specific "context.xml" configuration for each web application.
Information can be found here: http://jakarta.apache.org/tomcat/tomcat-5.5-doc/config/context.html
Basically it means instead of defining the <context> and all the database connection parameters in server.xml, you put that into a seperate file, and leave server.xml alone.
Most probable this file would be [TOMCAT]/confCatalina/localhost/myApp.xml
Cheers,
evnafets

Similar Messages

  • How use Tomcat with MySQL

    Can anybody suggest me as how to use Tomcat with MySQL server.
    Thanks in advance.
    Khiz_eng

    add the classpath to the JDBC-driver to the tomcat-
    environment (I did it in tomcat.sh)
    Then put your code accessing MySQL into a servlet....
    You can put the user-ID and the password into a session-
    object or read them in as parameters.
    The book 'core Servlets and Java Server Pages' from
    Marty Hall gave me a lot information.
    Regards
    Fredy

  • How do i get started configuring MySql

    I have a Xserve G5 running OS X 10.5.6. I am new to this and I haven't got much experience using MySql on OS X Server. Can any one help explaining how to configure MySql for mear mortals. Starting the service is of corse simple but the steps involved from that point on are where im getting lost.
    my apologies for the vagueness however the literature on the internet is vary vague and limited.
    ~Thanks

    Hi,
    I have setup mysql for use with a rails project using the version installed with server 10.5 and associated directory dependencies as given in the Web Technologies setup manual. I think there are other posts providing efforts to install a separate mysql from scratch.
    Anyway - my procedure was setup MySQL Service in Server Admin
    Initial Conditions:
    I wanted my databases to be stored on an external drive:
    1. Server -> Settings -> Services with MySQL checked. Save panel.
    2. Set permissions on /Volumes/<ext drive folder path>
    owner = _mysql, group = admin
    owner rwx, group rx, world rx (r=read, w=write, x=execute)
    MySQL Settings panel
    1. Check – Allow network connections (if connecting remotely)
    2. Set database location to - /Volumes/<ext drive folder path>
    3. Set MySQL Root Password – xxxxxxxx
    4. Save and start MySQL service
    5. In MySQL logs verify MySQL daemon started
    and datadir = /Volumes/<ext drive folder path> with log entries for service up and running
    6. In Terminal create a database:
    mysqladmin –u root –p create <database name>
    Note that database names are lowercase (case insensitive file names)
    from here you can access the database with the tool of your choice. For a ruby on rails application I was able to upload data with fixtures and interact with the data through the script/console.
    HTH,
    Harry

  • Step by step to set up tomcat with mysql

    hi i'm new to these things, well i went through the forum , there are load of info but no1 has explain how to set up (step by step) tomcat with mysql using jdbc driver ( also i'll use jsp pages to get info from the database.)
    thx alot.

    Hiya,
    Best way would be to read the README.doc that you get after the installation on the sysetm. Becuase this provided you with the exact info. pertianing to the sysetm etc that you have and also visit this website:
    http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_20148108.html
    It gives u a step by step guide to set-up and some sample codes also to test etc.
    Happy Javaing, Cheers

  • Help - JSC to Tomcat with MySql

    I built a simple test app in JSC with MySql.
    Product: MySql Ver. 5.0.27-community-nt
    Database name: Test
    Table name: testtable
    Datasource name: MySql1
    Dataprovider's SQL: SELECT ALL testtable.code, testtable.name FROM testtable WHERE testtable.name LIKE ?
    The page had a textfield, button, statictext and a table mapped to the dataprovider
    The following code was included:
    public void prerender() {
    try {
    String s = "";
    String t = (String) textField1.getText();
    if (t == null || t.equals(""))
    s = "";
    else
    s = t;
    s += "%";
    staticText3.setText(s);
    getSessionBean1().getTesttableRowSet().setObject(1,s);
    getSessionBean1().getTesttableDataProvider().refresh();
    } catch (Exception e) {error(e.toString());}
    public String button1_action() {
    return null;
    When tested in JSC, it worked fine.
    But when I exported it as a war file and deployed it in Tomcat 5.5.17 with the following settings, the statictext
    displayed the selected value, but the table showed "No items found". Please help.
    User: root
    password: adminadmin
    Connector downloaded: mysql-connector-java-5.0.4.zip
    The appropriate jstl.jar and standard.jar where used by copying them from jakarta
    The tomcat's server.xml used is shown below:
    <?xml version="1.0" encoding="UTF-8"?>
    <Server>
    <Listener className="org.apache.catalina.core.AprLifecycleListener"/>
    <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
    <Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
    <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
    <GlobalNamingResources>
    <Environment
    name="simpleValue"
    type="java.lang.Integer"
    value="30"/>
    <Resource
    auth="Container"
    description="User database that can be updated and saved"
    name="UserDatabase"
    type="org.apache.catalina.UserDatabase"
    pathname="conf/tomcat-users.xml"
    factory="org.apache.catalina.users.MemoryUserDatabaseFactory"/>
    <Resource
    name="jdbc/Travel"
    type="javax.sql.DataSource"
    driverClassName="org.apache.derby.jdbc.ClientDriver"
    password="travel"
    maxIdle="2"
    maxWait="5000"
    validationQuery="select * from TRAVEL.PRODUCT"
    username="travel"
    url="jdbc:derby://localhost:21527/samp"
    maxActive="4"/>
    </GlobalNamingResources>
    <Service
    name="Catalina">
    <Connector
    port="8080"
    redirectPort="8443"
    minSpareThreads="25"
    connectionTimeout="20000"
    maxThreads="150"
    maxSpareThreads="75">
    </Connector>
    <Connector
    port="8009"
    redirectPort="8443"
    protocol="AJP/1.3">
    </Connector>
    <Engine
    defaultHost="localhost"
    name="Catalina">
    <Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>
    <Host
    appBase="webapps"
    name="localhost">
    <Context
    path="/TomTest">
    </Context>
    <Context
    path="/TradeMeTender">
    <Resource
    auth="Container"
    description="Creator generated DataSource Reference"
    name="jdbc/Travel"
    type="javax.sql.DataSource"
    driverClassName="org.apache.derby.jdbc.ClientDriver"
    password="travel"
    maxIdle="2"
    maxWait="5000"
    validationQuery="SELECT * from TRAVEL.PRODUCT"
    username="travel"
    url="jdbc:derby://localhost:21527/sample"
    maxActive="4"/>
    </Context>
    <Context
    path="/FileUploadExample">
    <EJB
    home="greeting.GreeterHome"
    name="GreeterEJB"
    remote="greeting.Greeter"
    type="Session"/>
    </Context>
         <Context path="/MySqlTest" docBase="MySqlTest"
         debug="5" reloadable="true" crossContext="true">
              <Resource name="jdbc/MySql1" auth="Container" type="javax.sql.DataSource"
    maxActive="100" maxIdle="30" maxWait="10000"
    username="root" password="adminadmin" driverClassName="com.mysql.jdbc.Driver"
    url="jdbc:mysql://localhost:3306/Test?autoReconnect=true"/>
         </Context>
    </Host>
    </Engine>
    </Service>
    </Server>

    You could track JDBC calls and the SQL's executed by the driver at the database,
    Update you datasource, DBURL with some parameters/properties to generate some info for debugging like this:
    jdbc:mysql://$hostname:$port/$databasename?autoGenerateTestcaseScript=true&dumpQueriesOnException=true
    Check out your deployment containers log to find out which particular SQL statement is being executed. This could help in identifying performance issues with application. That could possibly give a clue, if something is not working in your application.
    For designtime JDBC calls made, this info is sent to IDE log.
    Reference: http://dev.mysql.com/doc/refman/5.0/en/cj-configuration-properties.html
    HTH,
    Sakthi

  • Configuring Mysql database in EJB  xml file for JBoss

    I am using Mysql as database , How to configure JBoss to use Mysql as the database when using ejb's( session beans)
    My ejb-jar.xml is as follows
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>
    <ejb-jar>
         <description>no description</description>
         <display-name>LoginJAR</display-name>
         <enterprise-beans>
         <session>
         <description>no description</description>
         <display-name>loginEJB</display-name>
         <ejb-name>loginEJB</ejb-name>
         <home>com.rfp.Session.loginHome</home>
         <remote>com.rfp.Session.loginObject</remote>
         <ejb-class>com.rfp.Session.loginEJB</ejb-class>
         <session-type>Stateless</session-type>
         <transaction-type>Container</transaction-type>
         <resource-ref>
              <res-ref-name>jdbc/rfptrack</res-ref-name>
              <res-type>javax.sql.DataSource</res-type>
              <res-auth>Container</res-auth>
              <res-sharing-scope>Shareable</res-sharing-scope>
         </resource-ref>
         </session>
         </enterprise-beans>
         <assembly-descriptor>
              <container-transaction>
                   <method>
                   <ejb-name>loginEJB</ejb-name>
                   <method-intf>Remote</method-intf>
                   <method-name>*</method-name>
              </method>
              <trans-attribute>Required</trans-attribute>
         </container-transaction>
         </assembly-descriptor>
    </ejb-jar>
    1) My doubts are
    a). there is a username and password to access the database,
    I am mentioning only the database namein the xml file like-
    jdbc/rfptrack. So where should the username and password be
    mentioned or declared.
    b). The server showed the following error when it was started.
    Caused by: java.sql.SQLException: Table 'test.jms_messages' doesn't exist
    11:40:11,687 ERROR [MainDeployer] could not create deployment: file:/C:/jboss-3.2.3/server/default/deploy/Jlogs.ear
    Incompletely deployed packages:
    [org.jboss.deployment.DeploymentInfo@6522477c { url=file:/C:/jboss-3.2.3/server/default/deploy/Jlogs.ear }
    deployer: org.jboss.deployment.EARDeployer@1e940b
    status: Deployment FAILED reason: Verification of Enterprise Beans failed, see above for error messages.
    state: FAILED
    the server is showing that table "test:" does not exist but I am using rfptrack as the database and not test. how can I configure the server for it.
    PLEASE GO THROUGH THE EJB-JAR.XML FILE AND THE SERVER ERRORS GIVEN ABOVE AND GIVE SUGGESTIONS TO RECTIFY MY ERRORS.

    Hi Svend,
    Please share the xml file.
    I am able to acheive the result by doing the above changes.
    Thanks,
    Dinesh.V
    PS:<SendDataOnNodes>False</SendDataOnNodes 
    replace with case sensitive  <SendDataOnNodes>false</SendDataOnNodes

  • Problem in configuring mysql with JBoss 4

    Hello Forum
    I m having following exceptions while invoking my session bean from servlet
    java.rmi.ServerException: RuntimeException; nested exception is: java.lang.NullPointerException I have put mysql-ds.xml file in :\jboss-4.0.3SP1\server\default\deploy directory and mysql-connector-java-3.1.10-bin.jar in :\jboss-4.0.3SP1\server\default\lib directory.
    my mysql-ds.xml code is (which I take from connector-j doc)
    <datasources>
        <local-tx-datasource>
            <!-- This connection pool will be bound into JNDI with the name
                 "java:/MySQLDB" -->
            <jndi-name>MySQLDB</jndi-name>
            <connection-url>jdbc:mysql://localhost:3306/student</connection-url>
            <driver-class>com.mysql.jdbc.Driver</driver-class>
            <user-name>root</user-name>
            <password>pakistan</password>
            <min-pool-size>5</min-pool-size>
            <max-pool-size>20</max-pool-size>
            <idle-timeout-minutes>5</idle-timeout-minutes>
            <exception-sorter-class-name>com.mysql.jdbc.integration.jboss.ExtendedMysqlExceptionSorter</exception-sorter-class-name>
            <valid-connection-checker-class-name>com.mysql.jdbc.integration.jboss.MysqlValidConnectionChecker</valid-connection-checker-class-name>
        </local-tx-datasource>
    </datasources>and my session bean code is:
    imports ....
    public class JBSessionBean implements javax.ejb.SessionBean, JBSession.JBSessionRemoteBusiness {
        private javax.ejb.SessionContext context;
        public void ejbCreate() { }
        public java.sql.ResultSet setDbConnection()
            InitialContext ctx ;
            String jndiName = "java:/MySQLDB";
            DataSource ds = null;
            Connection conn = null;
            ResultSet rs = null;                
            String query = "SELECT * FROM stdinfo";
            try
                ctx = new InitialContext();
            catch (NamingException e)
                System.out.println (e.toString());
            //Lookup the data source
            ctx = null;
            try
                ds = (DataSource) ctx.lookup(jndiName);
            catch(NamingException e)
                System.out.println (e.toString() + "Error in Creating the DataSource");
            try
                conn = ds.getConnection();
            catch(SQLException e)
                System.out.println (e.toString() + "Error in Creating Connection");
            try
                Statement stmt = conn.createStatement( );
                System.out.println("got statmnet");
                rs= stmt.executeQuery( query ) ;
                System.out.println("got rs");     
            catch(SQLException e)
                System.out.println (e.toString() + "Error in Creating statement n query");
            return rs;
    }and my servlet code is
    public class JBossWeb extends HttpServlet {
        protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            response.setContentType("text/html;charset=UTF-8");
            PrintWriter out = response.getWriter();
            ResultSet rSet = null;
            JBSessionRemote remoteRef = lookupJBSessionBean();
            try {
               rSet =  remoteRef.setDbConnection();
            } catch (RemoteException ex) {
                out.println(ex.toString());
            } catch (SQLException ex) {
                out.println(ex.toString());
            } catch (Exception ex){
                out.println(ex.toString());
            out.println("<html>");
            out.println("<head>");
            out.println("<title>Servlet JBossWeb</title>");
            out.println("</head>");
            out.println("<body>");
            out.println("<h1>Servlet JBossWeb</h1>");
            out.println(remoteRef.printTemp());
            if (rSet == null)
                out.println("Resultset null");
            out.println("</body>");
            out.println("</html>");
            out.close();
        private JBSession.JBSessionRemote lookupJBSessionBean() {
            try {
                javax.naming.Context c = new javax.naming.InitialContext();
                Object remote = c.lookup("java:comp/env/ejb/JBSessionBean");
                JBSession.JBSessionRemoteHome rv = (JBSession.JBSessionRemoteHome) javax.rmi.PortableRemoteObject.narrow(remote, JBSession.JBSessionRemoteHome.class);
                return rv.create();
            catch(javax.naming.NamingException ne) {
                java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE,"exception caught" ,ne);
                throw new RuntimeException(ne);
            catch(javax.ejb.CreateException ce) {
                java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE,"exception caught" ,ce);
                throw new RuntimeException(ce);
            catch(java.rmi.RemoteException re) {
                java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE,"exception caught" ,re);
                throw new RuntimeException(re);
    }I m using NetBeans IDE 5. Am I missing anything regarding more configuration in JBoss regarding mysql?
    I could not found why I got exception, please tell me after reviewing my code.
    hope I will got solution from u ppl
    Thanx in advance

    dear dvohra09
    it still giving me the same exception
    java.rmi.ServerException: RuntimeException; nested exception is: java.lang.NullPointerException as u suggested
    <application-policy name = "MySqlDbRealm">
    <authentication>
    <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required">
    <module-option name ="principal"></module-option>
    <module-option name ="userName">root</module-option>
    <module-option name ="password">pakistan</module-option>
    <module-option name ="managedConnectionFactoryName"> jboss.jca:service=LocalTxCM,name=MySQLDB
    </module-option>
    </login-module>
    </authentication>
    </application-policy>but still I didnt able to connect my database to JBoss
    any idea...???

  • Uisng XSQL without changing Tomcat configuration

    I would like to use XSQL servlet with a JSF application. In the installation guide, steps are given to specify the servlet responsible for *.xsql requests in the servlet container configuration files such as Tomcat's.
    But I was wondering if it is possible to specify the XSQL servlet in web.xml file for the application? Just as I do for JSF:
    <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>
    That way I would'nt have to alter the server configuration. Thanks!

    XSQL Servlet may be added to web.xml
    <servlet>
    <servlet-name>XSQLServlet</servlet-name>
    <servlet-class>oracle.xml.xsql.XSQLServlet </servlet-class>
    </servlet>
    Refer
    Can't get XSQL servlet to work on iPlanet Web Server (iws 6.0)

  • Container Managed Security on Tomcat - configuring different auth-methods

    I am trying to configure the container managed security on tomcat4. Or rather I am trying to add a further dimension to the configuration that already exists.
    At the moment the entire application uses LDAP authentication and I would like to separate an area that requires further authentication. That is to say I would like everyone using the web application to authenticate using the existing Form-Based LDAP authentication but I would like only certain users to be able to use the data upload facility (whose code is stored in it's own directory).
    This is the authentication bit of my web.xml:
      <security-constraint>
        <web-resource-collection>
          <web-resource-name>qmrae</web-resource-name>
          <url-pattern>*.do</url-pattern>
          <url-pattern>*.jsp</url-pattern>
        </web-resource-collection>
        <auth-constraint>
          <role-name>*</role-name>
        </auth-constraint>
      </security-constraint>
      <login-config>
        <auth-method>FORM</auth-method>
        <realm-name>Form-Based Authentication Area</realm-name>
        <form-login-config>
          <form-login-page>/login.jsp</form-login-page>
          <form-error-page>/loginError.jsp</form-error-page>
        </form-login-config>
      </login-config>My first hurdle is in understanding exactly how the application knows where to go for its authentication.
    I had guessed that the realm-name would map "areas" of my application to realm configuration defined in my application's context area in Tomcat's web.xml but this doesnt seem to be the case. In fact I have read conflicting explanations as to what the realm-name is for. One source has said that this is only used for BASIC authentication as a way of naming the resulting pop up window - many others say it maps the login-config to the web-resource-name. However the latter doesnt make sense because the authentication works in my application at the moment even though those values are completely different (and indeed are different in most of the examples i've read on the web). Furthermore I can find any other mention of the defined realm-name in any other file (which of course be because i'm looking in the wrong place).
    I was prepared to accept that the realm-name might not actually do anything and so I've been looking for examples of defining a different auth-method for different url-patterns but i've had no luck.
    I know a user can have one or more roles but I dont have access to the LDAP server to set these up and haven't found anything about defining different auth-methods other than one thread in this forum suggesting that is wasnt possible on AIS.
    This thread suggests that you can have more than one security-constraint but again i'm not sure about the auth methods and how you map an auth method to a security-constraint
    http://forum.java.sun.com/thread.jspa?forumID=33&threadID=320918
    To summarise my questions:
    1) What are the functions of the realm-name and web-resource-name? Are they related?
    2) Is it possible to configure different areas of an application to use different authentication methods? and if so, could you point me in the direction of relevant documentation
    3) If (2) is not possible and I have to assign a new role to the privileged LDAP users, is it enough to define a new security-constraint? Could you describe the behaviour I could expect for users that have authenticated once and try to access this super-security area, will they be shown another login form or will it just let them in because the container is already aware of their permissions.
    Many thanks for your attention,
    Rachel

    If you create your own Realm classes - look at JAAS - you can sort out your last login time, just wrap them around the DataSourceRealm.
    As far as 'remind' him is concerned - I'm guessing you mean provider a reminder for the password based on the user name. If you use form based authentication you can put what ever you like on the page.

  • Too many open connections from Tomcat to MySQL?

    <?xml version='1.0' encoding='utf-8'?>
    <Context>
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
    <Resource
    name="jdbc/RealmDB" auth="Container" type="javax.sql.DataSource"
    username="root" password="password" driverClassName="com.mysql.jdbc.Driver"
    url="jdbc:mysql://localhost:3306/monk"
    maxActive="-1" maxIdle="5" maxWait="5000"
    removeAbandoned="true" removeAbandonedTimeout="60"
    testWhileIdle="true" timeBetweenEvictionRunsMillis="180000"/>
    <Realm
    className="org.apache.catalina.realm.DataSourceRealm"
    dataSourceName="jdbc/RealmDB" localDataSource="true"
    digest="MD5"
    userTable="user" userNameCol="user_name" userCredCol="password"
    userRoleTable="tcrole" roleNameCol="role_name" />
    </Context>
    Is there a way in here to auto close inactive connections after say 10 seconds? Is that the removeAbandonedTimeout or the Eviction section? Would this be better off posted on the tomcat user listing?
    Edited by: TheWhiteKnight on Oct 29, 2009 8:00 PM

    Actually BalusC, I like this. This seems to define the entire cycle quite nicely and CLEAN. This will be very helpful when phase II rolls out. Right now I need to just patch the thing and get it running "well".
    I've also had to implement some new methods to clean up some of the junk that is left open. I have found RS's that are closed, but no corresponding connection / statement's are being closed. So when I have a return statement like:
    return ConnectionPool.getConnection().createStatement().executeQuery(sqlStatement);
    {code]
    that is called from the presentation layer, logically (to me) the only place to close the connection / statement associated with that RS is in the presentation layer.  As of right now.  This will change on phase II.  If I am wrong please correct me in this.
    Something that is happening now though since I have started explicitly closing the connections and statements.  It seems that my ConnectionPool is running out of connections. I can increase the size of the pool, but it worked just fine before with the amount of connections I have set.  When I call .close() on the connection, does that "recycle" the connection back to the pool?  I know there has to be resources bleeding someplace, however, this has only started happening (more often) since I have been closing things where I find them.
    Any ideas on this?
    Also will converting the basic generic queries to stored procedures help in the performance?  I know that I'll still have to have a connection, but if I can have less java coded sql statements and more SP's would that help in efficiency between MySQL and Tomcat?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • I can't get along with Tomcat and MySQL

    i'm using tomcat 5.5 and wan to connect to mysql database. when trying to run my webapp, the compiler said like the driver(java-connector) is not detected. what should i do now... someone tell me please. and where exactly i should copy the driver(jar file) to. thnk u in advance:D

    put it under WEB-INF\lib

  • How to implement transactions in Tomcat using MySQL

    Hi,
    I am trying to find a way to implement Transactions in Tomcat 4112 using a DBCP connection pool with MySQL (connector/j 3.0.16).
    I am developing a web app using the Struts framework and have tried using JOTM for the transaction implementation. However the JOTM PreparedStatement objects do not support the getGeneratedKeys() method (which i definitely need!!!).
    I have one database with multiple datasources, but the dataase may become much larger and require multiple instances in the future so i want a solution that will scale.
    Can i use the simple JDBC connection.commit() methods? Are these robust? Or is there a simple way to use the base JTA/JTS implementation myself??
    Or is there something like JOTM that implements the full JDBC 3.0 interfaces!!
    lots of questions - sorry...
    thanks
    will crick

    I've got the same problem here.
    I want to implement a HyperlinkListener to a JLabel. (Unlike suggested above, it is only supported by JEditorPane and not JLabel)
    The goal is, that if a user clicks on a Link in a JLabel, the standard browser opens and displays that page.
    Can somebody please help?
    My ultimate goal would be to also be able to add clickable HyperLinks in ToolTip texts, but i guess that'd be even more complicated.

  • Problem configure mysql datasource

    Hi, I am trying to use mysql datasource for my application. I had configured MYSQL_DRIVER and then
    i had configured gtasappdb datasource with
       driver-class-name = com.mysql.jdbc.Driver
       url               = jdbc:mysql://localhost:3306/appdb
       alias             = appdbdatasource
    And then i tried to deploy a EJB application which uses the above 'appdbdatasource'. When the application starts
    it says cannot find 'gtasappdb' connectionfactory.
    So can anyone tell me what should be done to use mysql for my application, please

    Hello mahesh,
    There are two ways.
    1. You should add a resource reference to the ds alias in the deployment descriptor of the application component.Once you have defined the reference,use the following snippet to access the data source
    DataSource ds = (DataSource) context.lookup("java:comp/env/<res-ref-name>").
    2. If you have not defined the reference in your application, use the JNDI reference "jdbc/alias".
    Hope this helps,
    Prasad

  • Configuring mysql with J2EE

    Hi Im a newbie in J2EE. (just started learning it 2 days back that new..;-)
    I managed to set up a simple application using the J2ee tutorial. Now i want to try out a database application. I have a mysql database installed. Can anyone guide me on how to setup mysql with j2ee server? Are there any online tutorials etc that would help me in this?
    I actually managed to create a connection pool however when i try to ping it i get an error message with says "An error has occurred. Operation 'pingConnectionPool' failed in 'resources' Config Mbean. Target exception message: Class name is wrong or classpath is not set for : org.gjt.mm.mysql.jdbc2.optional.MysqlDataSource" .
    I hav already set classpath of mysql driver. Do i need to copy the jar file to any other directory?
    Im not too sure if the way i have created connection pool is right, but i used the defaults specified so i guess that should be ok.
    Any Help would be appreciated.
    Thanks in advance.

    Hi! I�m Brazilian and I�ve been learning the English language yet, but I�ll try to describe how to configure J2EE with MySQL.
    I am using MySQL version 4.1.7 with J2EE version 1.3 on Windows XP Professional. The driver version of MySQL is 3.0.16.
    You have to configure the following two files:
    - <J2EE_HOME>\bin\setenv.bat
    - <J2EE_HOME>\config\resource.properties
    Do the following steps:
    1) Copy the JAR file of MySQL driver (mysql-connector-java-3.0.16-ga-bin.jar) to <J2EE_HOME>\lib directory.
    2) In <J2EE_HOME>\bin directory open the setenv.bat file and analize the code. It is not hard to understand the code, it is just the classpath configuration of J2EE. After understand it, add a reference of MySQL driver (mysql-connector-java-3.0.16-ga-bin.jar), that was copied to <J2EE_HOME>\lib directory.
    3) Run the <J2EE_HOME>\bin\j2eeadmin.bat to configure the resource.properties file.There are two command lines to be executed, as below:
    - j2eeadmin.bat -addJdbcDriver <CLASS NAME OF THE DRIVER>
    - j2eeadmin.bat -addJdbcDatasource <JNDI NAME> <URL>
    For example:
    - j2eeadmin.bat -addJdbcDriver "com.mysql.jdbc.Driver"
    - j2eeadmin.bat -addJdbcDatasource "jdbc/mysql/test" "jdbc:mysql://localhost/test?user=username&password=pass"
    4) After run j2eeadmin.bat, the resource.properties file will be modified. But when I did it and when I executed the verbose command to start J2EE, some error messages was exhibited. So I decided to open the resource.properties file and I noticed hat the character "\" was added erroneously in a lot of places of the code. It did not seem correct, so I decided to remove these characters replacing them. Bingo!!! After I did it, I run verbose again and no more message error ocurred. I think it is a bug of J2EE.
    Finish! I modified the datasource JNDI to access MySQL and then I run my EAR application. No problems occurred. My application is running succesfully.
    Good luck!

  • Installing anc configuring Mysql 4.0.x or 4.1.x

    Hi ive got Solaris 10 installed and configured however im having major dramas with the installation of Mysql 4.0.21 which i downloaded from sunfreeware, ive installed using pkgadd and all seems well, but when i try to start the mysql service or mysqld, i get the error :
    ERROR 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (146)
    Please any help would be much appreicated

    Hi,
    Actually MySQL comes with Solaris 10 by default and it is available under /usr/sfw and you can try like this. Otherwise it can be installed by default under /usr/local if it is installed from new download. but the steps will be the same and only install directory needs to be changed.
    And i used 'root' user instead of 'myql'. It can be started by mysql if user 'mysql' is created and given all the permissions as per installation steps given in the documentation.
    # ./mysql_install_db --user=root
    Installing all prepared tables
    050923 22:44:07 /usr/sfw/sbin/mysqld: Shutdown Complete
    To start mysqld at boot time you have to copy support-files/mysql.server
    to the right place for your system
    PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
    This is done with:
    /usr/sfw/bin/mysqladmin -u root password 'new-password'
    /usr/sfw/bin/mysqladmin -u root -h Mullapudi password 'new-password'
    See the manual for more instructions.
    NOTE: If you are upgrading from a MySQL <= 3.22.10 you should run
    the /usr/sfw/bin/mysql_fix_privilege_tables. Otherwise you will not be
    able to use the new GRANT command!
    You can start the MySQL daemon with:
    /usr/sfw/sbin/mysqld_safe &
    You can test the MySQL daemon with the tests in the 'mysql-test' directory:
    cd /usr/sfw/mysql/mysql-test; ./mysql-test-run
    Please report any problems with the /usr/sfw/bin/mysqlbug script!
    The latest information about MySQL is available on the web at
    http://www.mysql.com
    Support MySQL by buying support/licenses at https://order.mysql.com
    Hope this helps!
    ~RK

Maybe you are looking for