0

I have a web service(jboss seam) which consume requests, it further delegates its work to different seam components. One of the seam component has event generation capability as Events.instance().raiseTransactionSuccessEvent, the method which is listening to this event does not get invoked.

Am i missing any configurations?

Please suggest

user1000258
  • 567
  • 2
  • 8
  • 16

3 Answers3

0
  1. Make sure a transaction is started, when invoking a Seam component from you web-service. If not, start it manually.
  2. Make sure that transaction actually commits.
Tair
  • 3,779
  • 2
  • 20
  • 33
  • Thanks for your reply. I have configured container managed transaction in components.xml file, by adding . According to the documentation, a transaction is started transparently when EJB is invoked (in my case it will be invoked by web service call). I am not sure what is the scope of transaction that start when an EJB is invoked. EJB in my case consumes web service calls and then delegates work to other non-EJB seam components. I will appreciate your help. – user1000258 Jul 05 '12 at 20:49
0

@Tair

I have an ejb component which consumes web service requests as below

@Name("plugin")
@Stateless
@WebService(name = "PluginService", serviceName = "PluginService")
public class PluginService implements IPlugin {
    @WebMethod
    public boolean createUser(String username, String password) {
        System.out.println("in login ");
        WebAuthenticator authenticator = (WebAuthenticator) Component
                .getInstance("webauthenticator");

        usreCreated = authenticator.create(username, password);
        System.out.println("valid user "+validUser);
                return userCreated;
}
}

WebAuthenticator is a seam component as follows

@Name("webauthenticator")
@Scope(ScopeType.CONVERSATION)

public class WebAuthenticator {

    @In
    EntityManager entityManager;

        @Observer("test")
        public void test()
        {
        System.out.println("A transaction success event was fired");
        }

    private static Log log = (Log) Logging.getLog(WebAuthenticator.class);
    private static byte[] accountPassword = null;
    private static Account currentAccount = null;

    public boolean createUser(String username, String password) {

        System.out.println("In web authenticator");
                User user = new User();
                user.username = username;
                user.password = password;
                entityManager.persist(user);
                entityManager.flush();
                Events.instance().raisTransactionSuccessEvent("test");
}
}

in components.xml file, i have <transaction:ejb-transaction /> , so that seam can get updates about container transaction events and I have seam managed persistence context

    <persistence:managed-persistence-context
   auto-create="true" name="entityManager" persistence-unit-jndi-   name="java:/pilotEntityManagerFactory" />
user1000258
  • 567
  • 2
  • 8
  • 16
0

I figured it out. The conclusion is never to mix ejb transaction with seam transactions. I explicitly disable the ejb trasaction management in the ejb. It worked!!.

user1000258
  • 567
  • 2
  • 8
  • 16