• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

[solved]Struts 2 and Vaadin

 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The actual question is how can i provide a "do nothing" struts 2 action for the error message described below.

I want to embed a Vaadin application in a JSP used by Struts 2.
While the Vaadin part is sound, beeing a separate servlet, Struts 2 goes into an endless loop saying:
it can't find a There is no Action mapped for action name VaadinvizApplication/UIDL/
so, whatever communication Vaadin is doing, i don't want struts 2 meddling with it if i can. How do i configure struts 2 for that in this case?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure what you're asking--what do you need a Struts 2 action for if it's a servlet?
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
While displaying the web page, it goes in an infinite loop, displaying this error:
There is no Action mapped for action name VaadinvizApplication/UIDL/
VaadinvizApplication beeing my Vaadin servlet mapped path. Vaadin communicates through UIDL a lot asynchronously.
Struts 2 catches every request / response like an action and wants to do something about it since it filters everything with /*
UIDL is a Vaadin class that gets called asynchronously often, but i don't want Struts 2 to be doing anything about it.
That's why i asked "how can i provide a 'do nothing' struts 2 action".
I want to know how to map VaadinvizApplication/UIDL/ so i can just return "success" or nothing to the same page because i don't want to do nothing with the Struts 2 action.

P.S. I suspect the communication starts from Vaadin through UIDL, and sometime, Struts 2 gets in the way filtering the response by not beeing mapped, and it doesn't get to Vaadin.
If Struts 2 would just forward or ignore the Vaadin comms, i believe there wouldn't be a problem.

I got a war hosted here (but you have to get JSTL, Struts 2, c and sql tlds, Vaadin jar):
http://vaadin.com/forum/-/message_boards/message/99801
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you try mapping the servlet first in the web.xml?
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is my web.xml:
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh, right; I forgot S2 uses a filter--oops ;)

Are you in development mode? I guess I thought if S2 didn't see an action suffix (whatever you have that defined as--if you have a blank this could be causing the problem) it'd just pass it on without giving an error.
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How would that action look?
I made this experiment sending the result to the test2.jsp (simplified example - link below),
and i noticed this: struts 2 loads the jsp that embeds the Vaadin app, which communicates with its server counterpart for syncronization or something. Struts 2 catches this as an action, and since i send the response back to the page, the embedded vaadin app gets loaded again, which instead sends the UIDL communication again, which creates the infinite loop. How would i get out of this endless loop by configuring struts 2 properly. I want Struts 2 to ignore anything that contains "UIDL" for instance.
war here:
http://vaadin.com/forum/-/message_boards/message/99801

my struts.xml:
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm saying that you shouldn't have an action defined if you don't want Struts 2 to process a URL.
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With no action defined, i get:
There is no Action mapped for namespace / and action name . - [unknown location]
when trying to acces the JSP i get:
There is no Action mapped for action name VaadinStruts2Application/UIDL/. - [unknown location]

still in the infinite loop too.

Doesn't seem to matter what i map (except i don't get the errors now):
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, seems i've done it, the struts 2 just needs to send the intercepted UIDL to 'there be dragons', since it isn't suppose to do anything to it. I wish i knew how to ignore 'UIDL' requests. I'll update the war in the other forum with a working war.

 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm still not convinced I understand the problem, as we have several servlets working just fine in our S2 apps without it throwing any errors :/
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What version of S2 are you using? You never answered what your action extension is--if it's S2.1 the default includes extension-less actions, which could be the problem.
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
2.1.8.1
Vaadin framework has a client - server communication set up over a wrapper on top of JSON. Struts 2 hooks into that, although i don't understand perfectly well how i ended up in the infinite loop. As i observed, every time Vaadin gets embedded into the page, it sends a communication to its server side to be rendered. My guess is because i was responding with the same page, the embedding happened again, the communication happened again, and so on and so forth, an infinite loop.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, did you understand what I said?
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No didn't quite get that, you mean the classes that don't need to subclass ActionSupport?
I knew this. Don't they need their name to end in Action?
I can't relate to my problem with that.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, I mean that in Struts 2.0, the action extension was ".action". URLs not ending in ".action" were ignored.

In Struts 2.1 the action extension is ".action,,". URLs without an extension are *NOT* ignored by Struts. If you change the action extension to ".action" your problem will go away and you won't need to map an "empty" action to the servlet URL.
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, sorry but i still don't get it, how would i call my page?
When calling: http://localhost:8080/VaadinStruts2/test.action
i receive: There is no Action mapped for namespace / and action name test. - [unknown location]
I even wrote a test class, still doesn't work.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't understand. I thought your issue was that when calling the servlet you were getting S2 errors. The action extension setting is why.
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The actual flow is like this:
i call http://localhost:8080/VaadinStruts2/test.jsp
in test.jsp i have:



which embeds Vaadin. At this point i suspect a UIDL communication starts from AJAX, triggering the struts2 filter, which messes things up.
i even tried <url-pattern>/VaadinStruts2Application/*.action</url-pattern>, because the UIDL is the culprit i think, although it appends a '/' as you can see above and i can't guess what the mapping should look like.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm saying that if you fix the action extension configuration you shouldn't have a problem.
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understood that, thank you. However, i don't know how to apply that in my case other than downgrading to an older Struts 2. I tried appending .action everywhere it seemed logical.

EDIT: although this seems to work too, perhaps because it's sending the UIDL object nowhere again:

 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...

http://struts.apache.org/2.x/docs/strutsproperties.html
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Found struts2-core-2.1.8.1.jar\org\apache\struts2\default.properties
struts.action.extension=action,,
...so it should be ignored by default because the action .../UIDL/ ends in / ?
Lost again here, what should i write in:
<constant name="struts.action.extension" value="action,," /> in my struts.xml ?
Tried a couple of things, didn't work.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tudor Andrei Raneti wrote:
Lost again here, what should i write in:
<constant name="struts.action.extension" value="action,," /> in my struts.xml ?


No! That's what it is now! Remove the empty string suffix.
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much, it works, still unsure what happends technically though
Now all the requests are seen as .action(s)?

 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With the empty suffix Struts 2 will attempt to process all requests as actions.
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bangarang Thank you very much. Now only *.action(s) match actions.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Glad to hear we got it sorted out :)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic