Page 2 of 2 FirstFirst 12
Results 11 to 20 of 20

Thread: Is there any tutorial about Eclipse?

  1. #11
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    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?
    That looks right. Make sure you have the following at the top of your catalina.bat file:

    Code:
    set JPDA_ADDRESS=8000
    set JPDA_TRANSPORT=dt_socket

  2. #12
    Join Date
    Oct 2005
    Posts
    14

    Default

    Code:
    set JPDA_ADDRESS=8000 
    set JPDA_TRANSPORT=dt_socket
    After I add it, I can't start server now.
    I guess maybe the port is used by other applications.
    I use jdk1.5.

  3. #13
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    After I add it, I can't start server now.
    That's strange. What's the error (try 'catalina jpda run')? You should see "Listening for transport dt_socket at address: 8000" at the top.

    I guess maybe the port is used by other applications.I use jdk1.5
    This shouldn't matter :?

  4. #14
    Join Date
    Oct 2005
    Posts
    14

    Default

    my catalina.bat is like below:
    Code:
    set JPDA_ADDRESS=8000 
    set JPDA_TRANSPORT=dt_socket
    @echo off
    if "%OS%" == "Windows_NT" setlocal
    rem ---------------------------------------------------------------------------
    rem Start/Stop Script for the CATALINA Server
    rem
    rem Environment Variable Prequisites
    rem
    rem   CATALINA_HOME   May point at your Catalina "build" directory.
    rem
    rem   CATALINA_BASE   (Optional) Base directory for resolving dynamic portions
    rem                   of a Catalina installation.  If not present, resolves to
    rem                   the same directory that CATALINA_HOME points to.
    rem
    rem   CATALINA_OPTS   (Optional) Java runtime options used when the "start",
    rem                   "stop", or "run" command is executed.
    rem
    rem   CATALINA_TMPDIR (Optional) Directory path location of temporary directory
    rem                   the JVM should use (java.io.tmpdir).  Defaults to
    rem                   %CATALINA_BASE%\temp.
    rem
    rem   JAVA_HOME       Must point at your Java Development Kit installation.
    rem
    rem   JAVA_OPTS       (Optional) Java runtime options used when the "start",
    rem                   "stop", or "run" command is executed.
    rem
    rem   JSSE_HOME       (Optional) May point at your Java Secure Sockets Extension
    rem                   (JSSE) installation, whose JAR files will be added to the
    rem                   system class path used to start Tomcat.
    rem
    rem   JPDA_TRANSPORT  (Optional) JPDA transport used when the "jpda start"
    rem                   command is executed. The default is "dt_shmem".
    rem
    rem   JPDA_ADDRESS    (Optional) Java runtime options used when the "jpda start"
    rem                   command is executed. The default is "jdbconn".
    rem
    rem $Id: catalina.bat,v 1.12 2005/03/03 15:13:39 remm Exp $
    rem ---------------------------------------------------------------------------
    
    rem Guess CATALINA_HOME if not defined
    set CURRENT_DIR=%cd%
    if not "%CATALINA_HOME%" == "" goto gotHome
    set CATALINA_HOME=%CURRENT_DIR%
    if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
    cd ..
    set CATALINA_HOME=%cd%
    cd %CURRENT_DIR%
    :gotHome
    if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
    echo The CATALINA_HOME environment variable is not defined correctly
    echo This environment variable is needed to run this program
    goto end
    :okHome
    
    rem Get standard environment variables
    if exist "%CATALINA_HOME%\bin\setenv.bat" call "%CATALINA_HOME%\bin\setenv.bat"
    
    rem Get standard Java environment variables
    if exist "%CATALINA_HOME%\bin\setclasspath.bat" goto okSetclasspath
    echo Cannot find %CATALINA_HOME%\bin\setclasspath.bat
    echo This file is needed to run this program
    goto end
    :okSetclasspath
    set BASEDIR=%CATALINA_HOME%
    call "%CATALINA_HOME%\bin\setclasspath.bat"
    
    rem Add on extra jar files to CLASSPATH
    if "%JSSE_HOME%" == "" goto noJsse
    set CLASSPATH=%CLASSPATH%;%JSSE_HOME%\lib\jcert.jar;%JSSE_HOME%\lib\jnet.jar;%JSSE_HOME%\lib\jsse.jar
    :noJsse
    set CLASSPATH=%CLASSPATH%;%CATALINA_HOME%\bin\bootstrap.jar
    
    if not "%CATALINA_BASE%" == "" goto gotBase
    set CATALINA_BASE=%CATALINA_HOME%
    :gotBase
    
    if not "%CATALINA_TMPDIR%" == "" goto gotTmpdir
    set CATALINA_TMPDIR=%CATALINA_BASE%\temp
    :gotTmpdir
    
    if not exist "%CATALINA_HOME%\bin\tomcat-juli.jar" goto noJuli
    set JAVA_OPTS=%JAVA_OPTS% -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
    :noJuli
    
    rem ----- Execute The Requested Command ---------------------------------------
    
    echo Using CATALINA_BASE:   %CATALINA_BASE%
    echo Using CATALINA_HOME:   %CATALINA_HOME%
    echo Using CATALINA_TMPDIR: %CATALINA_TMPDIR%
    echo Using JAVA_HOME:       %JAVA_HOME%
    
    set _EXECJAVA=%_RUNJAVA%
    set MAINCLASS=org.apache.catalina.startup.Bootstrap
    set ACTION=start
    set SECURITY_POLICY_FILE=
    set DEBUG_OPTS=
    set JPDA=
    
    if not ""%1"" == ""jpda"" goto noJpda
    set JPDA=jpda
    if not "%JPDA_TRANSPORT%" == "" goto gotJpdaTransport
    set JPDA_TRANSPORT=dt_shmem
    :gotJpdaTransport
    if not "%JPDA_ADDRESS%" == "" goto gotJpdaAddress
    set JPDA_ADDRESS=jdbconn
    :gotJpdaAddress
    shift
    :noJpda
    
    if ""%1"" == ""debug"" goto doDebug
    if ""%1"" == ""run"" goto doRun
    if ""%1"" == ""start"" goto doStart
    if ""%1"" == ""stop"" goto doStop
    if ""%1"" == ""version"" goto doVersion
    
    echo Usage:  catalina ( commands ... )
    echo commands:
    echo   debug             Start Catalina in a debugger
    echo   debug -security   Debug Catalina with a security manager
    echo   jpda start        Start Catalina under JPDA debugger
    echo   run               Start Catalina in the current window
    echo   run -security     Start in the current window with security manager
    echo   start             Start Catalina in a separate window
    echo   start -security   Start in a separate window with security manager
    echo   stop              Stop Catalina
    echo   version           What version of tomcat are you running?
    goto end
    
    :doDebug
    shift
    set _EXECJAVA=%_RUNJDB%
    set DEBUG_OPTS=-sourcepath "%CATALINA_HOME%\..\..\jakarta-tomcat-catalina\catalina\src\share"
    if not ""%1"" == ""-security"" goto execCmd
    shift
    echo Using Security Manager
    set SECURITY_POLICY_FILE=%CATALINA_BASE%\conf\catalina.policy
    goto execCmd
    
    :doRun
    shift
    if not ""%1"" == ""-security"" goto execCmd
    shift
    echo Using Security Manager
    set SECURITY_POLICY_FILE=%CATALINA_BASE%\conf\catalina.policy
    goto execCmd
    
    :doStart
    shift
    if not "%OS%" == "Windows_NT" goto noTitle
    set _EXECJAVA=start "Tomcat" %_RUNJAVA%
    goto gotTitle
    :noTitle
    set _EXECJAVA=start %_RUNJAVA%
    :gotTitle
    if not ""%1"" == ""-security"" goto execCmd
    shift
    echo Using Security Manager
    set SECURITY_POLICY_FILE=%CATALINA_BASE%\conf\catalina.policy
    goto execCmd
    
    :doStop
    shift
    set ACTION=stop
    goto execCmd
    
    :doVersion
    %_EXECJAVA% -classpath "%CATALINA_HOME%\server\lib\catalina.jar" org.apache.catalina.util.ServerInfo
    goto end
    
    
    :execCmd
    rem Get remaining unshifted command line arguments and save them in the
    set CMD_LINE_ARGS=
    :setArgs
    if ""%1""=="""" goto doneSetArgs
    set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
    shift
    goto setArgs
    :doneSetArgs
    
    rem Execute Java with the applicable properties
    if not "%JPDA%" == "" goto doJpda
    if not "%SECURITY_POLICY_FILE%" == "" goto doSecurity
    %_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION%
    goto end
    :doSecurity
    %_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Djava.security.manager -Djava.security.policy=="%SECURITY_POLICY_FILE%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION%
    goto end
    :doJpda
    if not "%SECURITY_POLICY_FILE%" == "" goto doSecurityJpda
    %_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% -Xdebug -Xrunjdwp:transport=%JPDA_TRANSPORT%,address=%JPDA_ADDRESS%,server=y,suspend=n %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION%
    goto end
    :doSecurityJpda
    %_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% -Xdebug -Xrunjdwp:transport=%JPDA_TRANSPORT%,address=%JPDA_ADDRESS%,server=y,suspend=n %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Djava.security.manager -Djava.security.policy=="%SECURITY_POLICY_FILE%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION%
    goto end
    
    :end
    After command "catalina jpda start", I could see Tomcat window for few second. But without any output text or error info, the window close automatically.
    I don't know why.

  5. #15
    Join Date
    Oct 2005
    Posts
    14

    Default

    Moment ago, I try this command "catalina jpda run", I got the err below:

    Code:
    ERROR: transport error 202: connect failed: Connection refused ["transport.c",L4
    1]
    ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510) ["debu
    gInit.c",L497]
    JDWP exit error JVMTI_ERROR_INTERNAL(113): No transports initializedFATAL ERROR
    in native method: JDWP No transports initialized, jvmtiError=JVMTI_ERROR_INTERNA
    L(113)

  6. #16
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    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).

  7. #17
    Join Date
    Oct 2005
    Posts
    14

    Default

    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!

  8. #18
    Join Date
    Jul 2006
    Posts
    2

    Default 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>

  9. #19
    Join Date
    Jul 2006
    Posts
    2

    Default 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

  10. #20

    Default

    Quote 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.

Similar Threads

  1. Replies: 7
    Last Post: Jun 1st, 2006, 12:27 PM
  2. Replies: 0
    Last Post: Jun 21st, 2005, 06:16 PM
  3. eclipse 3.0.2 Spring IDE Problems
    By mkimber1 in forum SpringSource Tool Suite
    Replies: 5
    Last Post: Apr 21st, 2005, 11:01 AM
  4. Eclipse 3.0 compiler settings for Spring build?
    By jbetancourt in forum Architecture
    Replies: 4
    Last Post: Oct 5th, 2004, 03:41 PM
  5. Replies: 5
    Last Post: Sep 14th, 2004, 03:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •