Context started twice

2007-04-28 Thread sc

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
WEB-INF/web.xml

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






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


dummy
com.trip.view.DummyServlet
 1


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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Context started twice

2007-04-29 Thread sc

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
>> WEB-INF/web.xml
>> 
>> under $CATALINA_HOME/Catalina/localhost, I defined a context xml file,
>> trip.xml
>> 
>> 
>> 
>> > ..
>> 
> 
> 
> Note: path attribute should not be set unless context is defined in 
> server.xml, which is *strongly* discouraged.
> 
>   
>   
>  ..
>   
> 
> Won't fix your problem tho.
> Which version of Tomcat, OS? etc
> 
> 
> p
> 
> 
> 
>> In my web.xml, I have the following entry, 
>> 
>> 
>> dummy
>> com.trip.view.DummyServlet
>>  1
>> 
>> 
>> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Context started twice

2007-04-29 Thread sc

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

   



WEB-INF/web.xml

  



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



  
  
  
  

  





  

  







  


  

  



  



$CATALINA_HOME/conf/context.xml is:





Caldarale, Charles R wrote:
> 
>> From: Rashmi Rubdi [mailto:[EMAIL PROTECTED] 
>> Subject: Re: Context started twice
>> 
>> Seems to me that the Context is defined in 2 places First:
>> > context.xml is empty except this line
>> > WEB-INF/web.xml
>> 
>> I would suggest moving
>> WEB-INF/web.xml also inside
>> trip.xml
>> 
>> And change the /META-INF/context.xml entry to 
> 
> 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  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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Context started twice

2007-04-29 Thread sc

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:


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


Hello, World Application

This is a simple web application with a source code organization
based on the recommendations of the Application Developer's Guide.




test
com.trip.view.TestServlet
 1



test
/test




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 <[EMAIL PROTECTED]> 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
>>
>>   
>> 
>>>type="javax.sql.DataSource"
>>username="sa"
>>password="x"
>>driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
>>url="jdbc:microsoft:sqlserver://localhost:1433;databaseName=trip"
>>maxActive="8"
>>maxIdle="4"/>
>>
>>WEB-INF/web.xml
>> 
>>  > prefix="local_cutetrip." suffix=".log"
>>  timestamp="true"/>
>>
>> 
>>
>> $CATALINA_HOME/conf/server.xml is as following:
>>
>> 
>>
>>  
>>  > />
>>  > className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
>> />
>>  > className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
>>
>>  
>>
>>
>>
>>>  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" />
>>
>>  
>>
>>  
>>
>>>   maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
>>   enableLookups="false" redirectPort="8443" acceptCount="100"
>>   connectionTimeout="2" disableUploadTimeout="true" />
>>
>>>   enableLookups="false" redirectPort="8443"
>> protocol="AJP/1.3"
>> />
>>
>>
>>
>>  > resourceName="UserDatabase"/>
>>
>>
>>  >   unpackWARs="true" autoDeploy="true"
>>   xmlValidation="false" xmlNamespaceAware="false">
>>
>>  
>>
>>
>>
>>  
>>
>> 
>>
>> $CATALINA_HOME/conf/context.xml is:
>> 
>> 
>>
>>
> 
> -
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Context started twice

2007-04-30 Thread sc

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 <[EMAIL PROTECTED]> wrote:
>> On 4/30/07, sc <[EMAIL PROTECTED]> 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:
>> > 
>> >
>> > 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">
>> >
>> >
>> > Hello, World Application
>> > 
>> > This is a simple web application with a source code
>> organization
>> > based on the recommendations of the Application Developer's
>> Guide.
>> > 
>> >
>> >
>> > 
>> > test
>> > com.trip.view.TestServlet
>> >  1
>> > 
>> >
>> > 
>> > test
>> > /test
>> > 
>> >
>> > 
>> >
>> > 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]