0 Replies Latest reply on Nov 7, 2011 8:41 AM by Oved Ourfali

    problem in deploying servlet

    Oved Ourfali Newbie

      Hey,

       

      I have an ear, with several jars and wars.

       

      One of the wars contains a servlet.

       

      1. When I try to use it I get:

      15:34:35,713 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/webadmin]] (http--10.35.1.202-8080-1) Marking servlet WebAdminDynamicHosting as unavailable

      15:34:35,714 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/webadmin].[WebAdminDynamicHosting]] (http--10.35.1.202-8080-1) Allocate exception for servlet WebAdminDynamicHosting: java.lang.IllegalArgumentException: object is not an instance of declaring class

              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_20]

              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [:1.6.0_20]

              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [:1.6.0_20]

              at java.lang.reflect.Method.invoke(Method.java:616) [:1.6.0_20]

              at org.jboss.as.ee.component.ManagedReferenceMethodInjectionInterceptor.processInvocation(ManagedReferenceMethodInjectionInterceptor.java:66)

              at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]

              at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]

              at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]

              at org.jboss.as.ee.component.ManagedReferenceInterceptor.processInvocation(ManagedReferenceInterceptor.java:53)

              at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]

              at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]

              at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]

              at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)

              at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]

              at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]

              at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:152)

              at org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:77)

              at org.jboss.as.web.deployment.component.WebComponentInstantiator$1.<init>(WebComponentInstantiator.java:57) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]

              at org.jboss.as.web.deployment.component.WebComponentInstantiator.getReference(WebComponentInstantiator.java:55) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]

              at org.jboss.as.web.deployment.WebInjectionContainer.instantiate(WebInjectionContainer.java:99) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]

              at org.jboss.as.web.deployment.WebInjectionContainer.newInstance(WebInjectionContainer.java:78) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]

              at org.jboss.as.web.deployment.WebInjectionContainer.newInstance(WebInjectionContainer.java:72) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]

              at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1156) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

              at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:952) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:188) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

              at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:139) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]

              at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]

              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:952) [jbossweb-7.0.1.Final.jar:7.0.2.Final]

              at java.lang.Thread.run(Thread.java:636) [:1.6.0_20]

       

      2. Subsequent calls result it:

      Servlet WebAdminDynamicHosting is currently unavailable

       

      3. The source of the servlet is:

      package org.ovirt.engine.ui.frontend.server.gwt;

       

      import java.io.IOException;

      import java.io.PrintWriter;

       

      import javax.ejb.EJB;

      import javax.servlet.ServletException;

      import javax.servlet.http.HttpServlet;

      import javax.servlet.http.HttpServletRequest;

      import javax.servlet.http.HttpServletResponse;

       

      import org.ovirt.engine.core.common.interfaces.BackendLocal;

      import org.ovirt.engine.core.common.queries.VdcQueryParametersBase;

      import org.ovirt.engine.core.common.queries.VdcQueryReturnValue;

      import org.ovirt.engine.core.common.queries.VdcQueryType;

      import org.ovirt.engine.core.common.users.VdcUser;

       

      public class WebadminDynamicHostingServlet extends HttpServlet {

          private static final long serialVersionUID = 1L;

       

          private BackendLocal backend;

       

          // TODO: Should only set an html element that will be replaced by GWT widget instead.

          String title = "oVirt Enterprise Virtualization Engine Web Administration";

       

          @Override

          protected void doGet(HttpServletRequest req, HttpServletResponse resp)

                  throws IOException {

       

              PrintWriter writer = resp.getWriter();

              resp.setContentType("text/html");

              resp.setCharacterEncoding("UTF-8");

       

              writer.append("<!DOCTYPE html><html><head>");

              writer.append("<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">");

              writer.append("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=9\"/>");

              writer.append("<title>" + title + "</title>");

              VdcUser loggedUser = getLoggedInUser(req.getSession().getId());

              if (loggedUser != null) {

                  writer.append("<script type=\"text/javascript\">");

                  writer.append(" var userInfo = { ");

                  writer.append(" \"id\" : \"" + loggedUser.getUserId().toString() + "\",");

                  writer.append(" \"userName\" : \"" + loggedUser.getUserName() + "\",");

                  writer.append(" \"domain\" : \"" + loggedUser.getDomainControler() + "\"");

                  writer.append(" };");

                  writer.append("</script>");

              }

       

              writer.append("</head><body>");

       

              writer.append("<iframe src=\"javascript:''\" id=\"__gwt_historyFrame\" tabIndex='-1' style=\"position:absolute;width:0;height:0;border:0\"></iframe>");

              writer.append("<script type=\"text/javascript\" src=\"webadmin.nocache.js\"></script>");

       

              writer.append("</body></html>");

          }

       

          @Override

          protected void doPost(HttpServletRequest req, HttpServletResponse resp)

              throws ServletException, IOException {

            doGet(req, resp);

          }

       

         

          public VdcUser getLoggedInUser(String sessionId) {

              VdcQueryParametersBase queryParams = new VdcQueryParametersBase();

              queryParams.setSessionId(sessionId);

              queryParams.setHttpSessionId(sessionId);

       

              VdcQueryReturnValue vqrv = backend.RunQuery(VdcQueryType.GetUserBySessionId, queryParams);

       

              if (!vqrv.getSucceeded()) {

                  return null;

              } else if (vqrv.getSucceeded()) {

                  if (vqrv.getReturnValue() == null)

                      return null;

                  return (VdcUser) vqrv.getReturnValue();

              } else {

                  // For unknown reason the result was failed be returned.

                  return null;

              }

          }

       

          @EJB(beanInterface = BackendLocal.class, mappedName = "java:global/engine/engine-bll/Backend!org.ovirt.engine.core.common.interfaces.BackendLocal")

          public void setBackend(BackendLocal backend) {

              this.backend = backend;

          }

      }

       

      4. The service is located in a jar that is in the war/WEB-INF/lib directory.

       

      5. The servler definition and mapping in WEB-INF/web.xml is:

       

          <servlet> 
          <servlet-name>WebAdminDynamicHosting</servlet-name> 
          <servlet-class>org.ovirt.engine.ui.frontend.server.gwt.WebadminDynamicHostingServlet</servlet-class> 
      </servlet> 
      <!-- servlet mappings --> 
      <servlet-mapping> 
          <servlet-name>WebAdminDynamicHosting</servlet-name> 
          <url-pattern>/webadmin/WebAdmin.html</url-pattern> 
      </servlet-mapping> 

       

      6. I run jboss with the webservices module deployed (the standalone-preview.xml configuration).

       

      Help will be appreciated :-)

      Oved