Meaningless Drivel is fun!*
The moose likes Ant, Maven and Other Build Tools and the fly likes Seeting Ant for deployment to tomcat using eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Seeting Ant for deployment to tomcat using eclipse" Watch "Seeting Ant for deployment to tomcat using eclipse" New topic
Author

Seeting Ant for deployment to tomcat using eclipse

Suresh KumarPandey
Ranch Hand

Joined: Sep 08, 2012
Posts: 46
Hi i have got tomcat 7.0 and eclipse juno 4.2 installed,i have just downloaded the Ant and extracted it in C:\apache-ant-1.8.4 but i dont know how to use it to create .war file
can somebody help
when i am creating the war file using eclipse and placing the war file in the tomcat webapps folder asn starting tomcat folder structure for project is created but when running from tomcat error 404 is giving so searched and found that ant should be used for creating the war file and placing in teh webapps of tomcat



can somebody help please
tomcat installation directory is-C:\Program Files\Apache Software Foundation\Tomcat 7.0
my eclipse workspace is-c:\Users\DELL\Workspace
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

There are several online tutorials for building war files using ant: ant build war

By the way, just because you got a 404 error doesn't mean that you must use Ant to solve that problem. Perhaps if you told us exactly what you did (the name of your WAR file, exactly where you copied it, giving full file paths and the full location of Tomcat), and told us exactly what URL you used, we might be able to help you get running without having to learn Ant.


JBoss In Action
Suresh KumarPandey
Ranch Hand

Joined: Sep 08, 2012
Posts: 46
C:\Program Files\Apache Software Foundation\Tomcat 7.0 -This is the location of mytomcat
I have created a dynamic web project HelloWorldStruts2 using Struts and i am using eclipse juno and created the war file HelloWorldStruts2.war in the tomcat webapps folder
i am using url as http://localhost:8080/HelloWorldStruts2/index.jsp

my struts.xml file is
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true" />
<package name="helloworld" extends="struts-default">

<action name="hello"
class="com.tutorialspoint.struts2.HelloWorldAction"
method="execute">
<result name="success">/HelloWorld.jsp</result>
</action>
</package>
</struts>




my web.xml file is
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true" />
<package name="helloworld" extends="struts-default">

<action name="hello"
class="com.tutorialspoint.struts2.HelloWorldAction"
method="execute">
<result name="success">/HelloWorld.jsp</result>
</action>
</package>
</struts>


actually when i downloaded a war file from net and kept it in webapps of my tomcat directory it worked fine and when i placed the content of HelloWorldStruts2 in folder which i downloaded from net it is working fine but somehow it is not recognising HelloWorldStruts2
I have attached screenshots which you can have look at.
i have put the struts file in the lib directory of web-inf
Struts version is 2.3.4.1
previously somehow i dont know it was getting deployed now it is giving some error
Suresh KumarPandey
Ranch Hand

Joined: Sep 08, 2012
Posts: 46
Sorry could not attach scrren shots here is error of eclipse whily deploying HelloWorldStruts2


Nov 17, 2012 12:54:07 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.32
Nov 17, 2012 12:54:08 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Parsing configuration file [struts-default.xml]
Nov 17, 2012 12:54:08 PM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter struts2
java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:209)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:102)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:210)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:390)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:437)
at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:193)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:277)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:258)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:382)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:103)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4650)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5306)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
... 21 more

Nov 17, 2012 12:54:08 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error filterStart
Nov 17, 2012 12:54:08 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/HelloWorldStruts2] startup failed due to previous errors
Nov 17, 2012 12:54:08 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\mytomcat-eclipse-helloworld.war
Nov 17, 2012 12:54:08 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\docs
Nov 17, 2012 12:54:08 PM org.apache.catalina.startup.HostConfig deployDirectory
Suresh KumarPandey
Ranch Hand

Joined: Sep 08, 2012
Posts: 46

SEVERE: Exception starting filter struts2
java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils

hello I solved the above error by including commons-lang3 jar files but somehow eclipse is not deploying HelloWorldStruts2
the new console which i am getting for HelloWorldStruts2 is



[SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:HelloWorldStruts2' did not find a matching property.
Nov 17, 2012 7:29:23 PM org.apache.catalina.core.AprLifecycleListener initializeSSL
INFO: OpenSSL successfully initialized (OpenSSL 1.0.1c 10 May 2012)
Nov 17, 2012 7:29:24 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-apr-8080"]
Nov 17, 2012 7:29:24 PM org.apache.coyote.AbstractProtocol init
SEVERE: Failed to initialize end point associated with ProtocolHandler ["http-apr-8080"]
java.lang.Exception: Socket bind failed: [730048] Only one usage of each socket address (protocol/network address/port) is normally permitted.
at org.apache.tomcat.util.net.AprEndpoint.bind(AprEndpoint.java:433)
at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:610)
at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:429)
at org.apache.catalina.connector.Connector.initInternal(Connector.java:981)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.core.StandardService.initInternal(StandardService.java:559)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:814)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.startup.Catalina.load(Catalina.java:633)
at org.apache.catalina.startup.Catalina.load(Catalina.java:658)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:281)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:450)

Nov 17, 2012 7:29:24 PM org.apache.catalina.core.StandardService initInternal
SEVERE: Failed to initialize connector [Connector[HTTP/1.1-8080]]
org.apache.catalina.LifecycleException: Failed to initialize component [Connector[HTTP/1.1-8080]]
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:106)
at org.apache.catalina.core.StandardService.initInternal(StandardService.java:559)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:814)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.startup.Catalina.load(Catalina.java:633)
at org.apache.catalina.startup.Catalina.load(Catalina.java:658)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:281)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:450)
Caused by: org.apache.catalina.LifecycleException: Protocol handler initialization failed
at org.apache.catalina.connector.Connector.initInternal(Connector.java:983)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
... 12 more
Caused by: java.lang.Exception: Socket bind failed: [730048] Only one usage of each socket address (protocol/network address/port) is normally permitted.
at org.apache.tomcat.util.net.AprEndpoint.bind(AprEndpoint.java:433)
at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:610)
at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:429)
at org.apache.catalina.connector.Connector.initInternal(Connector.java:981)
... 13 more

Nov 17, 2012 7:29:24 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-apr-8009"]
Nov 17, 2012 7:29:24 PM org.apache.coyote.AbstractProtocol init
SEVERE: Failed to initialize end point associated with ProtocolHandler ["ajp-apr-8009"]
java.lang.Exception: Socket bind failed: [730048] Only one usage of each socket address (protocol/network address/port) is normally permitted.
at org.apache.tomcat.util.net.AprEndpoint.bind(AprEndpoint.java:433)
at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:610)
at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:429)
at org.apache.catalina.connector.Connector.initInternal(Connector.java:981)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.core.StandardService.initInternal(StandardService.java:559)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:814)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.startup.Catalina.load(Catalina.java:633)
at org.apache.catalina.startup.Catalina.load(Catalina.java:658)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:281)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:450)

Nov 17, 2012 7:29:24 PM org.apache.catalina.core.StandardService initInternal
SEVERE: Failed to initialize connector [Connector[AJP/1.3-8009]]
org.apache.catalina.LifecycleException: Failed to initialize component [Connector[AJP/1.3-8009]]
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:106)
at org.apache.catalina.core.StandardService.initInternal(StandardService.java:559)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:814)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.startup.Catalina.load(Catalina.java:633)
at org.apache.catalina.startup.Catalina.load(Catalina.java:658)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:281)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:450)
Caused by: org.apache.catalina.LifecycleException: Protocol handler initialization failed
at org.apache.catalina.connector.Connector.initInternal(Connector.java:983)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
... 12 more
Caused by: java.lang.Exception: Socket bind failed: [730048] Only one usage of each socket address (protocol/network address/port) is normally permitted.
at org.apache.tomcat.util.net.AprEndpoint.bind(AprEndpoint.java:433)
at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:610)
at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:429)
at org.apache.catalina.connector.Connector.initInternal(Connector.java:981)
... 13 more

Nov 17, 2012 7:29:24 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1985 ms
Nov 17, 2012 7:29:24 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Nov 17, 2012 7:29:24 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.32
Nov 17, 2012 7:29:25 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Parsing configuration file [struts-default.xml]
Nov 17, 2012 7:29:25 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Unable to locate configuration files of the name struts-plugin.xml, skipping
Nov 17, 2012 7:29:25 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Parsing configuration file [struts-plugin.xml]
Nov 17, 2012 7:29:25 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Parsing configuration file [struts.xml]
Nov 17, 2012 7:29:25 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.ObjectFactory)
Nov 17, 2012 7:29:25 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.FileManager)
Nov 17, 2012 7:29:25 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.impl.XWorkConverter)
Nov 17, 2012 7:29:25 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.TextProvider)
Nov 17, 2012 7:29:25 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.ActionProxyFactory)
Nov 17, 2012 7:29:25 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.conversion.ObjectTypeDeterminer)
Nov 17, 2012 7:29:25 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (org.apache.struts2.dispatcher.mapper.ActionMapper)
Nov 17, 2012 7:29:25 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (jakarta) for (org.apache.struts2.dispatcher.multipart.MultiPartRequest)
Nov 17, 2012 7:29:25 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (org.apache.struts2.views.freemarker.FreemarkerManager)
Nov 17, 2012 7:29:25 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (org.apache.struts2.components.UrlRenderer)
Nov 17, 2012 7:29:25 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.validator.ActionValidatorManager)
Nov 17, 2012 7:29:25 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.util.ValueStackFactory)
Nov 17, 2012 7:29:25 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.util.reflection.ReflectionProvider)
Nov 17, 2012 7:29:25 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.util.reflection.ReflectionContextFactory)
Nov 17, 2012 7:29:25 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.util.PatternMatcher)
Nov 17, 2012 7:29:25 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (org.apache.struts2.dispatcher.StaticContentLoader)
Nov 17, 2012 7:29:25 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (com.opensymphony.xwork2.UnknownHandlerManager)
Nov 17, 2012 7:29:25 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Choosing bean (struts) for (org.apache.struts2.views.util.UrlHelper)
Nov 17, 2012 7:29:25 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Overriding property struts.i18n.reload - old value: false new value: true
Nov 17, 2012 7:29:25 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Overriding property struts.configuration.xml.reload - old value: false new value: true
Nov 17, 2012 7:29:25 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\mytomcat-eclipse-helloworld.war
Nov 17, 2012 7:29:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\docs
Nov 17, 2012 7:29:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\examples
Nov 17, 2012 7:29:26 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Nov 17, 2012 7:29:26 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Nov 17, 2012 7:29:26 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@3585e3f2')
Nov 17, 2012 7:29:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\host-manager
Nov 17, 2012 7:29:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\manager
Nov 17, 2012 7:29:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\ROOT
Nov 17, 2012 7:29:26 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\sample
Nov 17, 2012 7:29:26 PM org.apache.catalina.startup.Catalina start
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

This sounds like another copy of Tomcat is already running - somethign is already using ports 8080 and 8009.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Seeting Ant for deployment to tomcat using eclipse
 
Similar Threads
HTTP Status 404 error in tomcat
Spring webMVC - org.springframework.web.servlet.DispatcherServlet noHandlerFound
Setting up contexts somewhere other than webapps
How to Import a JAVA File in JSP
Stop/Start Tomcat within eclipse