Announcement Announcement Module
Collapse
No announcement yet.
java.net.ConnectException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • java.net.ConnectException

    Hi,

    I am following the below link for developing sample spring application.

    springframework.org/docs/Spring-MVC-step-by-step/part1.html#step1.2

    I run the "build.xml" file by Ant Build. It displays the following in the console..

    Buildfile: D:\Ramesh\WorkSpace\springapp\build.xml
    usage:
    [echo] springapp build file
    [echo] -----------------------------------
    [echo] Available targets are:
    [echo] build --> Build the application
    [echo] deploy --> Deploy application as directory
    [echo] deploywar --> Deploy application as a WAR file
    [echo] install --> Install application in Tomcat
    [echo] reload --> Reload application in Tomcat
    [echo] start --> Start Tomcat application
    [echo] stop --> Stop Tomcat application
    [echo] list --> List Tomcat applications
    build:
    build:
    deploy:
    build:
    deploywar:
    reload:

    BUILD FAILED
    D:\Ramesh\WorkSpace\springapp\build.xml:113: java.net.ConnectException: Connection refused: connect

    Total time: 2 seconds

    Any one give me the solution.....

  • #2
    Originally posted by ram2206 View Post
    Hi,

    I am following the below link for developing sample spring application.

    springframework.org/docs/Spring-MVC-step-by-step/part1.html#step1.2

    I run the "build.xml" file by Ant Build. It displays the following in the console..

    Buildfile: D:\Ramesh\WorkSpace\springapp\build.xml
    usage:
    [echo] springapp build file
    [echo] -----------------------------------
    [echo] Available targets are:
    [echo] build --> Build the application
    [echo] deploy --> Deploy application as directory
    [echo] deploywar --> Deploy application as a WAR file
    [echo] install --> Install application in Tomcat
    [echo] reload --> Reload application in Tomcat
    [echo] start --> Start Tomcat application
    [echo] stop --> Stop Tomcat application
    [echo] list --> List Tomcat applications
    build:
    build:
    deploy:
    build:
    deploywar:
    reload:

    BUILD FAILED
    D:\Ramesh\WorkSpace\springapp\build.xml:113: java.net.ConnectException: Connection refused: connect

    Total time: 2 seconds

    Any one give me the solution.....
    check build.properties file
    It seems like your settings are incorrect. Most likely this is something to do with your web server. Check your configuration

    Comment


    • #3
      Originally posted by anurudda_spring View Post
      check build.properties file
      It seems like your settings are incorrect. Most likely this is something to do with your web server. Check your configuration
      Thank you for your reply...

      The build.properties file contains the following contents..

      appserver.home=D:/apache-tomcat-6.0.18
      appserver.lib=${appserver.home}/lib
      deploy.path=${appserver.home}/webapps

      tomcat.manager.url=localhost:8080/manager #url with protocol
      tomcat.manager.username=tomcat
      tomcat.manager.password=s3cret
      -----------

      Is there any more configuration file required?

      Still I'm having the same problem...

      Comment


      • #4
        Originally posted by ram2206 View Post
        Thank you for your reply...

        The build.properties file contains the following contents..

        appserver.home=D:/apache-tomcat-6.0.18
        appserver.lib=${appserver.home}/lib
        deploy.path=${appserver.home}/webapps

        tomcat.manager.url=localhost:8080/manager #url with protocol
        tomcat.manager.username=tomcat
        tomcat.manager.password=s3cret
        -----------

        Is there any more configuration file required?

        Still I'm having the same problem...
        Are you sure your tomcat manager username and passwords are correct?
        check inside D:/apache-tomcat-6.0.18/conf/tomcat-users.xml

        Comment


        • #5
          Thank you for your quick reply...
          Yes, I am sure...

          D:\apache-tomcat-6.0.18\conf\tomcat-users.xml contains the following...

          <?xml version='1.0' encoding='utf-8'?>
          <tomcat-users>
          <role rolename="manager"/>
          <user username="tomcat" password="s3cret" roles="manager"/>

          </tomcat-users>

          Comment


          • #6
            Still I'm having the same problem...

            Comment


            • #7
              Originally posted by ram2206 View Post
              Thank you for your quick reply...
              Yes, I am sure...

              D:\apache-tomcat-6.0.18\conf\tomcat-users.xml contains the following...

              <?xml version='1.0' encoding='utf-8'?>
              <tomcat-users>
              <role rolename="manager"/>
              <user username="tomcat" password="s3cret" roles="manager"/>

              </tomcat-users>
              Can u show us the build.xml file?

              Comment


              • #8
                <?xml version="1.0"?>

                <project name="springapp" basedir="." default="usage">
                <property file="build.properties"/>

                <property name="src.dir" value="src"/>
                <property name="web.dir" value="war"/>
                <property name="build.dir" value="${web.dir}/WEB-INF/classes"/>
                <property name="name" value="springapp"/>

                <path id="master-classpath">
                <fileset dir="${web.dir}/WEB-INF/lib">
                <include name="*.jar"/>
                </fileset>
                <!-- We need the servlet API classes: -->
                <!-- * for Tomcat 5/6 use servlet-api.jar -->
                <!-- * for other app servers - check the docs -->
                <fileset dir="${appserver.lib}">
                <include name="servlet*.jar"/>
                </fileset>
                <pathelement path="${build.dir}"/>
                </path>

                <target name="usage">
                <echo message=""/>
                <echo message="${name} build file"/>
                <echo message="-----------------------------------"/>
                <echo message=""/>
                <echo message="Available targets are:"/>
                <echo message=""/>
                <echo message="build --> Build the application"/>
                <echo message="deploy --> Deploy application as directory"/>
                <echo message="deploywar --> Deploy application as a WAR file"/>
                <echo message="install --> Install application in Tomcat"/>
                <echo message="reload --> Reload application in Tomcat"/>
                <echo message="start --> Start Tomcat application"/>
                <echo message="stop --> Stop Tomcat application"/>
                <echo message="list --> List Tomcat applications"/>
                <echo message=""/>
                </target>

                <target name="build" description="Compile main source tree java files">
                <mkdir dir="${build.dir}"/>
                <javac destdir="${build.dir}" source="1.5" target="1.5" debug="true"
                deprecation="false" optimize="false" failonerror="true">
                <src path="${src.dir}"/>
                <classpath refid="master-classpath"/>
                </javac>
                </target>

                <target name="deploy" depends="build" description="Deploy application">
                <copy todir="${deploy.path}/${name}" preservelastmodified="true">
                <fileset dir="${web.dir}">
                <include name="**/*.*"/>
                </fileset>
                </copy>
                </target>

                <target name="deploywar" depends="build" description="Deploy application as a WAR file">
                <war destfile="${name}.war"
                webxml="${web.dir}/WEB-INF/web.xml">
                <fileset dir="${web.dir}">
                <include name="**/*.*"/>
                </fileset>
                </war>
                <copy todir="${deploy.path}" preservelastmodified="true">
                <fileset dir=".">
                <include name="*.war"/>
                </fileset>
                </copy>
                </target>

                <!-- ================================================== ============ -->
                <!-- Tomcat tasks - remove these if you don't have Tomcat installed -->
                <!-- ================================================== ============ -->

                <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="install" classname="org.apache.catalina.ant.InstallTask">
                <classpath refid="catalina-ant-classpath"/>
                </taskdef>
                <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask">
                <classpath refid="catalina-ant-classpath"/>
                </taskdef>
                <taskdef name="list" classname="org.apache.catalina.ant.ListTask">
                <classpath refid="catalina-ant-classpath"/>
                </taskdef>
                <taskdef name="start" classname="org.apache.catalina.ant.StartTask">
                <classpath refid="catalina-ant-classpath"/>
                </taskdef>
                <taskdef name="stop" classname="org.apache.catalina.ant.StopTask">
                <classpath refid="catalina-ant-classpath"/>
                </taskdef>

                <target name="install" description="Install application in Tomcat">
                <install url="${tomcat.manager.url}"
                username="${tomcat.manager.username}"
                password="${tomcat.manager.password}"
                path="/${name}"
                war="${name}"/>
                </target>

                <target name="reload" description="Reload application in Tomcat">
                <reload url="${tomcat.manager.url}"
                username="${tomcat.manager.username}"
                password="${tomcat.manager.password}"
                path="/${name}"/>
                </target>

                <target name="start" description="Start Tomcat application">
                <start url="${tomcat.manager.url}"
                username="${tomcat.manager.username}"
                password="${tomcat.manager.password}"
                path="/${name}"/>
                </target>

                <target name="stop" description="Stop Tomcat application">
                <stop url="${tomcat.manager.url}"
                username="${tomcat.manager.username}"
                password="${tomcat.manager.password}"
                path="/${name}"/>
                </target>

                <target name="list" description="List Tomcat applications">
                <list url="${tomcat.manager.url}"
                username="${tomcat.manager.username}"
                password="${tomcat.manager.password}"/>
                </target>

                <!-- End Tomcat tasks -->

                </project>

                Comment


                • #9
                  I couldn't find out the problem.....

                  I run the build.xml file. It gves the following.....

                  Buildfile: D:\Ramesh\WorkSpace\springapp\build.xml
                  usage:
                  [echo] springapp build file
                  [echo] -----------------------------------
                  [echo] Available targets are:
                  [echo] build --> Build the application
                  [echo] deploy --> Deploy application as directory
                  [echo] deploywar --> Deploy application as a WAR file
                  [echo] install --> Install application in Tomcat
                  [echo] reload --> Reload application in Tomcat
                  [echo] start --> Start Tomcat application
                  [echo] stop --> Stop Tomcat application
                  [echo] list --> List Tomcat applications
                  build:
                  build:
                  deploy:
                  build:
                  deploywar:
                  reload:

                  BUILD FAILED
                  D:\Ramesh\WorkSpace\springapp\build.xml:113: java.net.ConnectException: Connection refused: connect

                  Total time: 8 seconds
                  --------------
                  Please give me the solution.....

                  Comment


                  • #10
                    There is an error in your build.properties file

                    change ur tomcat manager url to include the protocol like

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


                    Currently you have not mentioned the protocol

                    Comment


                    • #11
                      The build.properties file contains the following contents..

                      appserver.home=D:/apache-tomcat-6.0.18
                      appserver.lib=${appserver.home}/lib
                      deploy.path=${appserver.home}/webapps

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

                      Still i'm having the same problem...

                      Comment


                      • #12
                        I have same problem, please help!

                        Comment


                        • #13
                          I have come across these sort of errors earlier... either they have to do with wrong configurations or tomcat not being started....
                          Just check whether configuration correct and tomcat is started!

                          Comment


                          • #14
                            tomcat is not started... Can u give me solution...

                            Comment


                            • #15
                              Originally posted by ram2206 View Post
                              tomcat is not started... Can u give me solution...
                              If you are using windows....... start -> program files -> Apache Tomcat 6 -> Monitor tomcat
                              Then you will see the apache tomcat icon in the system tray... right click on it and select start...

                              If you are using linux... execute startup.sh file in tomcat/bin directory..
                              e.g. /usr/local/tomcat/bin/startup.sh

                              Comment

                              Working...
                              X