Skip to main content

Oracle GlassFish Server 3.1 Embedded throws many ClassCast Exceptions

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
No replies
tsmets
Offline
Joined: 2005-05-04

Based on the page : http://docs.oracle.com/cd/E18930_01/html/821-2424/giijw.html#scrolltoc
I wrote this :

	public static void main(String[] args) throws Exception {

    System.out.println("Starting");
    File configFile = new File ("/Applications/servers/glassfish3.1/glassfishv3/glassfish/glassfishv3/glassfish/domains/mydomain/config/domain.xml");
        File war = new File("./target/MyApp.war");
        GlassFishRuntime glassfishRuntime = GlassFishRuntime.bootstrap();
       
        GlassFishProperties glassfishProperties = new GlassFishProperties();
        System.out.println("URI : '" + configFile.toURI().toString() + "'");
        glassfishProperties.setConfigFileURI(configFile.toURI().toString());    //setConfigFileURI(configFile.toURI());
       
        glassfishProperties.setConfigFileReadOnly(true);  // was false
       
        GlassFish gf = glassfishRuntime.newGlassFish(glassfishProperties);
        gf.start();
       
        Deployer deployer = gf.getDeployer();
        deployer.deploy(war, "--force=true");
       
        Thread.sleep(2000);
       
        System.out.println("Press Enter to stop server");
        // wait for Enter
        new BufferedReader(new java.io.InputStreamReader(System.in)).readLine();
       
        gf.dispose();
        glassfishRuntime.shutdown();
}

The application seems to start OK but generates many many ClassCastExceptions.

SEVERE: PWC3989: An exception or error occurred in the container during the request processing
java.lang.ClassCastException: org.glassfish.grizzly.config.ContextRootInfo cannot be cast to org.apache.catalina.Context
at org.apache.catalina.connector.CoyoteAdapter.postParseRequest(CoyoteAdapter.java:538)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:286)

This error occurs many many time ... hopefully with apparently the EJB / Datasources being deployed

Any idea what's the root cause of those ClassCastException ?

Also, there is this message that worries me a bit :

SEVERE: Exception while loading the app : org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;
Ljava/lang/Throwable;)VPlainTextActionReporterFAILUREDescription: deploy AdminCommandError occurred during deployment:
Exception while loading the app : org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V.
Please see server.log for more details.
    [name=MyApp
Jul 17, 2013 1:10:19 PM org.apache.catalina.connector.CoyoteAdapter service
SEVERE: PWC3989: An exception or error occurred in the container during the request processing
java.lang.ClassCastException: org.glassfish.grizzly.config.ContextRootInfo cannot be cast to org.apache.catalina.Context
at org.apache.catalina.connector.CoyoteAdapter.postParseRequest(CoyoteAdapter.java:538)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:286)

but the real annoying part is that when I do a call :
I get the following stacktrace :

javax.ejb.EJBException: Attempt to invoke when container is in Initializing
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1996)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1991)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:222)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
at sun.proxy.$Proxy156.getParameter(Unknown Source)
at myApp.services.__EJB31_Generated__ParametersService__Intf____Bean__.getParameter(Unknown Source)
at myApp.actions.InitAction.prepare(InitAction.java:118)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:167)
...

Any Idea ... ?

\T,