On Thu, 11 Jul 2002, Struts Newsgroup wrote:

> Date: Thu, 11 Jul 2002 16:40:02 -0700
> From: Struts Newsgroup <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: where is ApplicationResources.properties defined?
>
> Subject: where is ApplicationResources.properties defined?
> From: "David Chu" <[EMAIL PROTECTED]>
>  ===
> I am very confused on how to define a new path for the file currently named
> "ApplicationResources.properties"  I did not see any definition in either
> web.xml nor struts-confug.xml.   Specifically, is there any way to define it
> to live outside of the "WEB-INF/classes" directory?  (this is because a
> clean operation deletes my whole classes directory, including the
> ApplicationResources.properties file!)  Thanks very much for the help.
>

Struts uses the web application class loader to load the application
resources file for your application.  Therefore, it must either be in
/WEB-INF/classes, or inside a JAR file in /WEB-INF/lib.

In Struts 1.0, you configure the "class name" of the application resources
by using the "application" servlet initialization parameter on the
controller servlet.  In Struts 1.1, you configure this with a
<message-resources> element in struts-config.xml instead.

In the Struts example application, the application resources are
initialized to "org.apache.struts.webapp.example.ApplicationResources",
which means that they must either exist as files named

  /WEB-INF/classes/org/apache/struts/webapp/example/ApplicationResources.properties

or be in a JAR file in /WEB-INF/lib with the pathname

  org/apache/struts/webapp/example/ApplicationResources.properties

My developemnet setup is similar to yours, in that a "clean" operation
deletes the entire web application output directory.  I solve this by
keeping the properties files for the application resources in the same
directory as the Java source code for the corresponding package (in this
case, the package is org.apache.struts.webapp.example).  Then, in my Ant
build script, I copy all the non-Java source files after compiling, like
this:

  <!-- Copy JSP files, WEB-INF configuration files, etc. -->
  <target name="prepare">
    <mkdir  dir="target">
    <copy todir="target">
      <fileset dir="web"/>
    </copy>
  </target>


  <target name="compile" depends="prepare">
    <!-- Compile Java classes, output .class files to /WEB-INF/classes -->
    <javac srcdir="src"
          destdir="target/WEB-INF/classes"
             ...>
    </javac>
    <!-- Copy everything except sources -->
    <!-- This picks up the application resources properties files -->
    <copy todir="target/WEB-INF/classes">
      <fileset dir="src">
        <exclude name="**/*.java"/>
      </fileset>
    </copy>
  </target>

In my CVS repository, all the Java sources and properties files are under
"src", and all the JSP pages and WEB-INF stuff is under "web".  Thus, I
can reassemble the entire webapp under the "target" directory" any time I
want to.

If you're not using Ant, you should be able to set up something equivalent
to this with your preferred build tools.

>
> --
> -david

Craig


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to