Announcement Announcement Module
Collapse
No announcement yet.
Is there any tutorial about Eclipse? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    I got the err below
    You might be better off googling for an answer - I have never got that. Your catalina.bat file looks OK. You could try connecting via a different port (e.g. 8888).

    Comment


    • #17
      After changing the port, it still can not run. I got the same error.
      Maybe the system configuration is not right, or maybe something else, I don't know.
      I plan to do the same work in Linux. I hope it can run correctly.
      Thank you!

      Comment


      • #18
        SpringIDE tutorial example

        Preliminary comments:

        This contribution comes from a teacher, not a professional developer. His main motivation is to develop expertise to share with undergraduate Computer Science students. Although an experienced Java programmer, he is a relatively naive user of Eclipse and Ant and an absolute novice at Spring and SpringIDE.

        The discussion below involves implementing the example Spring-Chap1-lab4 from the book, Spring Developers Notebook, in Eclipse with Spring and SpringIDE (link provided below). This is the first sample program from that book that really exercises the capabilities for dependency injection with Spring beans.

        Most of the individual steps listed below reflect an embarrassing number of hours/days of trial and error experimentation. It's not at all clear that the advantages of Eclipse justify the effort described below since one could simply run the Ant build file (with minor changes for installation peculiarities) directly without using Eclipse. Many developers apparently use Eclipse (or another IDE) only to organize and edit the files of the Spring project, but not to build or execute them. Eclipse file update and file visibility are (to put it kindly) unpredictable. What seems to work one time fails the next and vice-versa.

        SpringIDE Tutorial Example:

        1. Install Eclipse 3.2.1 or higher (3.1 versions will probably also work).

        2. Download Spring.

        3. Download and install the spring IDE using the Eclipse updater. For sophisticated Spring usage, the SpringIDE installer instructions suggest installing GEF (easy)_and WST(a royal pain). This effort gave up on the latter, hoping that the update programs will improve later when the advanced features are needed.

        4. Download the example folder.

        5. Selecting Eclipse:File:New Project: Spring IDE project, navigate to the folder that holds Spring-Chap1-lab4, and type in the identical project name, Spring-Chap1-lab4 before clicking Finish. Eclipse creates a Spring project matching (approximately) the existing folder structure.

        6. (Add build libraries) Right-click the project in the Eclipse navigator window on the left and select Properties:Java Build Path:Libraries:Add External Jars to add the jar files for Spring, Jakarta commons, log4j, j2ee (use servlet-api.jar instead of servlet.jar), and Junit that the Ant build file, build.xml, specifies. You must examine the build file to determine what jars to add and you must add them from the folder that contains your Spring implementation files.

        7. Repair the Ant build file to properly identify the proper Spring jar files just added to the build path (the versions of the jar files will probably differ from those listed in the build file).

        8. The config file, Spring-Chap1-Lab4/war/WEB-INF/ RentABike-context.xml, has an error: change the property tag (and its matching close tag) for the first bean to a constructor-arg tag instead of a property tag and remove the name designator.

        9. Copy (don't move) the config file, Spring-Chap1-Lab4/war/WEB-INF/ RentABike-context.xml, from the war directory to the src folder for the project.

        10. Things that the pure Ant build does automatically, but that one must patch to keep the Eclipse/Ant combination happy.
        * Select Eclipse:Window:General:Workspace:Linked Resources:New, type TestClasses as the Name, and click Folder to navigate to and select .../Spring-Chap1-Lab4/test/classes as the location for an Eclipse variable.
        i. This creates a virtual folder called TestClasses immediately inside of folder Spring-Chap1-Lab4. The actual folder, .../Spring-Chap1-Lab4/test/classes, matches the output folder used by the Ant build
        ii. You will eventually use this virtual folder to specify the output location of classes compiled from folder test. The virtual folder is necessary since Eclipse requires that class output folders reside at the top level of the project.
        * There is a problem with the src and test folders since Eclipse currently views them as packages instead of folders and also since Eclipse will currently place all compiled class files in the main project folder. Right-click the project in the navigator and select Properties:Source:
        i. Click a check beside Allow output Folders for source Folders.
        ii. Select Add Folder to add Spring-Chap1-Lab4/src. Answer Yes to removing the project folder as a source folder. Otherwise, you will find a number of redundant files cluttering your output folders.
        iii. Remaining in Properties:Source, click Browse beside the Default Output Folder text box and navigate to select Spring-Chap1-Lab4/war/WEB-INF/classes as the project's default location to write compiled class files. Click Yes to the prompt that follows.
        iv. Select Add Folder to add Spring-Chap1-Lab4/test in the same way you added Spring-Chap1-Lab4/src.
        v. Double-click the Output folder icon (if there isn't one, you skipped step i.) for the newly created source item from the previous step, click the Specific Output folder... button, and type TestClasses in the textbox. This will tell Eclipse to send the compiled classes into .../test/classes as accomplished by the Ant file.
        vi. Click OK to save your properties changes.
        * Right-click the project in the navigator and select Properties:Spring Beans:Add to add Spring-Chap1-Lab4/war/WEB-INF/ RentABike-context.xml,as a beans creator file and then to add Spring-Chap1-Lab4/src/ RentABike-context.xml. It's not clear that both are necessary, but the build works as recommended here and is unpredictable otherwise.
        11. To perform a basic run of the program,
        * right-click on the build file in the navigator, select Runs as:External Tools...:Targets, check only the compile target and then Run.
        * Select Eclipse:Run:Run...:Run to execute the program. Despite warnings about unimplemented log capabilities, the program should execute.
        12. To run the tests through the Eclipse Ant processor:
        * Adding Junit.jar to the libraries in the above step labelled (Add build libraries) was apparently a waste of time since the Eclipse/Ant build doesn't find it. Junit is an optional Ant task, and thus, not automatically available to Eclipse/Ant. One solution is to use Eclipse:Window:Preferences:Ant:Runtime:Global Entries:Add External Jars... to add a reference to a version of Junit.jar either from Spring as in the above step labelled (Add build libraries) or from the Ant-home at [ECLIPSE_DIR]/plugins/... . Here, the former was used to maintain compatibility with the build file, but it might be generally better to use the copy of Junit.jar in Ant-home so that the problem will be solved for all Eclipse/Ant/Junit builds, even if the Spring files are moved.
        * Right-click on the build file in the navigator, select Runs as:External Tools...:Targets, check the test target only and then Run.
        13. The successful build file used in this example (the Spring implementation was located at ../../spring-framework-2.0-m5 relative to the project folder):

        <?xml version="1.0"?>
        <project name="RentABike" default="compile" basedir=".">

        <property name="src.dir" value="src"/>
        <property name="test.dir" value="test"/>
        <property name="war.dir" value="war"/>
        <property name="class.dir" value="${war.dir}/WEB-INF/classes"/>
        <property name="test.class.dir" value="${test.dir}/classes"/>
        <property name="spring.dir" value="../../spring-framework-2.0-m5"/>
        <path id="bikestore.class.path">
        <fileset dir="${spring.dir}/dist">
        <include name="*.jar" />
        </fileset>

        <pathelement location="${spring.dir}/lib/jakarta-commons/commons-logging.jar" />
        <pathelement location="${spring.dir}/lib/log4j/log4j-1.2.13.jar" />
        <pathelement location="${spring.dir}/lib/j2ee/servlet-api.jar" />
        <dirset dir="${basedir}"/>
        </path>

        <path id="run.class.path">
        <path refid="bikestore.class.path"/>
        <dirset dir="${class.dir}"/>
        </path>

        <path id="junit.class.path">
        <path refid="run.class.path" />
        <pathelement location="${spring.dir}/lib/junit/junit.jar" />
        </path>

        <target name="init">
        <mkdir dir="${class.dir}"/>
        <mkdir dir="${test.class.dir}"/>
        </target>

        <target name="compile" depends="init"
        description="Compiles all source code.">
        <javac srcdir="${src.dir}" destdir="${class.dir}"
        classpathref="bikestore.class.path"/>
        </target>

        <target name="clean" description="Erases contents of classes dir">
        <delete dir="${class.dir}"/>
        <delete dir="${test.class.dir}"/>
        </target>

        <target name="compile.test" depends="init" description="Compiles all unit test source">
        <javac srcdir="${test.dir}"
        destdir="${test.class.dir}"
        classpathref="junit.class.path"/>
        </target>

        <target name="test" depends="compile, compile.test"
        description="Runs the unit tests">
        <junit printsummary="withOutAndErr" haltonfailure="no"
        haltonerror="no" fork="yes">
        <classpath refid="junit.class.path"/>
        <formatter type="xml" usefile="true" />
        <batchtest todir="${test.dir}">
        <fileset dir="${test.class.dir}">
        <include name="*Test.*"/>
        </fileset>
        </batchtest>
        </junit>
        </target>

        </project>

        14. The config file used in this example:

        <?xml version="1.0"?>
        <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

        <beans>
        <bean id="rentaBike" class="com.springbook.ArrayListRentABike">
        <constructor-arg><value>Bruce's Bikes</value></constructor-arg>
        </bean>

        <bean id="commandLineView" class="com.springbook.CommandLineView">
        <property name="rentaBike"><ref bean="rentaBike"/></property>
        </bean>

        </beans>

        Comment


        • #19
          link to example files from previous post

          My previous reply failed to include a specification of the source and a link to the zip file for the springide tutorial example:

          Spring: A Developers Notebook, Oreilly Publishing, ISBN:0-596-00910-0, Justin Gethland and Bruce Tate,

          http://examples.oreilly.com/springad...evNotebook.zip

          Comment


          • #20
            Originally posted by yunkun_yang
            I have another two questions.
            First, when I build a war file and copy it to CATALINA_HOME/webapps, I must restart tomcat to see the modification?

            Second, when I try to debug app in eclipse, but I get a err: Can't get connect remote server. I don't know why. I use tomcat , debug port 8000. start server using command: catalina jpda start. Is that right?

            If you are using Eclipse 3.2 and do a proper download of just 9 packages from Callisto, I think they are J2EE and JAva development tools, thats it, then you get a wizard that enables you to create a dynamic web project. With that you can choose what the final server you are going to deploy to and you can select Tomcat 5.5 in there. That way you can have Eclipse auto-deploy your project for you.

            Comment

            Working...
            X