Skip to content

Instantly share code, notes, and snippets.

@TerryTsao
Last active June 22, 2017 05:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TerryTsao/4c376662e6b124f9373269b76dc563fb to your computer and use it in GitHub Desktop.
Save TerryTsao/4c376662e6b124f9373269b76dc563fb to your computer and use it in GitHub Desktop.
Note on spring.io Spring tutorial
This is my note when walking thru this tutorial "Developing a Spring Framework MVC application step-by-step". This records my updates to make things work.

Chapter 1. Basic Application and Environment Setup


$ ant

BUILD FAILED c:\dev\springapp\build.xml:85: taskdef class org.apache.catalina.ant.InstallTask cannot be found using the classloader AntClassLoader[C:\dev\apache-tomcat-7.0.5\lib\catalina-ant.jar]

  • Since tomcat 7, there has been a change and requires more jars. Add more jars according to this StackOverflow
  • InstallTask fail. This is due to class InstallTask is deprecated by DeployTask according to this forum. (See also Tomcat API Doc) Just change the class name will do.

Solution: make changes to springapp/build.xml

$ diff todel build.xml 
81a82,86
>             <include name="tomcat-coyote.jar"/>
>             <include name="tomcat-util.jar"/>
>         </fileset>
>         <fileset dir="${appserver.home}/bin">
>             <include name="tomcat-juli.jar"/>
85c90
<     <taskdef name="install" classname="org.apache.catalina.ant.InstallTask">
---
>     <taskdef name="install" classname="org.apache.catalina.ant.DeployTask">

$ ant -v list

 BUILD FAILED
 /home/terrytsao/workspace/springapp/build.xml:138: java.io.FileNotFoundException: http://localhost:8080/manager/list
 	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1872)
 	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
 	at org.apache.catalina.ant.AbstractCatalinaTask.execute(AbstractCatalinaTask.java:233)
 	at org.apache.catalina.ant.AbstractCatalinaTask.execute(AbstractCatalinaTask.java:155)
 	at org.apache.catalina.ant.ListTask.execute(ListTask.java:50)
 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 	at java.lang.reflect.Method.invoke(Method.java:498)
 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
 	at org.apache.tools.ant.Task.perform(Task.java:348)
 	at org.apache.tools.ant.Target.execute(Target.java:435)
 	at org.apache.tools.ant.Target.performTasks(Target.java:456)
 	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
 	at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
 	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
 	at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
 	at org.apache.tools.ant.Main.runBuild(Main.java:853)
 	at org.apache.tools.ant.Main.startAnt(Main.java:235)
 	at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)
 	at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
 
 Total time: 0 seconds
 
  • Solution: in file 'springapp/build.properties', do this.
$ diff todel build.properties
 < tomcat.manager.url=http://localhost:8080/manager
 ---
 > tomcat.manager.url=http://localhost:8080/manager/text

Also, you would need to add "manager-scrpit" role in "$CATALINA_HOME/conf/tomcat-users.xml" as well. (See tomcat documentaion)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment