TechnoBuzz

A Techno Blog, mainly about Java

Struts2 Samples

I downloaded Struts2 (2.0.1) for first time after experimenting with webworks.

My experience at this point with struts2/webworks is limited.

I figured I would start from scratch rather than migrating some old code.

C:\java\struts2\struts-2.0.1\apps
The sample apps they have are
struts2-blank-2.0.1.war
struts2-mailreader-2.0.1.war
struts2-portlet-2.0.1.war
struts2-showcase-2.0.1.war

User List

Contents of  struts2-blank-2.0.1 war (folders in bold):

src
example
— ExampleSupport.java:    ExampleSupport extends com.opensymphony.xwork2.ActionSupport
— HelloWorld.java: HelloWorld extends ExampleSupport
– struts.properties: struts.devMode = true
                                  struts.enable.DynamicMethodInvocation = false

– struts.xml:  <!DOCTYPE struts PUBLIC
                     "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
                     "http://struts.apache.org/dtds/struts-2.0.dtd"&gt;
                   
… <include file="example.xml"/>

– example.xml: <!DOCTYPE struts PUBLIC
                     "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
                     "http://struts.apache.org/dtds/struts-2.0.dtd"&gt;
                   
<package name="example" namespace="/example" extends="struts-default">
                        

<action name="HelloWorld" class="example.HelloWorld">
                            <result>/example/HelloWorld.jsp</result>
                        </action>
                       <action name="Login!*" method="{1}" class="example.Login">
                            <result name="input">/example/Login.jsp</result>
                           <result type="redirect-action">Menu</result>
                      </action>
                      <action name="*" class="example.ExampleSupport">
                            <result>/example/{1}.jsp</result>
                    </action>
WebContent
WEB-INF

-lib

— commons-collections-3.1

— freemarker-2.3.4

— spring-aop-1.2.8

— spring-context-1.2.8

— spring-web-1.2.8

— struts2-core-2.0.1

— commons-logging-1.0.4

— ognl-2.6.7

— spring-beans-1.2.8

— spring-core-1.2.8

— struts2-api-2.0.1

— xwork-2.0-beta-1
example

The Struts 2  home page states the Struts 2 requires  Java 5. However, an alternate set of jars for  Java 1.4.x are available.  The challenge here is for people using Java 1.4.X is that the sample apps  come with the Java 5 jars.The java 4 jars can be found here.  I extracted them to here:

C:\java\struts2\struts-2.0.1\j4\

But, the only file I needed from here was struts2-extras-j4-2.0.0.jar .

copy C:\java\struts2\struts-2.0.1\j4\struts2-extras-j4-2.0.0.jar
C:\java\eclipse\workspace\struts2-blank-2.0.1\WebContent\WEB-INF\lib

as I got the backport files from the nightlies:

http://people.apache.org/builds/jakarta-struts/nightlies/2.0.x/java-1.4/backport/

which i copied to

C:\java\eclipse\workspace\struts2-blank-2.0.1\WebContent\WEB-INF\lib

Then i modified the translate.bat as follows:

java -jar retrotranslator-transformer-1.0.8.jar -srcjar struts2-core-2.0.1.jar -destjar struts2-core-j4-2.0.1.jar
java -jar retrotranslator-transformer-1.0.8.jar -srcjar struts2-api-2.0.1.jar -destjar struts2-api-j4-2.0.1.jar 
java -jar retrotranslator-transformer-1.0.8.jar -srcjar xwork-2.0-beta-1 -destjar xwork-2.0-j4.jar

The key thing is after the translate takes place to remove the following files:

  • struts2-core-2.0.1.jar
  • struts2-api-2.0.1.jar
  • xwork-2.0-beta-1

Again, a Java 5 version of struts2-extras-j4-2.0.0.jar was not in the struts2-blank-2.0.1 war.
In Summary, my lib folder contains the following jars for 1.4.x:

— commons-collections-3.1
—commons-beanutils-1.6
— commons-digester-1.6
— commons-logging-1.0.4

— freemarker-2.3.4

— spring-aop-1.2.8

— spring-context-1.2.8

— spring-web-1.2.8

— retrotranslator-runtime-1.0.8
— retrotranslator-transformer-1.0.8

— ognl-2.6.7

— spring-beans-1.2.8

— spring-core-1.2.8

— struts2-core-j4-2.0.1

— struts2-api-j4-2.0.1

— xwork-2.0-j4
—struts2-extras-j4-2.0.0
— backport-util-concurrent
— translate.bat

Refer to this issue here

Advertisements

November 24, 2006 - Posted by | Struts

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: