Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am building a web service using seam 2.0.1 and deploying it on jboss 4.2.2 GA. I have my web service class which access another class (updates stuff in data base).

I have standard-jaxws-endpoint-config.xml in META-INF folder.

@Name("pluginHandler")
@Scope(ScopeType.APPLICATION)  
@Install(precedence = Install.BUILT_IN)
@Startup(depends = "someclass")
@Stateless
@WebService(name = "Plugin", serviceName = "PluginService")
public class PlugInHandler {
@WebMethod
public int processRequest(Account account)
    Workbench wb = Component.getInstance("Workbench");
    //above line keeps throwing exception "No application context active"

I have been looking all over different forums, but I cannot find a solution. I tried using Lifecycle.begincall() and Lifecycle.endCall() but nothing worked. Do I need web.xml as well? If yes what information should web.xml contain? Any help would be highly appreciated.

I recognize that this is question is rather dated, but to those few poor souls out there that still share your (and, currently my) predicament, here are a few pointers (dragged together from various sources but mainly from https://community.jboss.org/thread/192046):

Java EE WebService

First, using JBoss 4.2.2 likely means using Java EE5. WebServices there (with or without SEAM 2) can only be created on top of Stateless Session Beans. Stateless Session Beans in Java EE 5 need to implement a Service Endpoint Interface annotated with @Local or @Remote. While this has become optional in Java EE6, it is still mandatory here.

@Local
public interface PluginHandlerInterface {
   int processRequest(Account account);
@WebService
@Stateless
public PluginHandler implements PluginHandlerInterface { }

POJO WebService

If, in seam, you want to use a regular POJO as web-service, your class has to have another special annotation defining a Handler chain:

@WebService
// This here makes all the difference!
@HandlerChain(file = "web-service-handler-chain.xml")
public class PluginHandler {

This is the handler chain you put in /WEB-INF/classes/web-service-handler-chain.xml:

<?xml version="1.0" encoding="UTF-8"?>
<handler-chains xmlns="http://java.sun.com/xml/ns/javaee">
  <handler-chain>
    <handler>
      <description>seam request handler</description>
      <!-- probably not necessary
         <handler-name>org.jboss.seam.webservice.SOAPRequestHandler</handler-name>
      <handler-class>org.jboss.seam.webservice.SOAPRequestHandler</handler-class>
    </handler>
  </handler-chain>
</handler-chains>

And you have to announce your service class to the war files web.xml like so:

<listener> <!-- this might already be present in your web.xml -->
    <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
</listener>
<servlet> <!-- Which class is to be used? -->
    <servlet-name>PluginHandler</servlet-name>
    <servlet-class>your.package.name.PluginHandler</servlet-class>
</servlet>
<servlet-mapping> 
    <!-- you'll find it under http://localhost:8080/your-war/PluginHandler?wsdl-->
    <servlet-name>PluginHandler</servlet-name>
    <url-pattern>/PluginHandler</url-pattern>
</servlet-mapping>

So these three steps, creating the handler chain, adding the annotation and announcing your service to the web.xml, should do the trick for you in SEAM: You'll have a web-service and the SEAM Context available right in it.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.