File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes [solved]Struts 2 and Vaadin Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "[solved]Struts 2 and Vaadin" Watch "[solved]Struts 2 and Vaadin" New topic
Author

[solved]Struts 2 and Vaadin

Tudor Raneti
Ranch Hand

Joined: Nov 29, 2009
Posts: 145
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?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Nov 29, 2009
Posts: 145
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
Rancher

Joined: Sep 29, 2008
Posts: 12617

Did you try mapping the servlet first in the web.xml?
Tudor Raneti
Ranch Hand

Joined: Nov 29, 2009
Posts: 145
This is my web.xml:
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Nov 29, 2009
Posts: 145
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
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Nov 29, 2009
Posts: 145
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

Joined: Nov 29, 2009
Posts: 145
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
Rancher

Joined: Sep 29, 2008
Posts: 12617

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
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Nov 29, 2009
Posts: 145
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
Rancher

Joined: Sep 29, 2008
Posts: 12617

Okay, did you understand what I said?
Tudor Raneti
Ranch Hand

Joined: Nov 29, 2009
Posts: 145
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
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Nov 29, 2009
Posts: 145
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
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Nov 29, 2009
Posts: 145
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
Rancher

Joined: Sep 29, 2008
Posts: 12617

I'm saying that if you fix the action extension configuration you shouldn't have a problem.
Tudor Raneti
Ranch Hand

Joined: Nov 29, 2009
Posts: 145
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
Rancher

Joined: Sep 29, 2008
Posts: 12617

...

http://struts.apache.org/2.x/docs/strutsproperties.html
Tudor Raneti
Ranch Hand

Joined: Nov 29, 2009
Posts: 145
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
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Nov 29, 2009
Posts: 145
Thank you very much, it works, still unsure what happends technically though
Now all the requests are seen as .action(s)?

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

With the empty suffix Struts 2 will attempt to process all requests as actions.
Tudor Raneti
Ranch Hand

Joined: Nov 29, 2009
Posts: 145
Bangarang Thank you very much. Now only *.action(s) match actions.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Glad to hear we got it sorted out :)
 
 
subject: [solved]Struts 2 and Vaadin