1 Reply Latest reply on Mar 14, 2008 3:25 PM by Peter Johnson

    Local not bound

    Ken Hamilton Newbie

      I'm working on a my first custom servlet, and I'm making progress. I've looked at the posts of people who are rendering PDFs using iText directly, and the favorite design seems to be to tie the servlet to a URL using the web:context-filter tag in components.xml to let the servlet work inside Seam. I'm getting an error that I can't track down. Something to do with the servlet lifecycle, I suspect. The error looks like:

      ...
      Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component: printServer
       at org.jboss.seam.Component.newInstance(Component.java:1962)
       at org.jboss.seam.Component.getInstance(Component.java:1865)
       at org.jboss.seam.Component.getInstance(Component.java:1832)
       at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
       at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)
       at org.jboss.seam.el.SeamELResolver.resolveBase(SeamELResolver.java:166)
       at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:53)
       at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
       at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
       at org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
       at org.jboss.el.parser.AstValue.getTarget(AstValue.java:34)
       at org.jboss.el.parser.AstValue.invoke(AstValue.java:95)
       at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
       at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
       at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
       at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
       at javax.faces.component.UICommand.broadcast(UICommand.java:383)
       at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:184)
       at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:162)
       at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:350)
       at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
       ... 42 more
      Caused by: javax.naming.NameNotFoundException: local not bound
       at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
       at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
       at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
       at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
       at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
       at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
       at javax.naming.InitialContext.lookup(InitialContext.java:351)
       at org.jboss.seam.Component.instantiateSessionBean(Component.java:1279)
       at org.jboss.seam.Component.instantiate(Component.java:1265)
       at org.jboss.seam.Component.newInstance(Component.java:1958)


      The servlet looks like:

      @Name("printServer")
      @Stateless
      @Scope(ScopeType.CONVERSATION)
      public class PrintServer extends HttpServlet implements IPrintServer {
      
       private static final long serialVersionUID = 1278807414184735439L;
      
       @Logger
       private static Log log;
      
       public String test(String message) {
       log.info("Running printing test method", "Arg = " + message);
      
       return "Printing test message = " + message;
       }
      
       protected void doGet(HttpServletRequest request, HttpServletResponse response)
       throws ServletException, IOException
       {
       String path = request.getContextPath();
       log.info("Running doGet method: path: " + path);
      
       ServletOutputStream out = response.getOutputStream();
       out.println("<html><body><h1>Hello World! in doGet</h1></body></html>");
       }
      
       protected void service(HttpServletRequest request, HttpServletResponse response)
       throws ServletException, IOException {
       log.info("Running service method in Print Servlet");
      
       try {
       String path = request.getContextPath();
       log.info("Running service method: path: " + path);
      
       ServletOutputStream out = response.getOutputStream();
       out.println("<html><body><h1>Hello World! in service</h1></body></html>");
       }
       catch( Exception ex )
       {
       log.error( "PrintServer", ex.getMessage());
       }
       }
      }


      And the page that invokes it looks like:
      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
       xmlns:s="http://jboss.com/products/seam/taglib"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:rich="http://richfaces.org/rich"
       template="/layout/template.xhtml">
      
      <ui:define name="body">
      
       <h:messages globalOnly="true" styleClass="message"/>
      
       <rich:panel>
       <f:facet name="header">Printing test</f:facet>
       <h:form>
       <h:commandLink action="#{printServer.test('Hey Hey Kids')}" value="Print"/>
       </h:form>
       </rich:panel>
      
      </ui:define>
      </ui:composition>


      Any helpful nudges in the right direction will be appreciated. In particular I've been trying to determine what "local not bound" means. Does Seam think local is a name that it needs to resolve? If so, I don't see where it's getting that from. Thanks.