You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by WiltOnTilt <aa...@hotmail.com> on 2007/08/08 19:51:14 UTC

Possible to package struts2 actions/code in a reusable jar?

We have several projects that will have many common actions and links to
common JSP names.  For example, all of our projects will have a Welcome
action and a related welcome.jsp.

I'd like to be able to create a common-actions.jar that would essentially
contain all of the source code needed for each common action to run (Action
classes, beans, DAOs, Entity objects, etc).  The hope would be that I could
put the struts.xml in the jar as well as .properties files and then override
them as necessary under each project's src folder.  

So here's what I've done so far, my directory structure looks like this:

src
>arson/
>>action/
>>biz/
>>model/
>META-INF/
>arson.properties
>log4j.properties
>struts.xml

I tried jarring up everything under src.

Then in eclipse, I added the external jar to the project, and put it at the
very top of my buildpath.  

When I try to access my Welcome action, it couldn't find it, giving me this
error:

"There is no Action mapped for namespace / and action name Welcome. -
[unknown location]"

Any idea if what I want to do is even possible, or what I could be doing
wrong?

Thanks!
Aaron
-- 
View this message in context: http://www.nabble.com/Possible-to-package-struts2-actions-code-in-a-reusable-jar--tf4238026.html#a12058541
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Possible to package struts2 actions/code in a reusable jar?

Posted by Don Brown <do...@gmail.com>.
I believe by default, Struts will load multiple struts.xml files on
the classpath, so creating jars, each with their own struts.xml,
should work.  As mentioned, JSP's won't work, but you could put the in
the usual places, leaving the jars for config and Java code.

Don

On 8/9/07, Ian Roughley <ia...@fdar.com> wrote:
> Looks like you are talking about creating a plugin.  I think the issue
> is that struts.xml needs to be renamed to the plugin specific name.
>
> WiltOnTilt wrote:
> > We have several projects that will have many common actions and links to
> > common JSP names.  For example, all of our projects will have a Welcome
> > action and a related welcome.jsp.
> >
> > I'd like to be able to create a common-actions.jar that would essentially
> > contain all of the source code needed for each common action to run (Action
> > classes, beans, DAOs, Entity objects, etc).  The hope would be that I could
> > put the struts.xml in the jar as well as .properties files and then override
> > them as necessary under each project's src folder.
> >
> > So here's what I've done so far, my directory structure looks like this:
> >
> > src
> >
> >> arson/
> >>
> >>> action/
> >>> biz/
> >>> model/
> >>>
> >> META-INF/
> >> arson.properties
> >> log4j.properties
> >> struts.xml
> >>
> >
> > I tried jarring up everything under src.
> >
> > Then in eclipse, I added the external jar to the project, and put it at the
> > very top of my buildpath.
> >
> > When I try to access my Welcome action, it couldn't find it, giving me this
> > error:
> >
> > "There is no Action mapped for namespace / and action name Welcome. -
> > [unknown location]"
> >
> > Any idea if what I want to do is even possible, or what I could be doing
> > wrong?
> >
> > Thanks!
> > Aaron
> >
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Possible to package struts2 actions/code in a reusable jar?

Posted by Ian Roughley <ia...@fdar.com>.
Looks like you are talking about creating a plugin.  I think the issue 
is that struts.xml needs to be renamed to the plugin specific name. 

WiltOnTilt wrote:
> We have several projects that will have many common actions and links to
> common JSP names.  For example, all of our projects will have a Welcome
> action and a related welcome.jsp.
>
> I'd like to be able to create a common-actions.jar that would essentially
> contain all of the source code needed for each common action to run (Action
> classes, beans, DAOs, Entity objects, etc).  The hope would be that I could
> put the struts.xml in the jar as well as .properties files and then override
> them as necessary under each project's src folder.  
>
> So here's what I've done so far, my directory structure looks like this:
>
> src
>   
>> arson/
>>     
>>> action/
>>> biz/
>>> model/
>>>       
>> META-INF/
>> arson.properties
>> log4j.properties
>> struts.xml
>>     
>
> I tried jarring up everything under src.
>
> Then in eclipse, I added the external jar to the project, and put it at the
> very top of my buildpath.  
>
> When I try to access my Welcome action, it couldn't find it, giving me this
> error:
>
> "There is no Action mapped for namespace / and action name Welcome. -
> [unknown location]"
>
> Any idea if what I want to do is even possible, or what I could be doing
> wrong?
>
> Thanks!
> Aaron
>   

Re: Possible to package struts2 actions/code in a reusable jar?

Posted by Musachy Barroso <mu...@gmail.com>.
The JSPs cannot be accessed if they are inside a jar.I could be wrong
on this, but I don't think that putting struts.xml inside the jar will
work.

If you package it as a plugin, and map the actions in the plugin xml,
and use FreeMarker for the viewer you will be fine.

musachy

On 8/8/07, WiltOnTilt <aa...@hotmail.com> wrote:
>
> We have several projects that will have many common actions and links to
> common JSP names.  For example, all of our projects will have a Welcome
> action and a related welcome.jsp.
>
> I'd like to be able to create a common-actions.jar that would essentially
> contain all of the source code needed for each common action to run (Action
> classes, beans, DAOs, Entity objects, etc).  The hope would be that I could
> put the struts.xml in the jar as well as .properties files and then override
> them as necessary under each project's src folder.
>
> So here's what I've done so far, my directory structure looks like this:
>
> src
> >arson/
> >>action/
> >>biz/
> >>model/
> >META-INF/
> >arson.properties
> >log4j.properties
> >struts.xml
>
> I tried jarring up everything under src.
>
> Then in eclipse, I added the external jar to the project, and put it at the
> very top of my buildpath.
>
> When I try to access my Welcome action, it couldn't find it, giving me this
> error:
>
> "There is no Action mapped for namespace / and action name Welcome. -
> [unknown location]"
>
> Any idea if what I want to do is even possible, or what I could be doing
> wrong?
>
> Thanks!
> Aaron
> --
> View this message in context: http://www.nabble.com/Possible-to-package-struts2-actions-code-in-a-reusable-jar--tf4238026.html#a12058541
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org