aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark ""ant list" connection refused exception" Watch ""ant list" connection refused exception" New topic
Author

"ant list" connection refused exception

Mike Kerry
Greenhorn

Joined: Mar 09, 2011
Posts: 2
I'm going through the step by step Spring MVC introduction tutorial at
http://www.springframework.org/docs/MVC-step-by-step/Spring-MVC-step-by-step-Part-1.html

I am able to build and deploy the application successfully but when I attempt to list the running applications I get the following exception

C:\JavaProjects\springapp>ant list
Buildfile: C:\JavaProjects\springapp\build.xml

list:

BUILD FAILED
C:\JavaProjects\springapp\build.xml:123: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.connect(Socket.java:478)....

I have seen other topics similar to this on this forum but none have been able to resolve my issue. Some of the other threads include
http://www.coderanch.com/t/108375/tools/Failed-build-InstallTask-cannot-found
http://www.coderanch.com/t/428039/tools/Occuring-during-interacting-Tomcat-server
http://www.coderanch.com/t/109089/tools/ant-list-error

and on other forums
http://forum.springsource.org/showthread.php?t=25882&highlight=connection+refused
http://forum.springsource.org/showthread.php?t=19767&highlight=connection+refused

On researching this issue, I found that a possible issue is to do with Tomcat Manager not running properly. However, I've verified that it is running i.e.
"http://localhost:8080/manager/html" takes me to the tomcat manager webpage and from there I can check e.g. server status and list applications

I can list the applications using:
"http://localhost:8080/manager/list" lists my running applications
OK - Listed applications for virtual host localhost
/springapp:running:0:springapp
/:running:0:ROOT
/manager:running:0:C:/apache-tomcat-5.5.31/server/webapps/manager
/webdav:running:0:webdav
/servlets-examples:running:0:servlets-examples
/tomcat-docs:running:0:tomcat-docs
/host-manager:running:0:C:/apache-tomcat-5.5.31/server/webapps/host-manager
/jsp-examples:running:0:jsp-examples
/balancer:running:0:balancer

My tomcat-users.xml file is:
<tomcat-users>
<role rolename="manager"/>
<role rolename="tomcat"/>
<role rolename="admin"/>
<role rolename="role1"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="tomcat" password="tomcat" roles="admin,manager"/>
<user username="springtomcat" password="s3cret" roles="admin,manager"/>
<user username="role1" password="tomcat" roles="role1"/>
</tomcat-users>

The relevant sections in the build.xml are:
<path id="catalina-ant-classpath">
<!-- We need the Catalina jars for Tomcat -->
<!-- * for other app servers - check the docs -->
<fileset dir="${appserver.lib}">
<include name="catalina-ant.jar" />
</fileset>
</path>
<taskdef name="list" classname="org.apache.catalina.ant.ListTask">
<classpath refid="catalina-ant-classpath" />
</taskdef>
<target name="list" description="List Tomcat applications">
<list url="${tomcat.manager.url}" username="${tomcat.manager.username}"
password="${tomcat.manager.password}" />
</target>

and the build.properties file is:
appserver.home=C:/apache-tomcat-5.5.31
# for Tomcat 5 use $appserver.home}/server/lib
# for Tomcat 6 use $appserver.home}/lib
appserver.lib=${appserver.home}/server/lib

deploy.path=${appserver.home}/webapps

tomcat.manager.url=http://localhost:8080/manager
tomcat.manager.username=tomcat
tomcat.manager.password=tomcat

As far as I can see, everything is configured correctly but I'm new to this so maybe you guys might see something. The only thing that I can think that may be the issue is that I'm behind a firewall, but I added the following lines to the 'catalina.properties' file and I'm still seeing the same problem.
http.proxyHost=servername
http.proxyPort=8080
http.proxyUser=myusername
http.proxyPassword=mypassword

Does it matter that the proxy port is the same as the port that Tomcat is running on?

Any help would be greatly appreciated. Tearing my hair out here!

Cheers
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5779
    
    7

Mike, welcome to Java Ranch!

Your post would be a lot easier to read, and thus more likely to generate responses, if you would use the 'code' tag for posting file contents.


JBoss In Action
Mike Kerry
Greenhorn

Joined: Mar 09, 2011
Posts: 2
Thanks for the reply Peter, I'll make sure to do that in future. Although I didn't find a solution to my problem, I used a workaround. Some people who run into the same problem might find this useful.
I downloaded a preconfigured tomcat env from coreservlets, here
http://www.coreservlets.com/Apache-Tomcat-Tutorial/tomcat-7-with-eclipse.html

The manager interface has changed slightly in Tomcat 7 (I was previously using 5.5) so my tomcat-users.xml now looks like:


manager-script allows access to the text interface and the status pages.

I also had to make a few small changes to my build.properties file:


It worked after those changes.

Cheers
 
Consider Paul's rocket mass heater.
 
subject: "ant list" connection refused exception
 
Similar Threads
changed the config file but still not working
forget the tomcat credentials
Springapp Tutorial FileNotFoundException at Step 1.11, running ant deploy reload
Tomcat 7.0 Manager's Username and Password
Unable to access Tomcat Manager Application(http://localhost:8080/manager