• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

listener tag makes the service false

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Friends,

When i add the tag for listener in the web.xml, it makes the startup fails of my application. Below is my web.xml file.
Please help....

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app>
<context-param>
<param-name>companyName</param-name>
<param-value>not-dot-com.com</param-value>
</context-param>

<context-param>
<param-name>formerCompanyName</param-name>
<param-value>hot-dot-com.com</param-value>
</context-param>

<listener>
<listener-class>coreservlets.listeners.InitialCompanyNameListener</listener-class>
</listener>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>

</web-app>

 
Creator of Enthuware JWS+ V6
Posts: 3412
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the error you get?
How does your listener class look like?
How is the structure of your web-app?

Regards,
Frits
 
Rupal Rshah
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The error is that it could not deploy my application. It gives message like SEVERE: Error listenerStart

package myPkg;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
public class InitialCompanyNameListener implements ServletContextListener {
private static final String DEFAULT_NAME = "MISSING-COMPANY-NAME";

public void contextInitialized(ServletContextEvent event) {

ServletContext context = event.getServletContext();
setInitialAttribute(context,"companyName",DEFAULT_NAME);
setInitialAttribute(context,"formerCompanyName","");

}
public void contextDestroyed(ServletContextEvent event) {}


private void setInitialAttribute(ServletContext context,String initParamName,String defaultValue)
{
String initialValue = context.getInitParameter(initParamName);
if (initialValue != null) {
context.setAttribute(initParamName, initialValue);
}
else
{
context.setAttribute(initParamName, defaultValue);
}
System.out.println(initialValue+"PARAM: " + initParamName);
}
}



This file is within WEB-INF/classes/myPkg;
My web.xml is in WEB-INF


 
Frits Walraven
Creator of Enthuware JWS+ V6
Posts: 3412
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
change:

into:


That should help.

Regards,
Frits
 
Rupal Rshah
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Frits,

Have done that, but it does not work. Actually have changed the package after the first post, so it was the earlier version.
 
Ranch Hand
Posts: 623
1
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So put the most actual code you try to deploy. It's hard to guess what did you change...

Also try commenting your methods code - compile it and redeploy. You will now if the listener is properly initialized (empty) and if so, then you can modify it's code.

Rupal Rshah wrote:This file is within WEB-INF/classes/myPkg;



I hope you mean the *.class file of this source code, right? :-)

Cheers!
 
Frits Walraven
Creator of Enthuware JWS+ V6
Posts: 3412
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, I included everything in my tomcat 5.5 server and it worked well.

How do you create your .war file? It looks like the wep-app can't find your listener....
What tomcat server are you using?

Regards,
Frits
 
Rupal Rshah
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using Tomcat 7. I have not created .war file for this application
 
Frits Walraven
Creator of Enthuware JWS+ V6
Posts: 3412
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your problem might be caused by a directory structure problem, try to build a .war file by hand.

you can use the following instructions: HowToCreateWebApplicationWithoutAnIDE

Regards,
Frits
 
Rupal Rshah
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you all....My problem got solved
 
Piotr Nowicki
Ranch Hand
Posts: 623
1
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, share with the rest what was the problem, so if someone else bump into the same problem, will not what you did to fix it :-)

Cheers!
 
Humans and their filthy friendship brings nothing but trouble. My only solace is this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic