Connection config in context.xml

Hi,
How to specify the following in context.xml resource tag?
jdbc:mysql://localhost:3308/test?characterEncoding=UTF-8&useUnicode=true
Thank you.

From HttpSession:
          setMaxInactiveInterval(int interval)
          Specifies the time, in seconds, between client requests before the servlet
          container will invalidate this session.
          Cameron Purdy
          "Olivier Brand" <[email protected]> wrote in message
          news:[email protected]..
          > As the documentation and the Servlet specifications specify, the session
          > timeout is expressed in minutes.
          >
          > We have set the tag to 30 and it appeared that the session was being
          > flushed every 30 seconds.
          >
          > Could somebody confirm this behavior ?
          >
          > Thanks
          >
          > Olivier
          >
          >
          

Similar Messages

  • Error in connecting the database with context.xml resource

    Dear everyone,
    i am trying to connect the application with database...
    i have a table with employee id, name...
    i have given context xml and established connection..
    but i am getting error as
    * " Element type "Resource" must be followed by either attribute specifications, ">" or "/>"."
    * "The context.xml file seems to be broken. Check whether it is well-formed and valid."
    anyone please give ur suggestions....

    the error that i received now was...
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSP:
    An error occurred at line: 34 in the jsp file: /index.jsp
    Context cannot be resolved to a type
    31:        int i=0;
    32:       
    33:       
    34:        Context ctx = new InitialContext();
    35:        DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/employee");
    36:       
    37:        try
    An error occurred at line: 34 in the jsp file: /index.jsp
    InitialContext cannot be resolved to a type
    31:        int i=0;
    32:       
    33:       
    34:        Context ctx = new InitialContext();
    35:        DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/employee");
    36:       
    37:        try
    An error occurred at line: 35 in the jsp file: /index.jsp
    DataSource cannot be resolved to a type
    32:       
    33:       
    34:        Context ctx = new InitialContext();
    35:        DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/employee");
    36:       
    37:        try
    38:         {
    An error occurred at line: 35 in the jsp file: /index.jsp
    DataSource cannot be resolved to a type
    32:       
    33:       
    34:        Context ctx = new InitialContext();
    35:        DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/employee");
    36:       
    37:        try
    38:         {
    Stacktrace:
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
         org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:299)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.23 logs.

  • Auto Config Tomcat 5.5 Context.xml

    I am trying to set up my app so no Data Source configuration is necessary in Tomcat 5.5 here is my context.xml anybody have any ideas why this isn't working?
    <?xml version='1.0' encoding='utf-8'?>
    <Context displayName="ElegantMailingTest" docBase="/opt/tomcat5/webapps/ElegantMailingTest.war" path="/ElegantMailingTest" workDir="work/Catalina/localhost/ElegantMailingTest">>
    <Resource auth="Container" description="Rave Generated Data Source" name="jdbc/ElegantMailing" type="javax.sql.DataSource"/>
    <ResourceParams name="jdbc/ElegantMailing">
    <parameter>
    <name>factory</name>
    <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    </parameter>
    <parameter>
    <name>driverClassName</name>
    <value>org.gjt.mm.mysql.Driver</value>
    </parameter>
    <parameter>
    <name>username</name>
    <value>jasonwpalmer</value>
    </parameter>
    <parameter>
    <name>password</name>
    <value>******</value> (I Obviously Removed)
    </parameter>
    <parameter>
    <name>url</name>
    <value>jdbc:mysql://localhost:3306/ElegantMailing?autoReconnect=true</value>
    </parameter>
    <parameter>
    <name>maxActive</name>
    <value>30</value>
    </parameter>
    <parameter>
    <name>maxIdle</name>
    <value>10</value>
    </parameter>
    <parameter>
    <name>maxWait</name>
    <value>10000</value>
    </parameter>
    </ResourceParams>
    </Context>

    Thank you Roman,
    I'm sure I have already read those posts before I posted, but somehow when I followed your links back there again, I got it right.
    Here is my context.xml that was successful with auto-config
    <?xml version="1.0" encoding="UTF-8"?>
    <Context path="/ElegantMailingTest">
    <Resource driverClassName="org.gjt.mm.mysql.Driver" maxActive="30" maxIdle="10" maxWait="10000" name="jdbc/ElegantMailing" password="788721" type="javax.sql.DataSource" url="jdbc:mysql://localhost:3306/ElegantMailing?autoReconnect=true" username="jasonwpalmer" validationQuery="select * from validation"/>
    </Context>
    Roman I have seen your replies all over the threads and I appreciate the time you spend helping us newbies out...really thanx!
    Jason

  • Problem in loading Context.xml file

    Hi,
    I just tried to create datasource from context.xml. i did the following steps
    1. i added context.xml file in webapps/META-INF/
    2. I added the below values to that xml file.
    <?xml version="1.0" encoding="UTF-8"?>
    <Context antiJARLocking="true" path="/myApp" >
        <Resource name="jdbc/dbtest" type="javax.sql.DataSource" driverClassName="oracle.jdbc.driver.OracleDriver" password="test_dev" minIdle="1" maxIdle="1" maxActive="10" maxWait="5000" username="test_dev" url="jdbc:oracle:thin:@22.4.55.6:1521:TEST"/>
    </Context>3.
    public class TestDB {
         private static Logger log = Logger.getLogger(TestDB.class.getName());
         private final static String JNDI_PATH_DB            = "java:comp/env/jdbc/dbtest";
         public javax.sql.DataSource getCatalogDS() throws NamingException
              try
                   InitialContext initCtx = new InitialContext();
                   return (DataSource)initCtx.lookup(JNDI_PATH_DB);
              catch (NamingException ex)
                   log.info("NamingException: " + ex.getMessage());
                   throw ex;
         public Connection getConnection() throws Exception
              try
                  DataSource catalogDS = getCatalogDS();
                   return catalogDS.getConnection();
              catch(Exception ex)
                   log.info(ex.getMessage());
                   throw ex;
         public static void main (String args[]){
                   try {
                        TestDB obj = new TestDB();
                        System.out.println("before lookup");
                        System.out.println("Datasource is "+obj.getConnection());
                   } catch( NamingException ne ) {
                        throw new RuntimeException( "Unable to aquire data source", ne );
         catch (Exception e)
              String st = StringUtils.StackTraceToString( e );
    }4. i run this class to get connection.
    i am getting an error
    Exception in thread "main" java.lang.RuntimeException: Unable to aquire data source
         at it.sscenter.escape.admintools.TestDB.main(TestDB.java:51)
    Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
         at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
         at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
         at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
         at javax.naming.InitialContext.lookup(InitialContext.java:392)
         at it.sscenter.escape.admintools.TestDB.getCatalogDS(TestDB.java:22)
         at it.sscenter.escape.admintools.TestDB.getConnection(TestDB.java:35)
         at it.sscenter.escape.admintools.TestDB.main(TestDB.java:49)Is that right way or do i need to configure the context file in somewhere OR do i need to create an properties file?
    Kindly help to resolve this issue.
    Thanks
    Jasmin

    EJP wrote:
    You need to give the InitialContext some properties, there's no magical way it'll configure itself (outside of a Java EE container).If you lookup a URL with a known protocol, e.g. ldap: or in this case java:, it will configure itself in any environment that has a factory for the protocol.Is this a recent change? Last time I was accessing Ldap, it did require me to specify the com.sun.jndi.ldap.LdapCtxFactory separately.

  • How to config the web.xml file, when I use Richfaces + RI 1.2?

    Hi there:
    I want to use Richfaces + RI 1.2 to build a project. I don`t know how to config the web.xml file.
    By the way, my web server is Tomcat 6.0, my JDK's version is 6u6. I don`t want to use the facelets.
    thanks.
    lxm

    just add this before *</web-app>*
    <context-param>
           <param-name>org.richfaces.SKIN</param-name>
           <param-value>blueSky</param-value>
      </context-param>
      <filter>
           <display-name>RichFaces Filter</display-name>
           <filter-name>richfaces</filter-name>
           <filter-class>org.ajax4jsf.Filter</filter-class>
      </filter>
      <filter-mapping>
           <filter-name>richfaces</filter-name>
           <servlet-name>Faces Servlet</servlet-name>
           <dispatcher>REQUEST</dispatcher>
           <dispatcher>FORWARD</dispatcher>
           <dispatcher>INCLUDE</dispatcher>
      </filter-mapping>

  • Context.xml configuration for database connetion in struts

    here is the content of context.xml
    <Context antiJARLocking="true" path="/WebApplication5">
        <!-- Specify a JDBC datasource -->
        <Resource name="jdbc/aaa"
                  auth="Container"
                  type="javax.sql.DataSource"
                  username="campus"
                  password="camp123"
                  driverClassName="com.mysql.jdbc.Driver"
                  url="jdbc:mysql://192.168.0.226:3306/training"/>
    </Context>here is the usage
    public boolean query(empform f)throws NamingException,SQLException {
            //Connection conn=null;
    //        String url = "jdbc:mysql://192.168.0.226:3306/";
    //        String dbname = "training";
    //Connection c=null;
            ResultSet rs = null;
            System.out.println("resultset out of try");
            try {
                // Get DataSource
                System.out.println("resultset 1");
                Context ctx = new InitialContext();
                System.out.println("resultset2 ");
                DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/aaa");
    // Get Connection and Statement
                System.out.println(ds);
                Connection c = ds.getConnection();
                System.out.println("resultset4");
    //                 Class.forName("com.mysql.jdbc.Driver");
    //                 conn = DriverManager.getConnection(url+dbname,"campus","camp123");
                PreparedStatement ps;
                String query = "select * from loginemp where username=? and password=?";
                ps = c.prepareStatement(query);
                ps.setString(1, f.getUsername());
                ps.setString(2, f.getPassword());
                rs = ps.executeQuery();
                System.out.println("resultset" + rs);
               if(rs.next()) {
                   System.out.println(rs.getString("username"));
                   return true;
               else
                   return false;
            } catch (Exception e) {
                // conn.close();
                System.out.println("in catch of login dao" + e);
            return false;
        }Im getting error
    resultset out of try
    resultset 1
    resultset2
    org.apache.tomcat.dbcp.dbcp.BasicDataSource@a5c9f1
    in catch of login dao
    org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1136)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
    at com.myapp.struts.LoginDao.query(LoginDao.java:40)
    at com.myapp.struts.Business.login(Business.java:20)
    at com.myapp.struts.empAction.execute(empAction.java:25)
    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:595)
    Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:164)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1130)
    ... 25 more
    can anyone help...

    Bhararrajverma wrote:
    org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'Looks like it can't find the JDBC driver. The MySQL JDBC driver jar must be available either in your web app or in the shared tomcat library directory. Is it there?

  • Tomcat application context.xml

    This is my problem:
    I've been programming my own implementation of a Realm.
    within I want to access a <Environment>-Entry situated in
    a customized Context.xml :
    <Context docBase="${catalina.home}/webapps/slide"
    privileged="true" antiResourceLocking="false"
    antiJARLocking="false" useNaming="true">
    <Environment name="test" type="java.lang.String"
    value="C:/user.xml"/>
              <Realm className="MyRealm"/>
    </Context>
    What do I need to do to gain access.
    When I declare the variable in <GlobalNamingResources> there is no problem accessing it.

    To clarify I add portions of my configuration files:
    <b>hibernate.cfg.xml</b> fragment:
    <property name="connection.datasource">
      java:comp/env/jdbc/cname
    </property>
    <property name="dialect">
      net.sf.hibernate.dialect.OracleDialect
    </property>
    <property name="connection.driver_class">
      oracle.jdbc.driver.OracleDriver
    </property>
    <property name="transaction.factory_class">
      net.sf.hibernate.transaction.JDBCTransactionFactory
    </property> <b>web.xml</b> fragment:
    <resource-ref>
      <description>DataSource</description>
      <res-ref-name>jdbc/cname</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
    </resource-ref>What I want to put inside <b>tomcat context application definition</b>:
    <Resource name="jdbc/cname" scope="Shareable" type="javax.sql.DataSource"/>
    <ResourceParams name="jdbc/cname">
      <parameter>
        <name>factory</name>
        <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
      </parameter>
      <parameter>
        <name>url</name>
        <value>jdbc:oracle:thin:@server:1521:SID</value>
      </parameter>
      <parameter>
        <name>driverClassName</name>
        <value>oracle.jdbc.driver.OracleDriver</value>
      </parameter>
      <parameter>
        <name>username</name>
        <value>name</value>
      </parameter>
      <parameter>
        <name>password</name>
        <value>pass</value>
      </parameter>
      <parameter>
        <name>maxWait</name>
        <value>3000</value>
      </parameter>
      <parameter>
        <name>maxIdle</name>
        <value>100</value>
      </parameter>
      <parameter>
        <name>maxActive</name>
        <value>10</value>
      </parameter>
    </ResourceParams>
    <Realm className="org.apache.catalina.realm.DataSourceRealm"
       dataSourceName="jdbc/cname"
       localDataSource="true"
       digest="MD5"
       userTable="usr" userNameCol="user" userCredCol="passwd"
       userRoleTable="usrrol" roleNameCol="rol" />

  • Referencing Database from Context.xml

    In the Context.xml file, I have reference to the database I am using for the application. Here is the Context.xml code.
    <?xml version="1.0" encoding="UTF-8"?>
    <Context path="ABATE" reloadable="true" docBase="C:\Documents and Settings\koconnor\EclipseWorkspace\ABATE" workDir="C:\Documents and Settings\koconnor\EclipseWorkspace\ABATE\work" >
         <Resource name="jdbc/ABATE" auth="Container" scope="Shareable" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000"
            username="ccn" password="ccn" driverClassName="com.mysql.jdbc.Driver"
            url="jdbc:mysql://localhost:3306/abate?autoReconnect=true"/>     
    </Context>Basically; what I need to know is how I can reference the value stored in "url" within a java class.

    The point is that you DON'T access the URL directly. You just look up the datasource by name: jdbc/ABATE, and ask it for a connection. It will use the url to give you a database connection.
    It abstracts the connection details from your code.

  • Cleanup of Context xml file in EBS Database

    Hello Team:
    I recently upgraded my database to 11g and ran autoconfig to reflect the new environment settings. For some reasons when I look at the env set. I am seeing the 9.2.0 instances also listed in it.
    [oradev@brazeau appsutil]$ env | grep 9.2.0
    PERL5LIB=/u02/dev/oradev/devdb/9.2.0/Apache/perl/lib/5.00503:/u02/dev/oradev/devdb/9.2.0/Apache/perl/lib/site_perl/5.005:/u02/dev/oradev/devdb/9.2.0/appsutil/perl:/u02/dev/oradev/devdb/10.2.0/appsutil/perl:/u02/dev/oradev/devdb/11.1.0/appsutil/perl
    TNS_ADMIN=/u02/dev/oradev/devdb/9.2.0/network/admin/SID_host
    PATH=/u02/dev/oradev/devdb/9.2.0/Apache/perl/bin:/u02/dev/oradev/devdb/9.2.0/Apache/perl/bin:/u02/dev/oradev/devdb/9.2.0/Apache/perl/bin:/u02/dev/oradev/devdb/9.2.0/Apache/perl/bin:/u02/dev/oradev/devdb/11.1.0/bin:/usr/bin:/usr/sbin:/u02/dev/oradev/devdb/9.2.0/jre/1.4.2/bin:/usr/ccs/bin:/bin:/usr/bin/X11:/usr/local/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/u02/dev/oradev/bin:.:.:.:.
    ADPERLPRG=/u02/dev/oradev/devdb/9.2.0/Apache/perl/bin/perl
    I need to clean this up. The next thing that I am seeing is this . The Database listener file.It is still using the 9.2.0 listener file instead of the 11g one.
    Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
    STATUS of the LISTENER
    Alias DEV
    Version TNSLSNR for Linux: Version 11.1.0.6.0 - Production
    Start Date 02-JUL-2008 12:43:41
    Uptime 6 days 3 hr. 40 min. 47 sec
    Trace Level off
    Security ON: Local OS Authentication
    SNMP OFF
    Listener Parameter File /u02/dev/oradev/devdb/9.2.0/network/admin/DEV_host/listener.ora
    Listener Log File /u02/dev/oradev/devdb/11.1.0/log/diag/tnslsnr/host/dev/alert/log.xml
    Listening Endpoints Summary...
    (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROCDEV)))
    (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=host.thebrick.com)(PORT=1521)))
    I think i need to change the TNS_ADMIN value so the database will start using the 11g listener right.
    Can I manually update the context.xml to correct values ? How should I proceed in this situation?
    Regards,
    BMP

    I think i need to change the TNS_ADMIN value so the database will start using the 11g listener right.
    Can I manually update the context.xml to correct values ? How should I proceed in this situation?- Make sure the database is up
    - Update the 11g listener.ora file manually and start the listener (using lsnrctl)
    - Edit the Context File and make the necessary changes
    - Run AutoConfig
    - As oracle user, open a new session and source the database env file again
    - Issue the command “env | grep 9.2.0” again to verify that all references to 9.2.0 ORACLE_HOME are no longer exist
    - Shutdown/Startup the listener/database

  • Context.xml question , Thanks

    Hi, developers:
    I would like to connect to another server using context.xml. I did like the following link: < a href="http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html"> link to instruction</a>
    In the "JDBC Data Source" :4 Configure Tomcat's Resource Factory part said a Context.xml tshould be stored in the META-INF directory .
    My problem is:
    1) where is /META-INF so I can find the contect.xml. I using tomcat5.5 and find only at Tomcat5.5\conf\context.xml?
    2) When I restart with my context.xml below, the tomcat can start but application can NOT.
    Error msd: Http status 404 : The requested resource (/account App) is not available.
    code of context.xml is:
    <?xml version='1.0' encoding='utf-8'?>
    <Context displayName="account" path="/accountApp" debug="0" reloadable="true" docBase="serverdb">
    <Resource name="jdbc/dbinstance" auth="Container" type="javax.sql.DataSource"
    factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
    driverClassName="oracle.jdbc.OracleDriver"
    url="jdbc:oracle:thin:@//dburl:1522/"
    username="accuser"
    password="accpw"
    maxActive="20"
    maxIdle="10"
    maxWait="120000"
    removeAbandoned="true"
    logAbandoned="true"
    removeAbandonedTimeout="300"
    testOnBorrow="true"
    testOnReturn="true"
    validationQuery="select 1 from dual" />
    </Context>
    is some one can give me a help to solve it. Thanks in advance

    The "context" here is an artifact of the way that Tomcat works. It contains deployment information - the path to the application files, the JNDI mappings and various other bits and pieces.
    The "context" of a web application is the path to which it is deployed within the application server. An application deployed to a context called "foo" would probably be accessed by the following URL:
    http://localhost:8080/foo/And the application files would probably be stored somewhere like this:
    C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\fooTomcat keeps its context information EITHER in a file called server.xml or in a seperate file named after the application's context. So typically it will be in one of these files (for our "foo" application):
    C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\server.xml
    C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\Catalina\localhost\foo.xmlYou can create the entry in one of several ways:
    1. Edit server.xml manually
    2. Edit foo.xml manually
    3. Use an application such as the admin webapp to deploy your application
    4. Include a Context.xml file in the META-INF directory of the application
    The last option allows you to specify the default values that you want the application to take up when you deploy it to Tomcat. This saves time during development, but may cause problems for your clients when they come to deploy the application themselves.
    It is this last file that you seem to be talking about. You would normally create it as a directory and file within the source directory for your application, from which you build and deploy a WAR file. For example, you might build the following files and directories into foo.war:
    C:\dev\foo\index.jsp
    C:\dev\foo\WEB-INF\web.xml
    C:\dev\foo\META-INF\MANIFEST.MF
    C:\dev\foo\META-INF\Context.xml
    This would be built to a WAR file called foo.war that represents a Zip of the contents of the C:\dev\foo directory. Deploying this will cause Tomcat to notice Context.xml and extract its contents into the conf/Catalina/localhost directory as foo.xml

  • Context.xml seems to be not read

    Hello guys,
    I've a strange issue. My application use a connection pool through JNDI.
    Issue is that on production server (linux debian) my application can't connect to db!
    In catalina log I see
    org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: YES))the issue is that in context.xml of my application (I use local context) user and password are different (i don't pass root user, but a specific user for db!).
    Is it possible tomcat is not able to read context.xml and so try to go with root user?Please help me, my application doesn't see db..
    this is my web.xml
    <resource-ref>
          <description>DB Connection</description>
          <res-ref-name>jdbc/MysqlJNDI</res-ref-name>
          <res-type>javax.sql.DataSource</res-type>
          <res-auth>Container</res-auth>
      </resource-ref>and this is my context.xml
    <Context antiJARLocking="true" path="/xxx">
        <Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" maxActive="-1"
          maxIdle="300" maxWait="1000000" name="jdbc/MysqlJNDI" password="yyy" removeAbandoned="true" removeAbandonedTimeout="30" type="javax.sql.DataSource"
          url="jdbc:mysql://ip/geco" username="zzz"/>
    </Context>Is there something I can do? Mysql is listening to this address, I can't access with my user through console...it's my jsf application that can't access and in the log appears root user...
    Please help me

    Hello guys,
    I've a strange issue. My application use a connection pool through JNDI.
    Issue is that on production server (linux debian) my application can't connect to db!
    In catalina log I see
    org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: YES))the issue is that in context.xml of my application (I use local context) user and password are different (i don't pass root user, but a specific user for db!).
    Is it possible tomcat is not able to read context.xml and so try to go with root user?Please help me, my application doesn't see db..
    this is my web.xml
    <resource-ref>
          <description>DB Connection</description>
          <res-ref-name>jdbc/MysqlJNDI</res-ref-name>
          <res-type>javax.sql.DataSource</res-type>
          <res-auth>Container</res-auth>
      </resource-ref>and this is my context.xml
    <Context antiJARLocking="true" path="/xxx">
        <Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" maxActive="-1"
          maxIdle="300" maxWait="1000000" name="jdbc/MysqlJNDI" password="yyy" removeAbandoned="true" removeAbandonedTimeout="30" type="javax.sql.DataSource"
          url="jdbc:mysql://ip/geco" username="zzz"/>
    </Context>Is there something I can do? Mysql is listening to this address, I can't access with my user through console...it's my jsf application that can't access and in the log appears root user...
    Please help me

  • Beginner Q: Which context.xml to place the DataSource setup?

    I am following this tutorial to use DataSource to access the database. http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html
    I originally place the Resource specificaiton in TOMCAT_HOME/conf/context.xml. My demo app works fine. I then experiment to move that section to My_App/Meta-inf/context.xml. Later, I need to uninstall and re-install Java and Tomcat. Then I run into to the problem in my demo http://forum.java.sun.com/thread.jspa?threadID=5299262
    I finally restore the resource section in TOMCAT_HOME/conf/context.xml to make my demo working again. From this explaination of Context (http://tomcat.apache.org/tomcat-6.0-doc/config/context.html), my understanding is that placing the resource in My_App/Meta-inf/context.xml should be better for deployment purpose. I am not understanding the need to placing resource in conf/context.xml.
    Is there any tutorial that will explain this context concept? I would like to see different setup in the path and docbase.

    eventhough it's working fine. I may have deployment problem. Anyway thanks for the reply.
    Regards,
    Ram

  • Apache server - tomcat - jk, virtual hosts, database/context.xml question?

    Hello,
    I have an web application that runs perfectly in Tomcat 5.5 when running tomcat stand-alone.
    I also have Apache HTTP server integrated with Tomcat using the jk connector and running virtual hosts in a mod_jk.conf file, which is working for html files. When I run apache and tomcat at the same time, the jsp opens but the servlet cannot get a database connection.
    To run virtual hosts and apache and tomcat, I added this host container to server.xml:
    <Host name="www.mydomain.com" debug="0" appBase="d:/WebApps/mydomain"
    unpackWARs="true" autoDeploy="true">
    <Context path="" docBase="" debug="0"/>
    </Host>
    Does anybody see anything wrong with this? Is there some reason why the context.xml (which contains the database info) is not being read?
    Any suggestions are greatly appreciated.
    Thank you,
    Logan

    Hi,
    In the docmentation of Tomcat 5.x is written that is not recommended to put <context> element in the server.xml file. Create a file in CATALINA_HOME/conf/Catalina/www.mydomain.com/ with an XML extension. For example context.xml. In files like this you should write all of your <context> elements.

  • Override defaultSearchKey in assembler-context.xml

    Hi,
    We have a query N=2&Nrs=collection()/record[P_RecordType = "store"], we do not want to search against interface "All" we configed in navigationStateBuilder, but all the records . How should we handle it? can we override defaultSearchKey in assembler-context.xml?
    <bean id="navigationStateBuilder" scope="request"
    class="com.endeca.infront.navigation.url.UrlNavigationStateBuilder">
    <property name="urlFormatter" ref="seoUrlFormatter" />
    <property name="mdexRequestBroker" ref="mdexRequestBroker"/>
    <property name="defaultSearchKey" value="All" />
    <property name="defaultMatchMode" value="ALLPARTIAL" />
    <property name="defaultFilterState">
    <bean scope="singleton" class="com.endeca.infront.navigation.model.FilterState">
    <property name="rollupKey" value="product.code" />
    <property name="autoPhraseEnabled" value="true" />
    <!-- <property name="securityFilter" value="" /> -->
    <!-- <property name="languageId" value="en" /> -->
    </bean>
    </property>

    See if the Ntk and Ntt query options are of any use for you requirement. You could create a new interface 'XYZ' with all the properties/dimensions you want searched, add relevance ranking and matching properties to it and then specify it in the query as Ntk=XYZ&Ntt=serachTerm.
    HTH,
    Pankaj.

  • In ColdFusion 10 Java integration, app-context.xml cannot be found in the classpath

    I have jars and dependencies from a vendor Java library that I wanted to use in my new CF10 environment, however the Hibernate/Spring dependencies of the library conflict with those within CF10 itself.  To work around that, I had hoped to use javasettings in an Application.cfc to prioritize the library with the classloader, but the Spring classpath resolver seems to be unable to find a META-INF/spring/app-context.xml in the classpath even though it is within the jar.
    Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [META-INF/spring/app-context.xml]; nested exception is java.io.FileNotFoundException: class path resource [META-INF/spring/app-context.xml] cannot be opened because it does not exist
            at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBean DefinitionReader.java:341)
            at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBean DefinitionReader.java:302)
            at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinition s(AbstractBeanDefinitionReader.java:143)
            at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinition s(AbstractBeanDefinitionReader.java:178)
            at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinition s(AbstractBeanDefinitionReader.java:149)
            at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinition s(AbstractBeanDefinitionReader.java:212)
            at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(Abs tractXmlApplicationContext.java:126)
            at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(Abs tractXmlApplicationContext.java:92)
            at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFact ory(AbstractRefreshableApplicationContext.java:130)
            at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(Abs tractApplicationContext.java:467)
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicatio nContext.java:397)
            at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApp licationContext.java:139)
            at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApp licationContext.java:83)
    Can anyone shed some light on why CF can't find this resource?
    Thanks,
    Dave

    ReadPDF rPDF = new ReadPDF();
    Class myClass = rPDF.getClass();
    ClassLoader loader = myClass.getClassLoader();
    URL myURL = loader.getResource("PreviewForm1210.pdf");
    String path = myURL.getPath();
    path = path.replaceAll("%20", " ");
    // Create a PdfReader instance
    PdfReader r = PdfReader.fileReader(path);
    // Create a PdfDocument instance with the reader
    PdfDocument d = new PdfDocument(r);
    // Get page count and display on console
    System.out.println("Number of pages in PreviewForm1210.pdf is " + d.getPageCount());

Maybe you are looking for

  • Why are there recovered files in the trash

    Since upgrading to Leopard I have found that there is very often recovered files in the Trash. Nothing has crashed, but I find a folder called 'Recovered Files' which contains Quark Xpress file, or other items. Just today, I found the PDF log (create

  • Spacing between lines - I'm an idiot

    Hello, I am used to Appleworks, and Pages is proving tricky for me. This is probably an idiotic question, but HOW do you set it to change from single to double or triple spacing between lines? This is my first posting, and I would be so grateful for

  • Invoice Data

    Hi All, I have to extract data of the "Invoice Amount" for each vendor from Purchasing. The Invoice Amount should come from Invoice data and not from PO Data. Can someone help me with this. What does the "Invoice Data and not PO Data" means? Many tha

  • Mountain Lion and Java 7

    I have run the java update 7u10 and it told me I have installed it fine.  Previously I was running version 6, but for minecraft tekkit I apparently need version 7. However when I choose java preferences i get to choose from version 6, 32 or 64 bit ve

  • DHCP in 6509E in VSS mode

    Hi, I am in the process of installing two 6509Es in VSS mode. Our enviroment uses the core switches as the DHCP server for the IP Phones; however, I was wondering how this would work in case they go on standalone mode. Which one would be the dhcp ser