You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by sc <so...@hotmail.com> on 2007/04/29 07:21:10 UTC

Context started twice

There was a thread on this
"http://www.nabble.com/Context-starts-twice-t1351694.html". But my
configuration is a bit different.

this is my configuration:

server.xml doesn't have context definition.
context.xml is empty except this line    
<WatchedResource>WEB-INF/web.xml</WatchedResource>

under $CATALINA_HOME/Catalina/localhost, I defined a context xml file,
trip.xml

<?xml version='1.0' encoding='utf-8'?>
<Context docBase="d:/dev/trip/main/build" path="/trip">
    <Resource name="jdbc/trip" auth="Container" 
..........
</Context>


In my web.xml, I have the following entry, 

    <servlet>
        <servlet-name>dummy</servlet-name>
        <servlet-class>com.trip.view.DummyServlet</servlet-class>
         <load-on-startup>1</load-on-startup>
    </servlet>

When DummyServlet starts, it init twice. Any help is appreciated. 
-- 
View this message in context: http://www.nabble.com/Context-started-twice-tf3664516.html#a10239122
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Context started twice

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: sc [mailto:songchang@hotmail.com] 
> Subject: Re: Context started twice
> 
> This is my first time using nabble.com and surprised 
> to see how prompt I can get response.

Nabble has nothing to do with it - it's merely a web-based GUI for
several mailing lists, including Tomcat-user.  My personal preference
for a searchable Tomcat mailing list is:
http://marc.info/?l=tomcat-user

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Context started twice

Posted by Rashmi Rubdi <ra...@gmail.com>.
On 4/30/07, sc <so...@hotmail.com> wrote:
>
> All my mistake. I apologize for my stupidity. It turns out it wasn't invoked
> twice. It just prints twice. I had the following in log4j.properties.
>
> log4j.rootLogger=ERROR, TRIP
> log4j.logger.org.hibernate=WARN, TRIP
> log4j.logger.net.sf.hibernate=INFO, TRIP
> log4j.logger.com.cutetrip=DEBUG, TRIP

I would never have guessed that :-) , thanks for sharing your solution.

> I commented out log4j.rootLogger and it prints only one init now.
> Thanks for your help. This is my first time using nabble.com and surprised
> to see how prompt I can get response. Thanks again.
>

-Cheers
Rashmi

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Context started twice

Posted by sc <so...@hotmail.com>.
All my mistake. I apologize for my stupidity. It turns out it wasn't invoked
twice. It just prints twice. I had the following in log4j.properties.

log4j.rootLogger=ERROR, TRIP
log4j.logger.org.hibernate=WARN, TRIP
log4j.logger.net.sf.hibernate=INFO, TRIP
log4j.logger.com.cutetrip=DEBUG, TRIP

I commented out log4j.rootLogger and it prints only one init now.
Thanks for your help. This is my first time using nabble.com and surprised
to see how prompt I can get response. Thanks again.


Rashmi Rubdi-2 wrote:
> 
> I tested your code, the init is called exactly once, when Tomcat starts.
> 
> Try one of these:
> 
> 1) Change
>     log.info("TestServlet init");
>     log.info("TestServlet destroy");
> 
>     to something else like
> 
>     log.info("TestServlet init ############## ");
>     log.info("TestServlet destroy ##############");
> 
>     Re-compile, re-start TC if necessary and
>     check if you see 2 different outputs on the console.
> 
> 
> 2) If you see the same output twice, that is if you see
> 
>     log.info("TestServlet init ############## ");
>     log.info("TestServlet init ############## ");
> 
>     log.info("TestServlet destroy ##############");
>     log.info("TestServlet destroy ##############");
> 
>     then check web.xml if the same Servlet is defined twice under
> different names.
> 
> 3) Globally search for "TestServlet init" and see if it appears in
> more than one Servlet that may be visible to the current installation
> of Tomcat.
> 
> -Regards
> Rashmi
> 
> On 4/30/07, Rashmi Rubdi <ra...@gmail.com> wrote:
>> On 4/30/07, sc <so...@hotmail.com> wrote:
>> >
>> > As you suggested, I started from scratch. I downloaded tomcat 6 from
>> > apache.org. changed $catalina_home to point to the new directory. Under
>> > $catalina_home/webapps, I created a new folder, which only has one
>> servlet
>> > TestServlet
>> >
>>
>> Do a global search on your projects and also on C: or Home drive to
>> see if this line of code is defined in an additional Servlet that is
>> visible to the current installation of Tomcat:
>>
>> log.info("TestServlet init");
>>
>> I know you mentioned that there's only one Servlet under webapps, but
>> just in case...
>>
>> I also see super.init(config); but that shouldn't cause the
>> TestServlet's init method to be called twice.
>>
>> >
>> > public class TestServlet extends HttpServlet
>> > {
>> >     private Log log = LogFactory.getLog(this.getClass().getName());
>> >
>> >     //public void init() throws ServletException
>> >     public void init(ServletConfig config) throws ServletException
>> >     {
>> >         super.init(config);
>> >         log.info("TestServlet init");
>> >
>> >     }
>> >
>> >     public void destroy()
>> >     {
>> >         log.info("TestServlet destroy");
>> >     }
>> > }
>> >
>> >
>> > My web.xml as following:
>> > <?xml version="1.0" encoding="ISO-8859-1"?>
>> >
>> > <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_5.xsd"
>> >     version="2.5">
>> >
>> >
>> >     <display-name>Hello, World Application</display-name>
>> >     <description>
>> >         This is a simple web application with a source code
>> organization
>> >         based on the recommendations of the Application Developer's
>> Guide.
>> >     </description>
>> >
>> >
>> >     <servlet>
>> >         <servlet-name>test</servlet-name>
>> >         <servlet-class>com.trip.view.TestServlet</servlet-class>
>> >          <load-on-startup>1</load-on-startup>
>> >     </servlet>
>> >
>> >     <servlet-mapping>
>> >         <servlet-name>test</servlet-name>
>> >         <url-pattern>/test</url-pattern>
>> >     </servlet-mapping>
>> >
>> > </web-app>
>> >
>> > I didn't do any changes to the new installation of tomcat. Then I
>> started
>> > tomcat and shutdown it.
>> > The log showed the following entries:
>> > 2007-04-30 12:35:27,968 [main] INFO  com.cutetrip.view.TestServlet -
>> > TestServlet init
>> > 2007-04-30 12:35:27,968 [main] INFO  com.cutetrip.view.TestServlet -
>> > TestServlet init
>> > 2007-04-30 12:35:40,046 [main] INFO  com.cutetrip.view.TestServlet -
>> > TestServlet destroy
>> > 2007-04-30 12:35:40,046 [main] INFO  com.cutetrip.view.TestServlet -
>> > TestServlet destroy
>> >
>> > Since I just downloaded Tomcat, it is likely the double init is caused
>> by my
>> > application or local environment setting. Anywhere I should look at? I
>> am
>> > very puzzled.
>> > Thanks.
>>
>> I will try to replicate this.
>>
>> Regards
>> -Rashmi
>>
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Context-started-twice-tf3664516.html#a10264243
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Context started twice

Posted by Rashmi Rubdi <ra...@gmail.com>.
I tested your code, the init is called exactly once, when Tomcat starts.

Try one of these:

1) Change
    log.info("TestServlet init");
    log.info("TestServlet destroy");

    to something else like

    log.info("TestServlet init ############## ");
    log.info("TestServlet destroy ##############");

    Re-compile, re-start TC if necessary and
    check if you see 2 different outputs on the console.


2) If you see the same output twice, that is if you see

    log.info("TestServlet init ############## ");
    log.info("TestServlet init ############## ");

    log.info("TestServlet destroy ##############");
    log.info("TestServlet destroy ##############");

    then check web.xml if the same Servlet is defined twice under
different names.

3) Globally search for "TestServlet init" and see if it appears in
more than one Servlet that may be visible to the current installation
of Tomcat.

-Regards
Rashmi

On 4/30/07, Rashmi Rubdi <ra...@gmail.com> wrote:
> On 4/30/07, sc <so...@hotmail.com> wrote:
> >
> > As you suggested, I started from scratch. I downloaded tomcat 6 from
> > apache.org. changed $catalina_home to point to the new directory. Under
> > $catalina_home/webapps, I created a new folder, which only has one servlet
> > TestServlet
> >
>
> Do a global search on your projects and also on C: or Home drive to
> see if this line of code is defined in an additional Servlet that is
> visible to the current installation of Tomcat:
>
> log.info("TestServlet init");
>
> I know you mentioned that there's only one Servlet under webapps, but
> just in case...
>
> I also see super.init(config); but that shouldn't cause the
> TestServlet's init method to be called twice.
>
> >
> > public class TestServlet extends HttpServlet
> > {
> >     private Log log = LogFactory.getLog(this.getClass().getName());
> >
> >     //public void init() throws ServletException
> >     public void init(ServletConfig config) throws ServletException
> >     {
> >         super.init(config);
> >         log.info("TestServlet init");
> >
> >     }
> >
> >     public void destroy()
> >     {
> >         log.info("TestServlet destroy");
> >     }
> > }
> >
> >
> > My web.xml as following:
> > <?xml version="1.0" encoding="ISO-8859-1"?>
> >
> > <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_5.xsd"
> >     version="2.5">
> >
> >
> >     <display-name>Hello, World Application</display-name>
> >     <description>
> >         This is a simple web application with a source code organization
> >         based on the recommendations of the Application Developer's Guide.
> >     </description>
> >
> >
> >     <servlet>
> >         <servlet-name>test</servlet-name>
> >         <servlet-class>com.trip.view.TestServlet</servlet-class>
> >          <load-on-startup>1</load-on-startup>
> >     </servlet>
> >
> >     <servlet-mapping>
> >         <servlet-name>test</servlet-name>
> >         <url-pattern>/test</url-pattern>
> >     </servlet-mapping>
> >
> > </web-app>
> >
> > I didn't do any changes to the new installation of tomcat. Then I started
> > tomcat and shutdown it.
> > The log showed the following entries:
> > 2007-04-30 12:35:27,968 [main] INFO  com.cutetrip.view.TestServlet -
> > TestServlet init
> > 2007-04-30 12:35:27,968 [main] INFO  com.cutetrip.view.TestServlet -
> > TestServlet init
> > 2007-04-30 12:35:40,046 [main] INFO  com.cutetrip.view.TestServlet -
> > TestServlet destroy
> > 2007-04-30 12:35:40,046 [main] INFO  com.cutetrip.view.TestServlet -
> > TestServlet destroy
> >
> > Since I just downloaded Tomcat, it is likely the double init is caused by my
> > application or local environment setting. Anywhere I should look at? I am
> > very puzzled.
> > Thanks.
>
> I will try to replicate this.
>
> Regards
> -Rashmi
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Context started twice

Posted by Rashmi Rubdi <ra...@gmail.com>.
On 4/30/07, sc <so...@hotmail.com> wrote:
>
> As you suggested, I started from scratch. I downloaded tomcat 6 from
> apache.org. changed $catalina_home to point to the new directory. Under
> $catalina_home/webapps, I created a new folder, which only has one servlet
> TestServlet
>

Do a global search on your projects and also on C: or Home drive to
see if this line of code is defined in an additional Servlet that is
visible to the current installation of Tomcat:

log.info("TestServlet init");

I know you mentioned that there's only one Servlet under webapps, but
just in case...

I also see super.init(config); but that shouldn't cause the
TestServlet's init method to be called twice.

>
> public class TestServlet extends HttpServlet
> {
>     private Log log = LogFactory.getLog(this.getClass().getName());
>
>     //public void init() throws ServletException
>     public void init(ServletConfig config) throws ServletException
>     {
>         super.init(config);
>         log.info("TestServlet init");
>
>     }
>
>     public void destroy()
>     {
>         log.info("TestServlet destroy");
>     }
> }
>
>
> My web.xml as following:
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <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_5.xsd"
>     version="2.5">
>
>
>     <display-name>Hello, World Application</display-name>
>     <description>
>         This is a simple web application with a source code organization
>         based on the recommendations of the Application Developer's Guide.
>     </description>
>
>
>     <servlet>
>         <servlet-name>test</servlet-name>
>         <servlet-class>com.trip.view.TestServlet</servlet-class>
>          <load-on-startup>1</load-on-startup>
>     </servlet>
>
>     <servlet-mapping>
>         <servlet-name>test</servlet-name>
>         <url-pattern>/test</url-pattern>
>     </servlet-mapping>
>
> </web-app>
>
> I didn't do any changes to the new installation of tomcat. Then I started
> tomcat and shutdown it.
> The log showed the following entries:
> 2007-04-30 12:35:27,968 [main] INFO  com.cutetrip.view.TestServlet -
> TestServlet init
> 2007-04-30 12:35:27,968 [main] INFO  com.cutetrip.view.TestServlet -
> TestServlet init
> 2007-04-30 12:35:40,046 [main] INFO  com.cutetrip.view.TestServlet -
> TestServlet destroy
> 2007-04-30 12:35:40,046 [main] INFO  com.cutetrip.view.TestServlet -
> TestServlet destroy
>
> Since I just downloaded Tomcat, it is likely the double init is caused by my
> application or local environment setting. Anywhere I should look at? I am
> very puzzled.
> Thanks.

I will try to replicate this.

Regards
-Rashmi

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Context started twice

Posted by sc <so...@hotmail.com>.
As you suggested, I started from scratch. I downloaded tomcat 6 from
apache.org. changed $catalina_home to point to the new directory. Under
$catalina_home/webapps, I created a new folder, which only has one servlet
TestServlet


public class TestServlet extends HttpServlet
{
    private Log log = LogFactory.getLog(this.getClass().getName());

    //public void init() throws ServletException
    public void init(ServletConfig config) throws ServletException
    {
	super.init(config);
        log.info("TestServlet init");

    }

    public void destroy()
    {
	log.info("TestServlet destroy");
    }
}


My web.xml as following:
<?xml version="1.0" encoding="ISO-8859-1"?>

<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_5.xsd"
    version="2.5">


    <display-name>Hello, World Application</display-name>
    <description>
	This is a simple web application with a source code organization
	based on the recommendations of the Application Developer's Guide.
    </description>


    <servlet>
        <servlet-name>test</servlet-name>
        <servlet-class>com.trip.view.TestServlet</servlet-class>
         <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>test</servlet-name>
        <url-pattern>/test</url-pattern>
    </servlet-mapping>

</web-app>

I didn't do any changes to the new installation of tomcat. Then I started
tomcat and shutdown it. 
The log showed the following entries:
2007-04-30 12:35:27,968 [main] INFO  com.cutetrip.view.TestServlet -
TestServlet init
2007-04-30 12:35:27,968 [main] INFO  com.cutetrip.view.TestServlet -
TestServlet init
2007-04-30 12:35:40,046 [main] INFO  com.cutetrip.view.TestServlet -
TestServlet destroy
2007-04-30 12:35:40,046 [main] INFO  com.cutetrip.view.TestServlet -
TestServlet destroy

Since I just downloaded Tomcat, it is likely the double init is caused by my
application or local environment setting. Anywhere I should look at? I am
very puzzled.
Thanks.


Rashmi Rubdi-2 wrote:
> 
> Please ignore my previous post.
> 
> Sorry, when you mentioned context.xml I was thinking of the one
> located under the project's META-INF folder.
> 
> Chuck is right, there's no need to move the contents of the
> conf/context.xml file anywhere.
> 
> Whenever configuration gets messed up (happens very rarely), I
> normally start with a fresh install of the zip version of Tomcat after
> backing up the existing version. This process normally fixes my
> problems quickly with little effort.
> 
> -Regards
> Rashmi
> 
> On 4/29/07, sc <so...@hotmail.com> wrote:
>>
>> I tried as you suggested. But didn't work. I have cleaned up tomcat
>> deployment directories and currently the configuration is very simple.
>>
>> Under $CATALINA_HOME/webapps, there is only one directory ROOT.
>> Under $CATALINA_HOME/Catalina, there is  only one directory "localhost",
>> which in turn only contains 1 file trip.xml
>>
>>   <?xml version='1.0' encoding='utf-8'?>
>> <Context docBase="d:/dev/trip/main/build">
>>    <Resource name="jdbc/trip" auth="Container"
>>        type="javax.sql.DataSource"
>>        username="sa"
>>        password="xxxxx"
>>        driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
>>        url="jdbc:microsoft:sqlserver://localhost:1433;databaseName=trip"
>>        maxActive="8"
>>        maxIdle="4"/>
>>
>>    <WatchedResource>WEB-INF/web.xml</WatchedResource>
>> <!-- Note: as suggested, I have moved the above entry from context.xml
>> over
>> here. -->
>>  <Logger className="org.apache.catalina.logger.FileLogger"
>>             prefix="local_cutetrip." suffix=".log"
>>          timestamp="true"/>
>>
>> </Context>
>>
>> $CATALINA_HOME/conf/server.xml is as following:
>>
>> <Server port="8005" shutdown="SHUTDOWN">
>>
>>  <Listener className="org.apache.catalina.core.AprLifecycleListener" />
>>  <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" maxHttpHeaderSize="8192"
>>               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">
>>
>>      </Host>
>>
>>    </Engine>
>>
>>  </Service>
>>
>> </Server>
>>
>> $CATALINA_HOME/conf/context.xml is:
>> <Context>
>> </Context>
>>
>>
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Context-started-twice-tf3664516.html#a10248444
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Context started twice

Posted by Rashmi Rubdi <ra...@gmail.com>.
Please ignore my previous post.

Sorry, when you mentioned context.xml I was thinking of the one
located under the project's META-INF folder.

Chuck is right, there's no need to move the contents of the
conf/context.xml file anywhere.

Whenever configuration gets messed up (happens very rarely), I
normally start with a fresh install of the zip version of Tomcat after
backing up the existing version. This process normally fixes my
problems quickly with little effort.

-Regards
Rashmi

On 4/29/07, sc <so...@hotmail.com> wrote:
>
> I tried as you suggested. But didn't work. I have cleaned up tomcat
> deployment directories and currently the configuration is very simple.
>
> Under $CATALINA_HOME/webapps, there is only one directory ROOT.
> Under $CATALINA_HOME/Catalina, there is  only one directory "localhost",
> which in turn only contains 1 file trip.xml
>
>   <?xml version='1.0' encoding='utf-8'?>
> <Context docBase="d:/dev/trip/main/build">
>    <Resource name="jdbc/trip" auth="Container"
>        type="javax.sql.DataSource"
>        username="sa"
>        password="xxxxx"
>        driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
>        url="jdbc:microsoft:sqlserver://localhost:1433;databaseName=trip"
>        maxActive="8"
>        maxIdle="4"/>
>
>    <WatchedResource>WEB-INF/web.xml</WatchedResource>
> <!-- Note: as suggested, I have moved the above entry from context.xml over
> here. -->
>  <Logger className="org.apache.catalina.logger.FileLogger"
>             prefix="local_cutetrip." suffix=".log"
>          timestamp="true"/>
>
> </Context>
>
> $CATALINA_HOME/conf/server.xml is as following:
>
> <Server port="8005" shutdown="SHUTDOWN">
>
>  <Listener className="org.apache.catalina.core.AprLifecycleListener" />
>  <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" maxHttpHeaderSize="8192"
>               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">
>
>      </Host>
>
>    </Engine>
>
>  </Service>
>
> </Server>
>
> $CATALINA_HOME/conf/context.xml is:
> <Context>
> </Context>
>
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Context started twice

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: sc [mailto:songchang@hotmail.com] 
> Subject: RE: Context started twice
> 
>   <Logger className="org.apache.catalina.logger.FileLogger"
>              prefix="local_cutetrip." suffix=".log"
>           timestamp="true"/>

Note the following from the 5.5 doc:

"An important consequence for Tomcat 5.5 is that the <Logger> element
found in previous versions to create a localhost_log is no longer a
valid nested element of <Context>."

To see how to set up app-specific loging, look at:
http://tomcat.apache.org/tomcat-5.5-doc/logging.html

Don't know if this has anything to do with the double init(), but some
erroneous <Context> entries have been known to result in erratic app
behavior.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Context started twice

Posted by sc <so...@hotmail.com>.
I tried as you suggested. But didn't work. I have cleaned up tomcat
deployment directories and currently the configuration is very simple.
 
Under $CATALINA_HOME/webapps, there is only one directory ROOT.
Under $CATALINA_HOME/Catalina, there is  only one directory "localhost",
which in turn only contains 1 file trip.xml

   <?xml version='1.0' encoding='utf-8'?>
<Context docBase="d:/dev/trip/main/build">
    <Resource name="jdbc/trip" auth="Container" 
        type="javax.sql.DataSource"
        username="sa"
        password="xxxxx" 
        driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
        url="jdbc:microsoft:sqlserver://localhost:1433;databaseName=trip"
        maxActive="8" 
        maxIdle="4"/>

    <WatchedResource>WEB-INF/web.xml</WatchedResource>
<!-- Note: as suggested, I have moved the above entry from context.xml over
here. -->
  <Logger className="org.apache.catalina.logger.FileLogger"
             prefix="local_cutetrip." suffix=".log"
          timestamp="true"/>

</Context>

$CATALINA_HOME/conf/server.xml is as following:

<Server port="8005" shutdown="SHUTDOWN">

  <Listener className="org.apache.catalina.core.AprLifecycleListener" />
  <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" maxHttpHeaderSize="8192"
               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">

      </Host>

    </Engine>

  </Service>

</Server>

$CATALINA_HOME/conf/context.xml is:
<Context>
</Context>



Caldarale, Charles R wrote:
> 
>> From: Rashmi Rubdi [mailto:rashmi.sub@gmail.com] 
>> Subject: Re: Context started twice
>> 
>> Seems to me that the Context is defined in 2 places First:
>> > context.xml is empty except this line
>> > <WatchedResource>WEB-INF/web.xml</WatchedResource>
>> 
>> I would suggest moving
>> <WatchedResource>WEB-INF/web.xml</WatchedResource> also inside
>> trip.xml
>> 
>> And change the /META-INF/context.xml entry to <Context/>
> 
> The OP doesn't have a META-INF/context.xml file; the one being talked
> about is the global one in conf/context.xml, which applies to all
> deployed apps.  Moving the <WatchedResource> element is unnecessary.
> 
> Creating a META-INF/context.xml is useless, since the
> conf/Catalina/localhost/trip.xml will override it.
> 
> None of which explains why the init() method of the servlet in question
> is being called twice.  Is there another copy of the trip application
> deployed under Tomcat's webapps directory?
> 
>  - Chuck
> 
> 
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you
> received this in error, please contact the sender and delete the e-mail
> and its attachments from all computers.
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Context-started-twice-tf3664516.html#a10247619
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Context started twice

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Rashmi Rubdi [mailto:rashmi.sub@gmail.com] 
> Subject: Re: Context started twice
> 
> Seems to me that the Context is defined in 2 places First:
> > context.xml is empty except this line
> > <WatchedResource>WEB-INF/web.xml</WatchedResource>
> 
> I would suggest moving
> <WatchedResource>WEB-INF/web.xml</WatchedResource> also inside
> trip.xml
> 
> And change the /META-INF/context.xml entry to <Context/>

The OP doesn't have a META-INF/context.xml file; the one being talked
about is the global one in conf/context.xml, which applies to all
deployed apps.  Moving the <WatchedResource> element is unnecessary.

Creating a META-INF/context.xml is useless, since the
conf/Catalina/localhost/trip.xml will override it.

None of which explains why the init() method of the servlet in question
is being called twice.  Is there another copy of the trip application
deployed under Tomcat's webapps directory?

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Context started twice

Posted by Rashmi Rubdi <ra...@gmail.com>.
On 4/29/07, sc <so...@hotmail.com> wrote:
>
> There was a thread on this
> "http://www.nabble.com/Context-starts-twice-t1351694.html". But my
> configuration is a bit different.
>
> this is my configuration:
>
> server.xml doesn't have context definition.

Seems to me that the Context is defined in 2 places First:
> context.xml is empty except this line
> <WatchedResource>WEB-INF/web.xml</WatchedResource>


Second (modified) :
>
> under $CATALINA_HOME/Catalina/localhost, I defined a context xml file,
> trip.xml
>
> <?xml version='1.0' encoding='utf-8'?>
> <Context docBase="d:/dev/trip/main/build" path="">
>     <Resource name="jdbc/trip" auth="Container"
> ..........
> </Context>
>

I would suggest moving
<WatchedResource>WEB-INF/web.xml</WatchedResource> also inside
trip.xml

And change the /META-INF/context.xml entry to <Context/>


>
> In my web.xml, I have the following entry,
>
>     <servlet>
>         <servlet-name>dummy</servlet-name>
>         <servlet-class>com.trip.view.DummyServlet</servlet-class>
>          <load-on-startup>1</load-on-startup>
>     </servlet>
>
> When DummyServlet starts, it init twice. Any help is appreciated.
> --
> View this message in context: http://www.nabble.com/Context-started-twice-tf3664516.html#a10239122
> Sent from the Tomcat - User mailing list archive at Nabble.com.

-Rashmi

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Context started twice

Posted by Martin Gainty <mg...@hotmail.com>.
You should not need both
http://tomcat.apache.org/tomcat-5.5-doc/config/context.html

The definition of path
path = 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 
inferred from the filenames used for either the .xml context file or the 
docBase.

The definition of docBase
docBase = The Document Base (also known as the Context Root) directory for 
this web application, or the pathname to the web application archive file 
(if this web application is being executed directly from the WAR file). You 
may specify an absolute pathname for this directory or WAR file, or a 
pathname that is relative to the appBase directory of the owning Host.
If a symbolic link is used for docBase then changes to the symbolic link 
will only be effective after a Tomcat restart or by undeploying and 
redeploying the conext. A context reload is not sufficient.

Do not choose a docBase that starts with your Host's appBase string. The 
default appBase is "webapps" so do not choose a docBase like "webapps-foo." 
Doing so will lead to deployment errors: see Bugzilla for details.

HTH
martin

This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.

----- Original Message ----- 
From: "sc" <so...@hotmail.com>
To: <us...@tomcat.apache.org>
Sent: Sunday, April 29, 2007 10:41 AM
Subject: Re: Context started twice


>
> I removed /path. Still the same problem. The version I am using is 5.5.17 
> and
> it is win xp.
>
>
> Pid-2 wrote:
>>
>> sc wrote:
>>> There was a thread on this
>>> "http://www.nabble.com/Context-starts-twice-t1351694.html". But my
>>> configuration is a bit different.
>>>
>>> this is my configuration:
>>>
>>> server.xml doesn't have context definition.
>>> context.xml is empty except this line
>>> <WatchedResource>WEB-INF/web.xml</WatchedResource>
>>>
>>> under $CATALINA_HOME/Catalina/localhost, I defined a context xml file,
>>> trip.xml
>>>
>>> <?xml version='1.0' encoding='utf-8'?>
>>> <Context docBase="d:/dev/trip/main/build" path="/trip">
>>>     <Resource name="jdbc/trip" auth="Container"
>>> ..........
>>> </Context>
>>
>>
>> Note: path attribute should not be set unless context is defined in
>> server.xml, which is *strongly* discouraged.
>>
>>   <?xml version='1.0' encoding='utf-8'?>
>>   <Context docBase="d:/dev/trip/main/build">
>>       <Resource name="jdbc/trip" auth="Container"
>>   ..........
>>   </Context>
>>
>> Won't fix your problem tho.
>> Which version of Tomcat, OS? etc
>>
>>
>> p
>>
>>
>>
>>> In my web.xml, I have the following entry,
>>>
>>>     <servlet>
>>>         <servlet-name>dummy</servlet-name>
>>>         <servlet-class>com.trip.view.DummyServlet</servlet-class>
>>>          <load-on-startup>1</load-on-startup>
>>>     </servlet>
>>>
>>> When DummyServlet starts, it init twice. Any help is appreciated.
>>
>>
>>
>>
>
> -- 
> View this message in context: 
> http://www.nabble.com/Context-started-twice-tf3664516.html#a10242348
> Sent from the Tomcat - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
> 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Context started twice

Posted by sc <so...@hotmail.com>.
I removed /path. Still the same problem. The version I am using is 5.5.17 and
it is win xp. 


Pid-2 wrote:
> 
> sc wrote:
>> There was a thread on this
>> "http://www.nabble.com/Context-starts-twice-t1351694.html". But my
>> configuration is a bit different.
>> 
>> this is my configuration:
>> 
>> server.xml doesn't have context definition.
>> context.xml is empty except this line    
>> <WatchedResource>WEB-INF/web.xml</WatchedResource>
>> 
>> under $CATALINA_HOME/Catalina/localhost, I defined a context xml file,
>> trip.xml
>> 
>> <?xml version='1.0' encoding='utf-8'?>
>> <Context docBase="d:/dev/trip/main/build" path="/trip">
>>     <Resource name="jdbc/trip" auth="Container" 
>> ..........
>> </Context>
> 
> 
> Note: path attribute should not be set unless context is defined in 
> server.xml, which is *strongly* discouraged.
> 
>   <?xml version='1.0' encoding='utf-8'?>
>   <Context docBase="d:/dev/trip/main/build">
>       <Resource name="jdbc/trip" auth="Container"
>   ..........
>   </Context>
> 
> Won't fix your problem tho.
> Which version of Tomcat, OS? etc
> 
> 
> p
> 
> 
> 
>> In my web.xml, I have the following entry, 
>> 
>>     <servlet>
>>         <servlet-name>dummy</servlet-name>
>>         <servlet-class>com.trip.view.DummyServlet</servlet-class>
>>          <load-on-startup>1</load-on-startup>
>>     </servlet>
>> 
>> When DummyServlet starts, it init twice. Any help is appreciated. 
> 
> 
>  
> 

-- 
View this message in context: http://www.nabble.com/Context-started-twice-tf3664516.html#a10242348
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Context started twice

Posted by Pid <p...@pidster.com>.
sc wrote:
> There was a thread on this
> "http://www.nabble.com/Context-starts-twice-t1351694.html". But my
> configuration is a bit different.
> 
> this is my configuration:
> 
> server.xml doesn't have context definition.
> context.xml is empty except this line    
> <WatchedResource>WEB-INF/web.xml</WatchedResource>
> 
> under $CATALINA_HOME/Catalina/localhost, I defined a context xml file,
> trip.xml
> 
> <?xml version='1.0' encoding='utf-8'?>
> <Context docBase="d:/dev/trip/main/build" path="/trip">
>     <Resource name="jdbc/trip" auth="Container" 
> ..........
> </Context>


Note: path attribute should not be set unless context is defined in 
server.xml, which is *strongly* discouraged.

  <?xml version='1.0' encoding='utf-8'?>
  <Context docBase="d:/dev/trip/main/build">
      <Resource name="jdbc/trip" auth="Container"
  ..........
  </Context>

Won't fix your problem tho.
Which version of Tomcat, OS? etc


p



> In my web.xml, I have the following entry, 
> 
>     <servlet>
>         <servlet-name>dummy</servlet-name>
>         <servlet-class>com.trip.view.DummyServlet</servlet-class>
>          <load-on-startup>1</load-on-startup>
>     </servlet>
> 
> When DummyServlet starts, it init twice. Any help is appreciated. 


RE: Context started twice

Posted by "Raghupathy, Gurumoorthy" <Gu...@nielsen.com>.
Can you post your dummyservlet Code ?

	
Thanks
Guru

-----Original Message-----
From: sc [mailto:songchang@hotmail.com] 
Sent: 29 April 2007 06:21
To: users@tomcat.apache.org
Subject: Context started twice


There was a thread on this
"http://www.nabble.com/Context-starts-twice-t1351694.html". But my
configuration is a bit different.

this is my configuration:

server.xml doesn't have context definition.
context.xml is empty except this line    
<WatchedResource>WEB-INF/web.xml</WatchedResource>

under $CATALINA_HOME/Catalina/localhost, I defined a context xml file,
trip.xml

<?xml version='1.0' encoding='utf-8'?>
<Context docBase="d:/dev/trip/main/build" path="/trip">
    <Resource name="jdbc/trip" auth="Container" 
..........
</Context>


In my web.xml, I have the following entry, 

    <servlet>
        <servlet-name>dummy</servlet-name>
        <servlet-class>com.trip.view.DummyServlet</servlet-class>
         <load-on-startup>1</load-on-startup>
    </servlet>

When DummyServlet starts, it init twice. Any help is appreciated. 
-- 
View this message in context:
http://www.nabble.com/Context-started-twice-tf3664516.html#a10239122
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org