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" />

Similar Messages

  • Tomcat 5.5 context.xml, how to configure the Host element

    [Probably this question should be asked elsewhere, if so please advise]
    Dear all,
    I understand that Tomcat 5.5 prefers that your web application comes with a context.xml file under the META-INF folder.
    So I added a context.xml file under the META-INF folder of my web application,
    please have a look below.
    context.xml
    <Context path="" docBase="C://Program Files//Apache Software Foundation//Tomcat 5.5//webapps//test">
         <Resource
              name="jdbc/testDB"
              factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
              auth="Container"
              type="javax.sql.DataSource"
              maxActive="10"
              maxIdle="5"
              maxWait="10000"
              removeAbandoned="true"
              removeAbandonedTimeout="60"
              logAbandoned="true"
              username="username"
              password="password"
              driverClassName="com.mysql.jdbc.Driver"
              url="jdbc:mysql://localhost:3306/test" />
    </Context> Ok, that is good so far, but how do I configure the Host element.
    I mean how do you link a specific Host to a specific Context?
    Before, the Context element was a sub element of the Host element,
    now it is completely separated.
    Host in server.xml
    <Host name="www.test.com" deployOnStartup="true" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
         <Valve
              className="org.apache.catalina.valves.FastCommonAccessLogValve"
              prefix="test_access_log."
              suffix=".txt"
              pattern="common"
              directory="C://Program Files//Apache Software Foundation//Tomcat 5.5//webapps//test//logs"/>
    </Host> I assume that if I modify the appBase of the Host element from webapps to webapps/test then it would work, but if I have several
    Contexts for the specific Host, how should I configure it then?
    Please help by giving examples!

    OK, I have changed the Host's appbase to webapps/mytestapplication.
    I want to deploy a test.war under the appbase:
    webapps/mytestapplication/test.war
    The name of the host is www.test.com
    Because the war file is not named ROOT.war (instead it is named test.war),
    the URL to the test application would be www.test.com/test.
    Now I have several relative anchor links in the test application
    Say for example the test application is deployed and accessed through www.test.com/test.
    Clicking on the aboutus link would change to URL to www.test.com/aboutus.html.
    Instead, for this to work, the URL must be www.test.com/test/aboutus.html.
    Obviously, the easiest solution is to add /test before each anchor link:
    But the there must a different solution.
    Adding a path to Context element did not work:
    <Context path="/test" ...>
    </Context>
    Question:
    1. what is the solution for the anchor scenario above, should I add /test before each link?
    2. Is my configuration (can be seen at the bottom) correct?
    Basically, I have removed the path and docBase attributes from the Context element.
    I have also set autoDeploy to false in the Host element.
    Here are a few paragraphs from the docs:
    autoDeploy attribute of Host element:
    "Finally, note that if you are defining contexts explicitly,
    you should probably turn off automatic application deployment.
    Otherwise, your context will be deployed twice each, and that may cause problems for your app."
    OK, so I set autoDeploy to false since I am defining contexts explicitly, (META-INF/context.xml)
    docBase attribute of Context element:
    The value of this field must not be set when the Context
    is configured using a META-INF/context.xml file as it will be inferred by the automatic deployment process.
    So, I remove the docBase attribute eventhough I am confused a bit.
    This is the part that confuses me:
    If autoDeploy is set to false since I am defining contexts explicitly,
    how can then anything be inferred by the automatic
    deployment process? (please answer!)
    There should not be any automatic deployment process when autoDeploy is set to false.
    path attribute of Context element:
    The value of this field must not be set except when statically defining a Context in server.xml,
    as it will be inferred from the filenames used for either the .xml context file or the docBase.
    Same as the Context element.
    Thanks!
    <Context>
         <Resource
              name="jdbc/testDB"
              factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
              auth="Container"
              type="javax.sql.DataSource"
              maxActive="10"
              maxIdle="5"
              maxWait="10000"
              removeAbandoned="true"
              removeAbandonedTimeout="60"
              logAbandoned="true"
              username="username"
              password="password"
              driverClassName="com.mysql.jdbc.Driver"
              url="jdbc:mysql://localhost:3306/test" />
    </Context>
    <Host name="www.test.com" deployOnStartup="true" debug="0" appBase="webapps/mytestapplication" unpackWARs="true" autoDeploy="false" xmlValidation="false" xmlNamespaceAware="false">
         <Valve
              className="org.apache.catalina.valves.FastCommonAccessLogValve"
              prefix="test_access_log."
              suffix=".txt"
              pattern="common"
              directory="C:/Program Files/Apache Software Foundation/Tomcat 5.5/webapps/mytestapplication/test/logs"/>
    </Host>

  • 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.

  • Tomcat 5.x, context.xml and the caseSensitive attribute.

    Hi,
    I have already configured a context.xml file in the CATALINA_HOME/conf/Catalina/localhost with the following content:
    <Context path="/mysite" docBase="${catalina.home}/webapps/mysite" reloadable="true"/>
    It is working, because the servlets can be reloaded after a modification. My goal is to make the URL recognition of the server for may web application case-insensitive. There is an attribute caseSensitive in the <Context> element? Is that right? And this can turn off case-sensitivity of this web application. This means it should also affect the URL recognition. But wen I change the line in the context.xml to
    <Context path="/mysite" docBase="${catalina.home}/webapps/mysite" reloadable="true" caseSensitive="false"/>
    and try to access the URL with different case then the original it does not find the page. Is this the right place to put the caseSensitive attribute?

    i am posting the Car.xml which i created in
    /conf/catalina/localhost directory in Tomcat 5.5.7
    ?xml version='1.0' encoding='utf-8'?>
    <Context path ="/Car" docBase="C:\Program
    Files\Apache Software Foundation\Tomcat
    5.5\webapps\Car" debug="0" />Rather than have you working directory under webapps, you can have it elsewhere in your system and refer to it using the docBase attribute. For example, say you have your work directory in d:\work\car,
    then
    <?xml version='1.0' encoding='utf-8'?>
    <Context  path ="/Car" docBase="d:/work/car"  />would suffice.
    cheers,
    ram.

  • META-INF/context.xml, Tomcat, META-INF/services

    I presently have a Netbeans project laid out like this:
    src
    src\java
    web
    web\META-INF
    web\META-INF\context.xml
    etc. Tomcat finds that META-INF/context.xml OK and does what I expect with it.
    I have recently added something that is loaded by java.util.ServiceLoader, which requires a META-INF/services/x.y.z file containing the name(s) of the classes that implement x.y.z. After deployment, my webapp's ServiceLoader doesn't find it, because in the target it isn't in WEB-INF/classes/META-INF/services/x.y.z. If I put it into src/java/META-INF/services/x.y.z it works correctly, as it then ends up in the right place. However I'm now concerned that either Tomcat won't find the context.xml if I put it in the same place under src, because it would then not be in /META-INF/context.xml but rather /WEB-INF/classes/META-INF/context.xml, which in turn would mean that I would then need two META-INF directories. I'm about to test that conjecture about Tomcat finding it under WEB-INF/classes/META-INF, but I'm wondering whether I'm doing something basically wrong in the first place here.

    You seem to think that you can have only one META-INF directory; this is simply not true. Keep both your META-INF directories and put the files where they are expected. Yay for using overlapping names :/

  • Context.xml for Tomcat using Weblogic JMS

    Hello,
              has anyone succeeded in getting Tomcat to use a queue hosted by Weblogic? If so, could you please post a snippet of your context.xml with the <Resource>... sections appropriate? My last attempt drowned in a sea of bizarre security exceptions and hasn't been seen since.
              Thanks,
              Richard

    Tom,
              I'll see what happens when I move things about, but really, there's a difference here. One of the issues here is that Tomcat needs a class that implements the ReferenceFactory interface for its configuration. I can't find such a class in the Weblogic docs, but I might have it all wrong or be looking in the wrong place. Hence, my question.
              The weblogic jar is not in the Tomcat classpath, it's in the WEB-INF/lib directory of the war file I'm working with.

  • Are there application context variables on WebAS  like in tomcat?

    Hello @ all,
    can anyone tell me if there is a possibility to store variables in an application context on WebAS like in tomcat.
    I need this possibility to implement a connection pooling on a server wide basis. Where i thought of implementing a singleton to do the connection pooling and i wanted to store this in the application context of WebAS if there is one.
    Any hint or link to documentation would be very welcome.
    Thanks
    Tobi

    Hi,
    Since you are in the portal forum, I assume you have a portal installed.
    You can then create a portal service, which will function as a singleton for the application server. Note however that if you run a cluster of many application servers, each of them will have an instance of it.
    Dagfinn

  • 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

  • Tomcat 5.5.7 and context.xml

    I am having difficulty corrcetly setting up the context.xml file. Perhaps someone can shed some insight as to how to do this...
    I have a .war file called myWar.war I place this in the webapps directory
    I want to use a path of a/b to access it.
    so, if my browser url is
    http://localhost:8080/a/b/html/index.html it will actually access webapp/myWar/html/index.html
    I keep reading things that confuse me as to how to do this. Do I need something called context.xml, ROOT.xml, or myWar.xml. Also do I place it in the conf/Catalina/localhost directory r in the myWar/Meta-Inf directory
    thank you

    I remember reading something about the path value not being recognized for 5.5.x . It seems to validate it in the documentation below. I don't know how to 'fix' it though...
    "The context path of this web application, which is matched against the beginning of each request URI to select the appropriate web application for processing. All of the context paths within a particular Host must be unique. If you specify a context path of an empty string (""), you are defining the default web application for this Host, which will process all requests not assigned to other Contexts. The value of this field must not be set except when statically defining a Context in server.xml, as it will be infered from the filenames used for either the .xml context file or the docBase."

  • Data source needs to be specified in context.xml instead of web.xml - why?

    Hi,
    I'm using a Spring JndiObjectFactoryBean to create my JNDI data source in my code:
    <bean id="jndiDataSource" class="org.springframework.jndi.JndiObjectFactoryBean" lazy-init="true">
              <property name="jndiName" value="java:comp/env/jdbc/DS_OURDB_DB2" />
              <property name="lookupOnStartup" value="false"/>
              <property name="proxyInterface" value="javax.sql.DataSource"/>
         </bean>I have the necessary Resource added to my Tomcat's server.xml:
    <Resource accessToUnderlyingConnectionAllowed="false"
                defaultAutoCommit="true" defaultReadOnly="false"
                driverClassName="com.ibm.db2.jcc.DB2Driver"
                factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
                initialSize="0" logAbandoned="false" maxActive="8"
                maxIdle="8" maxOpenPreparedStatements="0" maxWait="-1"
                minEvictableIdleTimeMillis="1800000" minIdle="0"
                name="jdbc/DS_OURDB_DB2" numTestsPerEvictionRun="3"
                password="ourpass" poolPreparedStatements="false"
                removeAbandoned="false" removeAbandonedTimeout="300"
                testOnBorrow="true" testOnReturn="false"
                testWhileIdle="false" timeBetweenEvictionRunsMillis="-1"
                type="javax.sql.DataSource"
                url="jdbc:db2://machine1:60056/DBD1" username="ouruser"
                   validationQuery="SELECT current date FROM sysibm.sysdummy1"/>I then have the resource referenced in my web.xml:
    <resource-ref>
              <res-ref-name>jdbc/DS_OURDB_DB2</res-ref-name>
              <res-type>javax.sql.DataSource</res-type>
              <res-auth>Container</res-auth>
              <res-sharing-scope>Shareable</res-sharing-scope>
         </resource-ref>However, I'm getting JndiLookupFailureExceptions when I attempt to use this JNDI resource.
    I can resolve it by specifying the following in my META-INF/context.xml:
    <Context>
         <ResourceLink global="jdbc/DS_OURDB_DB2" name="jdbc/DS_OURDB_DB2" type="javax.sql.Datasource"/>
    </Context>I've read some of the JNDI/Tomcat documentation. However, I still do not understand why it doesn't work with the web.xml. Can anyone explain please? Thanks

    Can answer this myself after some more investigation. The reason I required the entry in the META-INF/context.xml was because I had specified the Resource as a Global Reference in the server.xml. By adding this Resource to my application's Context in the server.xml the configuration in the web.xml worked as expected.

  • 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.

  • Where to place /META-INF/context.xml ?

    Hi,
    Apologies, but this is a newbie question. In the tomcat docs, it states that
    "A /META-INF/context.xml file can be used to define Tomcat specific configuration..."
    Could you please tell me where /META-INF/context.xml is placed relative to web application root? In other words, if I have a web application in a directory /MyWebApp, should the /META-INF dir be in /MyWebApp/META-INF or should it be under /WEB-INF?
    Thanks.
    Ben

    You seem to think that you can have only one META-INF directory; this is simply not true. Keep both your META-INF directories and put the files where they are expected. Yay for using overlapping names :/

  • 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

  • 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