wood burning stoves*
The moose likes Web Services and the fly likes stateless endpoint, how to make soap-fault exeption rollback enabled Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "stateless endpoint, how to make soap-fault exeption rollback enabled" Watch "stateless endpoint, how to make soap-fault exeption rollback enabled" New topic
Author

stateless endpoint, how to make soap-fault exeption rollback enabled

Jaro Simak
Greenhorn

Joined: Oct 24, 2005
Posts: 26
Hello,
I have an implementation problem concerning transaction handling in a webservice endpoint.
I hope someone can help me.

I have defined a service in an wsdl, generated some classe using JAX-WS.
Finally, I wrote the webservice implementation, like that



Well, what I want to reach is that rollback is called, wenn
MyServiceFault is thrown in the webservice.
If I could, I put the annotation
@ApplicationException(rollback=true) on it. But it comes already compiled, generated from wsdl as the operation comes
with the some soap-faults.

I presume, there must be some way make it using some descriptor.
But, actually I don't have any.

Some suggestions?

Greetings Jaro
Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 576

Hi Jaro,



If you are using IDE to generate JAX-WS webservice artefacts, then if you had changed generated code with your custom annotation, as long as they are valid, IDE would recompile the java classes. Did you try doing this?

Can you tell how your SOAP Fault is being thrown, is your code throwing application SOAP Fault or it is the server? If it is your code, then I guess you must be knowing how to rollback, so I suppose you are asking how when server throws. I may not provide you 100% accurate solution but can suggest you to use SOAP Handler before the endpoint so you can deal with the SOAP fault. Your question is really interesting to think of.

Cheers,
Naren
------------------------------
SCJP
SCDJWS
SCWCD
------------------------------


Cheers,
Naren
(OCEEJBD6, SCWCD5, SCDJWS, SCJP1.4 and Oracle SQL 1Z0-051)
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Instead of using the @ApplicationException annotation in the code, you can use the <application-exception> element in the ejb-jar.xml deployment descriptor.
Example:

Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
Jaro Simak
Greenhorn

Joined: Oct 24, 2005
Posts: 26
Thanks, for responses.
I have actually known that one can override the ApplicationException annontation in ejb-jar.xml (among others).
For a plain ejb module I would not hesitate
What I don't know if or how does it apply to a webservice which based on ejb?

Where ejb-jar.xml should be packaged?
Currently (simplified) it looks like

myService.ear contains
      META-INF/
        |--MANIFEST.MF
        |--application.xml

      myService.war contains
            WEB-INF/
                 |--web.xml
                 |--wsdl/
                   |--myService.wsdl
                 |--classes/
                   |--class files
                 |--lib/
                   |--*jar files


I have tried it just like put it in meta-inf in the war file. But it does not work.
The rollback does not get called.


myService.ear contains
      META-INF/
        |--MANIFEST.MF
        |--application.xml

      myService.war contains
            meta-inf/
                |--ejb-jar.xml
            WEB-INF/
                 |--web.xml
                 |--wsdl/
                   |--myService.wsdl
                 |--classes/
                   |--class files
                 |--lib/
                   |--*jar files


Any suggestions?
Greetings Jaro
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Have you tried storing the ejb-jar.xml deployment descriptor in the WEB-INF directory?
If you are deploying to GlassFish v3, which fully supports EJB 3.1, then this will, without doubt, be possible.
Regretfully, I do not know about other application servers.
Good luck!
Jaro Simak
Greenhorn

Joined: Oct 24, 2005
Posts: 26
Well, finally I got the point. The bug was, that the service was packaged in the war-file and declared to be servlet.
The ejb features don't apply then.
I changed the packaging and put the endpoint to a regular ejb-module and the rollbacks work now fine
You have play then a little bit around with the web context and put the wsdl to the right place and some minor issues ..
The topic I worth to be described in some tutorial or blog. I found pretty much confusing stuff in internet.
Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 576

Hi Ivan,

Have you tried storing the ejb-jar.xml deployment descriptor in the WEB-INF directory?

A bit confused with this point. As far as I know, ejb-jar.xml should be placed in META-INF directly under .ear file. Can you explain this on how it could be otherwise different, please?
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
In EJB 3.1, the ejb-jar.xml deployment descriptor may also be stored in the WEB-INF directory to allow for deploying EJBs in a web application.
As before, you have to use a container that supports EJB 3.1 - GlassFish v3 is one such container.
Best wishes!
Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 576

Thanks Ivan.

I'm just getting into EJB3.1 and other related JEE 5 technologies. I feel having ejb-jar.xml in WEB-INF directory just to deploy EJBs in web application is very odd, why not use Enterprise archive in that case! Don't know how many these kind of weird changes in JEE 5 I have to get over with!
Jaro Simak
Greenhorn

Joined: Oct 24, 2005
Posts: 26
Hello Naren,
the ear consist of couple of ejb-modules, just put to the root of the ear and declared in application.xml
Each ejb-module (jar-file) have META-INF directory in it and possibly ejb-jar.xml there.
I declared an exception to be application-exception in the ejb-jar.xml for the ejb-based webservice endpoint.
I hope I do nothing wrong.
Best regards
Jaro

Thank you Ivan for the comment. We use jboss 5.1.0 - I have to look closer if it supports 3.1 ejb-jar.xml. After all the version is nearly 2 years old. For now I use just the 3.0 specification.
Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 576

Hi Jaro,
the ear consist of couple of ejb-modules, just put to the root of the ear and declared in application.xml
Each ejb-module (jar-file) have META-INF directory in it and possibly ejb-jar.xml there.
I declared an exception to be application-exception in the ejb-jar.xml for the ejb-based webservice endpoint.
I hope I do nothing wrong.

That's perfect and what I'd have thought, had you not been using EJB3.1. I should have mentioned JEE 6 in my earlier response
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Naren Chivukula wrote:I'm just getting into EJB3.1 and other related JEE 5 technologies. I feel having ejb-jar.xml in WEB-INF directory just to deploy EJBs in web application is very odd, why not use Enterprise archive in that case! Don't know how many these kind of weird changes in JEE 5 I have to get over with!

It is JavaEE 6 and there still is the option to deploy in an enterprise archive available.
Personally, I feel that being able to deploy EJBs in a web application enables me to quickly test and prototype things. It is also nice if I want to use EJBs in a smaller application.
However, for regular applications I would, as you suggest, deploy in an enterprise application.
These are, of course, only my preferences.
By the way, what am I doing?!?? Writing a post all about EJBs in the web service conference. Well, at least I mentioned the conference now...
Best wishes!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: stateless endpoint, how to make soap-fault exeption rollback enabled