2 Replies Latest reply on Jun 13, 2007 11:45 PM by Daniel Young

    Is it possible to have same Class name Different package/@Na

    Chris Hane Novice

      Is it possible in Seam to have two SFSB that have the same class name but be in two packages with different component names?

      package com.firstpackage.inf
      
      @Local
      public interface ISomeEditor{
       ... methods ...
      }
      

      package com.firstpackage
      
      @Name("component1")
      @Stateful
      public class SomeEditor implements com.firstpackage.inf.ISomeEditor{
      ...methods...
      }
      


      package com.secondpackage.inf
      
      @Local
      public interface ISomeEditor{
       ... methods ...
      }
      

      package com.secondpackage
      
      @Name("component2")
      @Stateful
      public class SomeEditor implements com.secondpackage.inf.ISomeEditor{
      ...methods...
      }
      


      It seems this isn't possible, I am getting the following error with 1.2.0p1. If I change the name of the class (Interface name can be the same), everything works:
      javax.faces.el.EvaluationException: Exception while invoking expression #{component1.showRoles}
       at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:165)
       at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpression(ActionParamBindingHelper.java:58)
       at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionParamMethodBinding.java:75)
       at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:106)
       at org.jboss.seam.core.Pages.callAction(Pages.java:466)
       at org.jboss.seam.core.Pages.enterPage(Pages.java:275)
       at org.jboss.seam.jsf.AbstractSeamPhaseListener.enterPage(AbstractSeamPhaseListener.java:242)
       at org.jboss.seam.jsf.AbstractSeamPhaseListener.beforeRender(AbstractSeamPhaseListener.java:193)
       at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:57)
       at org.apache.myfaces.lifecycle.PhaseListenerManager.informPhaseListenersBefore(PhaseListenerManager.java:70)
       at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:373)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._invokeDoFilter(TrinidadFilterImpl.java:210)
       at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:167)
       at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:140)
       at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:93)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
       at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:199)
       at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:282)
       at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:754)
       at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:684)
       at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:876)
       at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: java.lang.ClassCastException: $Proxy335
       at com.firstpackage.inf.ISomeEditor$$FastClassByCGLIB$$3c2e74ac.invoke(<generated>)
       at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
       at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:45)
       at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:74)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:57)
       at org.jboss.seam.interceptors.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:40)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
       at org.jboss.seam.intercept.ClientSideInterceptor.intercept(ClientSideInterceptor.java:52)
       at org.jboss.seam.intercept.Proxy$$EnhancerByCGLIB$$1db42c93.initialize(<generated>)
       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:18)
       at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:121)
       at org.jboss.seam.Component.callComponentMethod(Component.java:1802)
       at org.jboss.seam.Component.callCreateMethod(Component.java:1725)
       at org.jboss.seam.Component.newInstance(Component.java:1714)
       at org.jboss.seam.Component.getInstance(Component.java:1611)
       at org.jboss.seam.Component.getInstance(Component.java:1578)
       at org.jboss.seam.jsf.SeamVariableResolver.resolveVariable(SeamVariableResolver.java:53)
       at org.apache.myfaces.trinidadinternal.el.TrinidadVariableResolver.resolveVariable(TrinidadVariableResolver.java:55)
       at org.apache.myfaces.config.LastVariableResolverInChain.resolveVariable(LastVariableResolverInChain.java:42)
       at org.apache.myfaces.el.ValueBindingImpl$ELVariableResolver.resolveVariable(ValueBindingImpl.java:574)
       at org.apache.commons.el.NamedValue.evaluate(NamedValue.java:124)
       at org.apache.myfaces.el.ValueBindingImpl.resolveToBaseAndProperty(ValueBindingImpl.java:455)
       at org.apache.myfaces.el.MethodBindingImpl.resolveToBaseAndProperty(MethodBindingImpl.java:180)
       at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:114)
       ... 50 more
      23:12:27,531 INFO [Exceptions] reading exception mappings from /WEB-INF/pages.xml
      23:12:27,531 ERROR [DebugPageHandler] redirecting to debug page
      


        • 1. Re: Is it possible to have same Class name Different package
          Daniel Young Novice


          Regardless of Seam, all EJBs in the same ejb-jar should have unique ejb names.

          Try annotating the SFSB classes with @EJB(name="beanX"), this may solve the problem.

          • 2. Re: Is it possible to have same Class name Different package
            Daniel Young Novice

             

            "jazir1979" wrote:

            Regardless of Seam, all EJBs in the same ejb-jar should have unique ejb names.

            Try annotating the SFSB classes with @EJB(name="beanX"), this may solve the problem.


            BTW- there's a section on page 319 of Bill Burke's EJB3 book that explains how JBoss resolves ambiguous EJB-name references. I imagine Seam is just doing a JNDI lookup and getting the wrong EJB back, hence the class cast exception.

            Ideally, it would be a deployment time error, to do what you're doing here (maybe there even is a warning in your logs). But as the book says, you could still have ambiguous name references across different ejb-jar's in the same EAR.