13 Replies Latest reply on May 14, 2003 11:33 AM by yoyodyne

    problem with struts

    substring

      Hello All,

      I am trying to do my very first HelloWorld in EJB, using a tutorial I downloaded from the Net. In one of the .java file, there are import statements as followed:
      import org.apache.struts.action.*;
      import org.apache.struts.util.*;

      When I compile with "ant all", I get the error message:
      package org.apache.struts.action does not exist

      I have installed the followings:
      JDK 1.3.1
      J2EE 1.3.1
      JBoss-3.2.1_tomcat-4.1.24 bundle
      struts 1.0.2

      My questions are:

      1. What files and to where should I copy from the downloaded struts? The installation document I got from the Apache web site did not help because it does not include JBoss on their container list.

      2. I am confused over the org.apache.struts.action.* format. With my limited knowledge on Java, whenever I create a new class library myself, I will "package" it like com.mypackage.whatever. Then I will create the folder structure under WEB-INF/classes to mimic that scheme, and then store the class files in that location for the import statement to find them. Am I correct? Now, am I suppose to have to "package" anything and create the corresponding folder structure for the import statement to work??? Since the import statement is explicitly pointing to org.apache.struts.action.* ? Where is this folder path? And what files in the struts download that I have to package???

      Any help will be very much appreciated.

        • 1. Re: problem with struts
          yoyodyne

          put struts.jar under WEB-INF/lib

          • 2. Re: problem with struts
            substring

            Thanks for the reply.

            However, I have already done that. As a matter of fact, I have:
            1. Copy the lib/struts.jar to WEB-INF/lib
            2. Copy lib/struts-*.tld to WEB-INF
            3. Check and verify the WEB-INF/web.xml is including the element and the <servlet mapping> element. (the web.xml file is included in the tutorial).
            4. Then stop and restart JBoss.

            Still get same error message when I do "ant all". By the way, I do not have any problem when running JSP program in JBoss. So I know my JBoss installation is fine.

            By the way, does copying the struts.jar file will take care of my question #2 in my original post?

            Please help. Thank you very much.

            • 3. Re: problem with struts
              yoyodyne

              <<Still get same error message when I do "ant all". >>
              u will need to check what the ant "all" target does. "all" may be depending on some compile target and this target is probably unable to find struts.jar. so u will have to edit build.xml to add the struts.jar location to the compilation classpath.

              <<By the way, does copying the struts.jar file will take care of my question #2 in my original post?>>
              it shud.

              • 4. Re: problem with struts
                substring

                Yes, I have already checked that. In the build.xml file, there is a line as stated below:


                and I have added a system variable called STRUTS_HOME to point to the folder path where I store the struts program.

                Also, when I restart JBoss, I saw JBoss was calling and registering struts. The messages in the console scrolled up too fast for me to read it. But I found the following scripts:
                //scripts begin--------------------------------------------
                16:34:23,015 INFO [STDOUT] New org.apache.struts.action.ActionForward
                16:34:23,015 INFO [STDOUT] Set org.apache.struts.action.ActionForward propertie
                s
                16:34:23,031 INFO [STDOUT] Call org.apache.struts.action.ActionMapping.addForwa
                rd(ActionForward[display])
                16:34:23,031 INFO [STDOUT] Pop org.apache.struts.action.ActionForward
                16:34:23,046 INFO [STDOUT] Call org.apache.struts.action.ActionServlet.addMappi
                ng(ActionMapping[path=/upload, type=org.apache.struts.webapp.upload.UploadAction
                ])
                16:34:23,046 INFO [STDOUT] Pop org.apache.struts.action.ActionMapping
                16:34:23,046 INFO [STDOUT] register('-//Apache Software Foundation//DTD Struts
                Configuration 1.0//EN', 'jar:file:/C:/jboss-3.2.1_tomcat-4.1.24/server/default/t
                mp/deploy/server/default/deploy/work/MainEngine/localhost/struts-upload/WEB-INF/
                lib/struts.jar!/org/apache/struts/resources/struts-config_1_0.dtd'
                //scripts end--------------------------------------------

                So if the startup program can "see" org.apache.struts.action.*, why can't my import statement? I don't understand why I keep getting the error message of:
                package org.apache.struts.action does not exist

                Thank you very much.

                • 5. Re: problem with struts
                  substring

                  Oops, typo. The line in build.xml should be:


                  Thanks.

                  • 6. Re: problem with struts
                    substring

                    Well, I guess the dollar sign do not show up here. Let me try again with word instead of the symbol. So replace the word with the corresponding symbol will get the actual code.

                    • 7. Re: problem with struts
                      yoyodyne

                      ok, can u post what u see on the console when u do 'ant all'. Also can u attach the build.xml.

                      • 8. Re: problem with struts
                        yoyodyne

                        <<So if the startup program can "see" org.apache.struts.action.*, why can't my import statement? I don't understand why I keep getting the error message of:
                        package org.apache.struts.action does not exist
                        >>
                        cuz they get their paths from different places.

                        • 9. Re: problem with struts
                          substring

                          Hmmm, so am I correct that the following is the line of code where the program "knows" the location of the file:


                          and since I have already created the system variable of STRUTS_HOME to point to the program location, say, C:\struts , shouldn't the <dollar sign>{env.STRUTS_HOME} be translated to C:\struts ?

                          I have attached the build.xml and the messages I got from running "ant all".

                          Thank you very much.

                          • 10. Re: problem with struts
                            yoyodyne

                            <<shouldn't the <dollar sign>{env.STRUTS_HOME} be translated to C:\struts ?>>
                            Yes, it shud.

                            I saw the following line in ur build.xml.

                            Try replacing the ":"s in the classpath with ";" (assuming that u r running the build on a windows platform).

                            If that doesnt work, replace the line with the following:
                            <javac srcdir="${top}/${src}" destdir="${build}"




                            scaffold.jar"/>



                            • 11. Re: problem with struts
                              yoyodyne

                              Yikes the dollars get eaten away :(

                              I saw the following line in ur build.xml.



                              Try replacing the ":"s in the classpath with ";" (assuming that u r running the build on a windows platform).

                              If that doesnt work, replace the line with the following:








                              • 12. Re: problem with struts
                                substring

                                First of all, I like to thank yoyodyne for the continuous help.

                                However, I modified the code as suggested and got the same result. Then, I got suspicious about the system variable translation and investigated a little more on this. Then I realized that I forgot to close the command prompt after I created the system variable. It was a stupid oversight, good grief! Now it compiled successfully.

                                Thanks for all the help.

                                • 13. Re: problem with struts
                                  yoyodyne

                                  ok cool :)