[jboss-user] [Beginners Corner] - Creating a servlet

2008-03-14 Thread tracker
I have a JBoss Seam project already in place, and I'm trying to add a service 
that will return a PDF from a URL request. It's my understanding that to do 
that I will need to modify the HTTP response, and to do that I need a component 
that extends HTTPServlet. I've tried to do that but I suspect that I'm missing 
some vital information. The code and error are below. If you read on, thank 
you, and prepare to be shocked by ignorance and apparently willful stupidity. 
But that's why I posted it in the Beginner's Corner.

The component code looks like this:
@Name(printServer)
  | @Stateless
  | @Scope(ScopeType.PAGE)
  | 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;
  | }
  | }

The interface code (do I even need to do that?) looks like this:
@Remote
  | public interface IPrintServer {
  | public String test(String message);
  | }

The servlet mapping in web.xml looks like this:
servlet
  | servlet-namePrint Servlet/servlet-name
  | 
servlet-classcom.mckesson.hbi.services.PrintServer/servlet-class
  | load-on-startup2/load-on-startup
  | /servlet
  | servlet-mapping
  | servlet-namePrint Servlet/servlet-name
  | url-pattern/services/pdf/*/url-pattern
  | /servlet-mapping
  | 

The page I'm using it in looks like this:
!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=headerPrinting test/f:facet
  | divPrint: #{printServer.test(Hey Hey Kids)}/div
  | /rich:panel
  | 
  | /ui:define 
  | /ui:composition

The error looks like this:
SEVERE: Error Rendering View[/services/pdf/print.xhtml]
  | javax.el.ELException: /services/pdf/print.xhtml: Could not instantiate Seam 
component: printServer
  | at 
com.sun.facelets.compiler.TextInstruction.write(TextInstruction.java:50)
  | at 
com.sun.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:39)
  | at 
org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:280)
  | at 
org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
  | at 
org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:220)
  | at 
org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:215)
  | at 
org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:121)
  | at 
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
  | at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
  | at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
  | at 
com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
  | at 
org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
  | at 
org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
  | at 
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
  | at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
  | at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
  | at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
  | at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
  | at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  | at 
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
  | at 
org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
  | at 
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  | at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
  | at 
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  | at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
  | at 

[jboss-user] [Beginners Corner] - Local not bound

2008-03-14 Thread tracker
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(htmlbodyh1Hello 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(htmlbodyh1Hello World! in 
service/h1/body/html);
  | }
  | catch( Exception ex )
  | {
  | log.error( PrintServer, ex.getMessage());
  | }
  | }
  | }