3 Replies Latest reply on Jun 24, 2013 9:38 PM by sharad7879

    Class cast exception with Jboss 6.1

    sharad7879

      Hi,

       

      I am getting class cast exception while trying to post a request to my servlet, below are the logs for the same, This is working fine when i place my code jar inside the lib folder of my WAR file but when the same is placed inside the module folder with proper module xml i get this exception, I am able to refrence other custom libraries jars from module folder but getting below exception when trying to reference my code jar file.

      can someone help me with this please.

       

       

       

      19:54:17,712 INFO  [org.jboss.modules] (main) JBoss Modules version 1.2.0.Final-redhat-1

       

      19:54:22,274 INFO  [org.jboss.msc] (main) JBoss MSC version 1.0.4.GA-redhat-1

       

      19:54:22,352 INFO  [org.jboss.as] (MSC service thread 1-2) JBAS015899: JBoss EAP 6.1.0.GA (AS 7.2.0.Final-redhat-8) starting

       

      19:54:22,368 DEBUG [org.jboss.as.config] (MSC service thread 1-2) Configured system properties:

          awt.toolkit = sun.awt.windows.WToolkit

          file.encoding = MS932

          file.encoding.pkg = sun.io

          file.separator = \

          java.awt.graphicsenv = sun.awt.Win32GraphicsEnvironment

          java.awt.printerjob = sun.awt.windows.WPrinterJob

          java.class.path = D:\jboss-eap-6.1.0\jboss-eap-6.1\jboss-modules.jar

          java.class.version = 51.0

          java.endorsed.dirs = D:\jdk1.7.0_17\jre\lib\endorsed

          java.ext.dirs = D:\jdk1.7.0_17\jre\lib\ext;C:\Windows\Sun\Java\lib\ext

          java.home = D:\jdk1.7.0_17\jre

          java.io.tmpdir = C:\Users\myjava\AppData\Local\Temp\4\

          java.library.path = D:\jdk1.7.0_17\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.7.0_17\bin;;.

          java.net.preferIPv4Stack = true

          java.runtime.name = Java(TM) SE Runtime Environment

          java.runtime.version = 1.7.0_17-b02

          java.specification.name = Java Platform API Specification

          java.specification.vendor = Oracle Corporation

          java.specification.version = 1.7

          java.util.logging.manager = org.jboss.logmanager.LogManager

          java.vendor = Oracle Corporation

          java.vendor.url = http://java.oracle.com/

          java.vendor.url.bug = http://bugreport.sun.com/bugreport/

          java.version = 1.7.0_17

          java.vm.info = mixed mode

          java.vm.name = Java HotSpot(TM) 64-Bit Server VM

          java.vm.specification.name = Java Virtual Machine Specification

          java.vm.specification.vendor = Oracle Corporation

          java.vm.specification.version = 1.7

          java.vm.vendor = Oracle Corporation

          java.vm.version = 23.7-b01

          javax.management.builder.initial = org.jboss.as.jmx.PluggableMBeanServerBuilder

          javax.xml.datatype.DatatypeFactory = __redirected.__DatatypeFactory

          javax.xml.parsers.DocumentBuilderFactory = __redirected.__DocumentBuilderFactory

          javax.xml.parsers.SAXParserFactory = __redirected.__SAXParserFactory

          javax.xml.stream.XMLEventFactory = __redirected.__XMLEventFactory

          javax.xml.stream.XMLInputFactory = __redirected.__XMLInputFactory

          javax.xml.stream.XMLOutputFactory = __redirected.__XMLOutputFactory

          javax.xml.transform.TransformerFactory = __redirected.__TransformerFactory

          javax.xml.validation.SchemaFactory:http://www.w3.org/2001/XMLSchema = __redirected.__SchemaFactory

          javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom = __redirected.__XPathFactory

          jboss.home.dir = D:\jboss-eap-6.1.0\jboss-eap-6.1

          jboss.host.name = Test

          jboss.modules.dir = D:\jboss-eap-6.1.0\jboss-eap-6.1\modules

          jboss.modules.system.pkgs = org.jboss.byteman

          jboss.node.name = Test

          jboss.qualified.host.name = Test

          jboss.server.base.dir = D:\jboss-eap-6.1.0\jboss-eap-6.1\standalone

          jboss.server.config.dir = D:\jboss-eap-6.1.0\jboss-eap-6.1\standalone\configuration

          jboss.server.data.dir = D:\jboss-eap-6.1.0\jboss-eap-6.1\standalone\data

          jboss.server.deploy.dir = D:\jboss-eap-6.1.0\jboss-eap-6.1\standalone\data\content

          jboss.server.log.dir = D:\jboss-eap-6.1.0\jboss-eap-6.1\standalone\log

          jboss.server.name = Test

          jboss.server.persist.config = true

          jboss.server.temp.dir = D:\jboss-eap-6.1.0\jboss-eap-6.1\standalone\tmp

          line.separator =

       

       

          logging.configuration = file:D:\jboss-eap-6.1.0\jboss-eap-6.1\standalone/configuration/logging.properties

          module.path = D:\jboss-eap-6.1.0\jboss-eap-6.1\modules

          org.jboss.boot.log.file = D:\jboss-eap-6.1.0\jboss-eap-6.1\standalone\log\server.log

          org.jboss.resolver.warning = true

          org.xml.sax.driver = __redirected.__XMLReaderFactory

          os.arch = amd64

          os.name = Windows Server 2008 R2

          os.version = 6.1

          path.separator = ;

          program.name = standalone.bat

          sun.arch.data.model = 64

          sun.boot.class.path = D:\jdk1.7.0_17\jre\lib\resources.jar;D:\jdk1.7.0_17\jre\lib\rt.jar;D:\jdk1.7.0_17\jre\lib\sunrsasign.jar;D:\jdk1.7.0_17\jre\lib\jsse.jar;D:\jdk1.7.0_17\jre\lib\jce.jar;D:\jdk1.7.0_17\jre\lib\charsets.jar;D:\jdk1.7.0_17\jre\lib\jfr.jar;D:\jdk1.7.0_17\jre\classes

          sun.boot.library.path = D:\jdk1.7.0_17\jre\bin

          sun.cpu.endian = little

          sun.cpu.isalist = amd64

          sun.desktop = windows

          sun.io.unicode.encoding = UnicodeLittle

          sun.java.command = D:\jboss-eap-6.1.0\jboss-eap-6.1\jboss-modules.jar -mp D:\jboss-eap-6.1.0\jboss-eap-6.1\modules -jaxpmodule javax.xml.jaxp-provider org.jboss.as.standalone -Djboss.home.dir=D:\jboss-eap-6.1.0\jboss-eap-6.1 -Duser.home=D:\code4.2\myhome -Duser.dir=D:\code4.2\src

          sun.java.launcher = SUN_STANDARD

          sun.jnu.encoding = MS932

          sun.management.compiler = HotSpot 64-Bit Tiered Compilers

          sun.os.patch.level = Service Pack 1

          user.country = US

          user.country.format = JP

          user.dir = D:\code4.2\src

          user.home = D:\code4.2\myhome

          user.language = en

          user.language.format = ja

          user.name = myjava

          user.script =

          user.variant =

       

      19:54:22,368 DEBUG [org.jboss.as.config] (MSC service thread 1-2) VM Arguments: -XX:+TieredCompilation -XX:+UseCompressedOops -Dprogram.name=standalone.bat -Xms1303M -Xmx1303M -XX:MaxPermSize=256M -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Dorg.jboss.boot.log.file=D:\jboss-eap-6.1.0\jboss-eap-6.1\standalone\log\server.log -Dlogging.configuration=file:D:\jboss-eap-6.1.0\jboss-eap-6.1\standalone/configuration/logging.properties

       

      19:54:44,008 INFO  [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http)

       

      19:54:44,024 INFO  [org.xnio] (MSC service thread 1-2) XNIO Version 3.0.7.GA-redhat-1

       

      19:54:44,071 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 46) JBAS015537: Activating WebServices Extension

       

      19:54:44,102 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 42) JBAS013171: Activating Security Subsystem

       

      19:54:44,071 INFO  [org.xnio.nio] (MSC service thread 1-2) XNIO NIO Implementation Version 3.0.7.GA-redhat-1

       

      19:54:44,462 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 29) JBAS010280: Activating Infinispan subsystem.

       

      19:54:44,477 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 37) JBAS011800: Activating Naming Subsystem

       

      19:54:44,477 INFO  [org.jboss.as.jsf] (ServerService Thread Pool -- 35) JBAS012605: Activated the following JSF Implementations: [main, 1.2]

       

      19:54:46,602 INFO  [org.jboss.remoting] (MSC service thread 1-2) JBoss Remoting version 3.2.16.GA-redhat-1

       

      19:54:47,462 INFO  [org.jboss.as.security] (MSC service thread 1-2) JBAS013170: Current PicketBox version=4.0.17.Final-redhat-1

       

      19:54:51,602 INFO  [org.jboss.ws.common.management] (MSC service thread 1-1) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.1.3.Final-redhat-3

       

      19:54:52,102 INFO  [org.jboss.as.naming] (MSC service thread 1-2) JBAS011802: Starting Naming Service

       

      19:54:52,305 INFO  [org.apache.coyote.http11] (MSC service thread 1-1) JBWEB003001: Coyote HTTP/1.1 initializing on : http-/127.0.0.1:7004

       

      19:54:52,415 INFO  [org.apache.coyote.http11] (MSC service thread 1-1) JBWEB003000: Coyote HTTP/1.1 starting on: http-/127.0.0.1:7004

       

      19:54:57,508 INFO  [org.jboss.as.connector.logging] (MSC service thread 1-1) JBAS010408: Starting JCA Subsystem (IronJacamar 1.0.17.Final-redhat-1)

       

      19:54:57,430 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-2) JBAS015400: Bound mail session [java:jboss/mail/Default]

       

      19:54:57,399 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 25) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)

       

      19:54:57,618 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]

       

      19:54:57,649 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "httponline.war" (runtime-name: "httponline.war")

       

      19:54:57,774 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-1) JBAS015012: Started FileSystemDeploymentService for directory D:\jboss-eap-6.1.0\jboss-eap-6.1\standalone\deployments

       

      19:54:58,071 INFO  [org.jboss.as.remoting] (MSC service thread 1-1) JBAS017100: Listening on 127.0.0.1:4447

       

      19:54:58,024 INFO  [org.jboss.as.remoting] (MSC service thread 1-2) JBAS017100: Listening on 127.0.0.1:9999

       

      19:55:06,915 WARN  [org.jboss.as.dependency.private] (MSC service thread 1-1) JBAS018567: Deployment "deployment.httponline.war" is using a private module ("org.jboss.ws.spi:main") which may be changed or removed in future versions without notice.

       

      19:55:06,915 WARN  [org.jboss.as.dependency.private] (MSC service thread 1-1) JBAS018567: Deployment "deployment.httponline.war" is using a private module ("org.jboss.ws.spi:main") which may be changed or removed in future versions without notice.

       

      19:55:07,102 INFO  [org.jboss.web] (ServerService Thread Pool -- 54) JBAS018210: Register web context: /httponline

       

      19:55:07,243 INFO  [org.jboss.as.server] (Controller Boot Thread) JBAS018559: Deployed "httponline.war" (runtime-name : "httponline.war")

       

      19:55:07,290 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management

       

      19:55:07,290 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990

       

      19:55:07,290 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss EAP 6.1.0.GA (AS 7.2.0.Final-redhat-8) started in 51891ms - Started 166 of 223 services (56 services are passive or on-demand)

       

      19:55:29,587 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/httponline]] (http-/127.0.0.1:7004-1) JBWEB000264: Marking servlet httponline as unavailable

       

      19:55:29,587 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/httponline].[httponline]] (http-/127.0.0.1:7004-1) JBWEB000235: Allocate exception for servlet httponline: java.lang.ClassCastException: com.base.host.MyRequestServlet cannot be cast to javax.servlet.Servlet

       

          at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1154) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]

       

          at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:950) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]

       

          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:151) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]

       

          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]

       

          at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]

       

          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]

       

          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]

       

          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]

       

          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]

       

          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]

       

          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]

       

          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]

       

          at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_17]

        • 1. Re: Class cast exception with Jboss 6.1
          sfcoy

          Does your module.xml contain a dependency on the servlet api?

          {code:xml}    <dependencies>

                  <module name="javax.servlet.api" export="true"/>

                  <module name="javax.servlet.jsp.api" export="true"/>

              </dependencies>{code}

          or perhaps

          {code:xml}    <dependencies>

                  <module name="javaee.api" export="true"/>

              </dependencies>{code}

           

          • 2. Re: Class cast exception with Jboss 6.1
            ctomc

            Or do you have any servlet spec jars bundled with your app?

             

            can you post output of jar tf <name-of-your-deployment-archive> to see what you have in lib folders.

             

             

             

             

            --

            tomaz

            • 3. Re: Class cast exception with Jboss 6.1
              sharad7879

              Thanks Stephen!!! I added below to my module.xml and it is working now

               

              <dependencies>
                      <module name="javax.servlet.api" export="true"/>
                      <module name="javax.servlet.jsp.api" export="true"/>
              </dependencies>