6 Replies Latest reply on Jul 6, 2007 10:00 PM by garypinkham

    ClassCastException: java.lang.Long when viewing home page.

    garypinkham

      ok. Apologizes early if I don't post the right info... I checked the forums and the Jira and don't see this issue so I'm betting it's me.. but here goes..

      I used Seam generate-entities to create a bunch of crud pages.. all went well. I have tried this again with the same DB several different times with no luck. It seems to generate the entities just fine, deploys and starts up but when I try to view the home page I'm presented with a "java.lang.ClassCastException: java.lang.Long" I've tried it with both 1.3Alpha (which worked the 1st time) and with 2.0Beta1. I'm using SQL Server 2005 and the SprintA TDS driver.

      Since there is so much code I didn't create I'm really not sure where to look for the issue. So any suggestions would be greatly appreciated. Also note that I had this error on a different entity.. I removed it from the included DB tables.. regenerated and now the next entity has the same issue so I know it wasn't a particular entity.

      Here is the Stack Trace:

      java.lang.ClassCastException: java.lang.Long
       at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManagerFactoryFromJndiOrVal
      ueBinding(ManagedPersistenceContext.java:228)
       at org.jboss.seam.persistence.ManagedPersistenceContext.initEntityManager(ManagedPersistence
      Context.java:79)
       at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManager(ManagedPersistenceC
      ontext.java:107)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
       at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:124)
       at org.jboss.seam.Component.callComponentMethod(Component.java:1957)
       at org.jboss.seam.Component.unwrap(Component.java:1983)
       at org.jboss.seam.Component.getInstance(Component.java:1770)
       at org.jboss.seam.Component.getInstance(Component.java:1723)
       at org.jboss.seam.Component.getInstance(Component.java:1717)
       at org.jboss.seam.framework.Controller.getComponentInstance(Controller.java:258)
       at org.jboss.seam.framework.PersistenceController.getPersistenceContext(PersistenceControlle
      r.java:20)
       at org.jboss.seam.framework.EntityQuery.getEntityManager(EntityQuery.java:120)
       at org.jboss.seam.framework.EntityQuery.validate(EntityQuery.java:29)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
       at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
       at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
       at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:38)
       at org.jboss.seam.util.Work.workInTransaction(Work.java:39)
       at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.jav
      a:32)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
       at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:4
      2)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
       at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java
      :151)
       at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:87)
       at com.foo.bar.config.entities.AuthoritiesList_$$_javassist_32.validate(AuthoritiesList_$
      $_javassist_32.java)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
       at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:124)
       at org.jboss.seam.Component.callComponentMethod(Component.java:1957)
       at org.jboss.seam.Component.callCreateMethod(Component.java:1880)
       at org.jboss.seam.Component.newInstance(Component.java:1859)
       at org.jboss.seam.Component.getInstance(Component.java:1756)
       at org.jboss.seam.Component.getInstance(Component.java:1723)
       at org.jboss.seam.Component.getInstance(Component.java:1717)
       at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:60)
       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.getValue(AstValue.java:63)
       at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
       at org.jboss.seam.core.Expressions$1.getValue(Expressions.java:112)
       at org.jboss.seam.navigation.Param.getValueFromModel(Param.java:127)
       at org.jboss.seam.navigation.Pages.getPageParameterValue(Pages.java:711)
       at org.jboss.seam.navigation.Pages.getConvertedParameters(Pages.java:687)
       at org.jboss.seam.ui.component.UISeamCommandBase.getUrl(UISeamCommandBase.java:50)
       at org.jboss.seam.ui.renderkit.LinkRendererBase.doEncodeBegin(LinkRendererBase.java:26)
       at org.jboss.seam.ui.util.cdk.RendererBase.encodeBegin(RendererBase.java:79)
       at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:785)
       at org.ajax4jsf.framework.renderer.RendererBase.renderChild(RendererBase.java:280)
       at org.richfaces.renderkit.html.ToolBarRendererBase.encodeChildren(ToolBarRendererBase.java:
      81)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809)
       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:577)
       at org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
       at org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:233)
       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.j
      ava: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:63)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:87)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:63)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:46)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
       at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:40)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:140)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j
      ava:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j
      ava:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.
      16:08:58,074 ERROR [STDERR] java:179)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:
      156)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.ja
      va:580)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Thread.java:595)
      


        • 1. Re: ClassCastException: java.lang.Long when viewing home pag
          gavin.king

          Show your components.xml

          • 2. Re: ClassCastException: java.lang.Long when viewing home pag
            garypinkham

            Thanks Gavin,

            <?xml version="1.0" encoding="UTF-8"?>
            <components xmlns="http://jboss.com/products/seam/components"
             xmlns:core="http://jboss.com/products/seam/core"
             xmlns:persistence="http://jboss.com/products/seam/persistence"
             xmlns:drools="http://jboss.com/products/seam/drools"
             xmlns:security="http://jboss.com/products/seam/security"
             xmlns:mail="http://jboss.com/products/seam/mail"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation=
             "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd
             http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd
             http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.0.xsd
             http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd
             http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.0.xsd
             http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd">
            
             <core:init debug="@debug@" jndi-pattern="@jndiPattern@"/>
            
             <core:manager concurrent-request-timeout="500"
             conversation-timeout="120000"
             conversation-id-parameter="cid"/>
            
             <persistence:managed-persistence-context name="entityManager"
             auto-create="true"
             entity-manager-factory="#{knx-seamui4EntityManagerFactory}"/>
            
             <persistence:entity-manager-factory name="knx-seamui4EntityManagerFactory"
             persistence-unit-name="knx-seamui4"/>
            
             <drools:rule-base name="securityRules">
             <drools:rule-files><value>/security.drl</value></drools:rule-files>
             </drools:rule-base>
            
             <security:identity authenticate-method="#{authenticator.authenticate}"
             security-rules="#{securityRules}"
             remember-me="true"/>
            
             <event type="org.jboss.seam.notLoggedIn">
             <action expression="#{redirect.captureCurrentView}"/>
             </event>
             <event type="org.jboss.seam.postAuthenticate">
             <action expression="#{redirect.returnToCapturedView}"/>
             </event>
            
             <mail:mail-session host="localhost" port="2525" username="test" password="test" />
            
             <!-- For use with jBPM pageflow or process management -->
             <!--
             <bpm:jbpm>
             <bpm:process-definitions></bpm:process-definitions>
             <bpm:pageflow-definitions></bpm:pageflow-definitions>
             </bpm:jbpm>
             -->
            
            </components>
            


            • 3. Re: ClassCastException: java.lang.Long when viewing home pag
              gavin.king

              You can't have a minus in the name of a Seam component.

              • 4. Re: ClassCastException: java.lang.Long when viewing home pag
                garypinkham

                 

                "gavin.king@jboss.com" wrote:
                You can't have a minus in the name of a Seam component.


                That was it!! Many thanks Gavin! Now that I know this and I look at the project which worked (knxconfig) and the 4 that didn't (knx-seamui1 thru knx-seamui4) it makes sense to me!

                Thanks again.
                Gary

                • 5. Re: ClassCastException: java.lang.Long when viewing home pag
                  gavin.king

                  np, its Seam's fault for not validating the name very well

                  Would you do me a favor and report in JIRA that Seam should validate component names and eliminate things that aren't valid EL identifiers?

                  Thanks

                  • 6. Re: ClassCastException: java.lang.Long when viewing home pag
                    garypinkham