Hi Jean

thanks for the explanation. I understand now.

[]

Leo


On Fri, Nov 29, 2013 at 8:31 AM, Jean-Louis MONTEIRO <[email protected]>wrote:

> Hi,
>
> As per the spec that is perfectly the desired behavior IMHO.
> When using a local view bean (concrete ejb without any interface), the
> container basically generate the necessary stuff to make it serializable.
> When you define by your self a view (@Local, @Remote, etc), you receive the
> view you defined.
>
> So to be clear, the EJB2 must be cast to SomeInterface after the lookup.
>
> Hope that helps
> JLouis
>
>
>
> 2013/11/28 Leonardo K. Shikida <[email protected]>
>
> > Sure
> >
> > >>>>>>>>>>>
> >
> > import javax.ejb.embeddable.EJBContainer;
> > import javax.naming.Context;
> > import javax.naming.NamingException;
> >
> >
> > public class Test {
> >
> >     /**
> >      * @param args
> >      * @throws NamingException
> >      */
> >     public static void main(String[] args) throws NamingException {
> >         EJBContainer ejbContainer = EJBContainer.createEJBContainer();
> >         Context context = ejbContainer.getContext();
> >
> >         EJBOne one = (EJBOne)
> > context.lookup("java:global/Interfaces/"+EJBOne.class.getSimpleName());
> >         EJBTwo two = (EJBTwo)
> > context.lookup("java:global/Interfaces/"+EJBTwo.class.getSimpleName());
> >         ejbContainer.close();
> >
> >     }
> >
> > }
> >
> > >>>>>>>>>>>
> >
> > import javax.ejb.Stateless;
> >
> >
> > @Stateless
> > public class EJBOne {
> >
> > }
> >
> > >>>>>>>>>>>>>
> >
> > import javax.ejb.Stateless;
> >
> >
> > @Stateless
> > public class EJBTwo implements SomeInterface{
> >
> > }
> >
> > >>>>>>>>>>>>
> >
> > public interface SomeInterface {
> >
> > }
> >
> > >>>>>>>>>>>>
> >
> > Nov 28, 2013 7:21:25 PM org.apache.openejb.OpenEJB$Instance <init>
> > INFO:
> >
> >
> ********************************************************************************
> > Nov 28, 2013 7:21:25 PM org.apache.openejb.OpenEJB$Instance <init>
> > INFO: OpenEJB http://openejb.apache.org/
> > Nov 28, 2013 7:21:25 PM org.apache.openejb.OpenEJB$Instance <init>
> > INFO: Startup: Thu Nov 28 19:21:25 BRST 2013
> > Nov 28, 2013 7:21:25 PM org.apache.openejb.OpenEJB$Instance <init>
> > INFO: Copyright 1999-2013 (C) Apache OpenEJB Project, All Rights
> Reserved.
> > Nov 28, 2013 7:21:25 PM org.apache.openejb.OpenEJB$Instance <init>
> > INFO: Version: 4.6.0-SNAPSHOT
> > Nov 28, 2013 7:21:25 PM org.apache.openejb.OpenEJB$Instance <init>
> > INFO: Build date: 20131119
> > Nov 28, 2013 7:21:25 PM org.apache.openejb.OpenEJB$Instance <init>
> > INFO: Build time: 04:08
> > Nov 28, 2013 7:21:25 PM org.apache.openejb.OpenEJB$Instance <init>
> > INFO:
> >
> >
> ********************************************************************************
> > Nov 28, 2013 7:21:25 PM org.apache.openejb.OpenEJB$Instance <init>
> > INFO: openejb.home = /home/leoks/EclipseIndigo/workspace2/Interfaces
> > Nov 28, 2013 7:21:25 PM org.apache.openejb.OpenEJB$Instance <init>
> > INFO: openejb.base = /home/leoks/EclipseIndigo/workspace2/Interfaces
> > Nov 28, 2013 7:21:25 PM org.apache.openejb.cdi.CdiBuilder initializeOWB
> > INFO: Created new singletonService
> > org.apache.openejb.cdi.ThreadSingletonServiceImpl@119126ab
> > Nov 28, 2013 7:21:25 PM org.apache.openejb.cdi.CdiBuilder initializeOWB
> > INFO: Succeeded in installing singleton service
> > Nov 28, 2013 7:21:25 PM org.apache.openejb.util.OptionsLog info
> > INFO: Using 'javax.ejb.embeddable.EJBContainer=true'
> > Nov 28, 2013 7:21:25 PM org.apache.openejb.config.ConfigUtils
> > searchForConfiguration
> > INFO: Cannot find the configuration file [conf/openejb.xml].  Will
> attempt
> > to create one for the beans deployed.
> > Nov 28, 2013 7:21:25 PM org.apache.openejb.config.ConfigurationFactory
> > configureService
> > INFO: Configuring Service(id=Default Security Service,
> > type=SecurityService, provider-id=Default Security Service)
> > Nov 28, 2013 7:21:25 PM org.apache.openejb.config.ConfigurationFactory
> > configureService
> > INFO: Configuring Service(id=Default Transaction Manager,
> > type=TransactionManager, provider-id=Default Transaction Manager)
> > Nov 28, 2013 7:21:25 PM org.apache.openejb.assembler.classic.Assembler
> > createRecipe
> > INFO: Creating TransactionManager(id=Default Transaction Manager)
> > Nov 28, 2013 7:21:25 PM org.apache.openejb.assembler.classic.Assembler
> > createRecipe
> > INFO: Creating SecurityService(id=Default Security Service)
> > Nov 28, 2013 7:21:26 PM org.apache.openejb.config.DeploymentsResolver
> > processUrls
> > INFO: Found EjbModule in classpath:
> > /home/leoks/EclipseIndigo/workspace2/Interfaces/build/classes
> > Nov 28, 2013 7:21:26 PM org.apache.openejb.config.ConfigurationFactory
> > loadApplication
> > INFO: Beginning load:
> > /home/leoks/EclipseIndigo/workspace2/Interfaces/build/classes
> > Nov 28, 2013 7:21:26 PM org.apache.openejb.config.ConfigurationFactory
> > configureApplication
> > INFO: Configuring enterprise application:
> > /home/leoks/EclipseIndigo/workspace2/Interfaces
> > Nov 28, 2013 7:21:26 PM org.apache.openejb.config.InitEjbDeployments
> deploy
> > INFO: Auto-deploying ejb EJBTwo: EjbDeployment(deployment-id=EJBTwo)
> > Nov 28, 2013 7:21:26 PM org.apache.openejb.config.InitEjbDeployments
> deploy
> > INFO: Auto-deploying ejb EJBOne: EjbDeployment(deployment-id=EJBOne)
> > Nov 28, 2013 7:21:26 PM org.apache.openejb.config.ConfigurationFactory
> > configureService
> > INFO: Configuring Service(id=Default Stateless Container, type=Container,
> > provider-id=Default Stateless Container)
> > Nov 28, 2013 7:21:26 PM org.apache.openejb.config.AutoConfig
> > createContainer
> > INFO: Auto-creating a container for bean EJBTwo:
> Container(type=STATELESS,
> > id=Default Stateless Container)
> > Nov 28, 2013 7:21:26 PM org.apache.openejb.assembler.classic.Assembler
> > createRecipe
> > INFO: Creating Container(id=Default Stateless Container)
> > Nov 28, 2013 7:21:26 PM org.apache.openejb.config.ConfigurationFactory
> > configureService
> > INFO: Configuring Service(id=Default Managed Container, type=Container,
> > provider-id=Default Managed Container)
> > Nov 28, 2013 7:21:26 PM org.apache.openejb.config.AutoConfig
> > createContainer
> > INFO: Auto-creating a container for bean Test: Container(type=MANAGED,
> > id=Default Managed Container)
> > Nov 28, 2013 7:21:26 PM org.apache.openejb.assembler.classic.Assembler
> > createRecipe
> > INFO: Creating Container(id=Default Managed Container)
> > Nov 28, 2013 7:21:26 PM org.apache.openejb.core.managed.SimplePassivater
> > init
> > INFO: Using directory /tmp for stateful session passivation
> > Nov 28, 2013 7:21:26 PM org.apache.openejb.config.AppInfoBuilder build
> > INFO: Enterprise application
> > "/home/leoks/EclipseIndigo/workspace2/Interfaces" loaded.
> > Nov 28, 2013 7:21:26 PM org.apache.openejb.assembler.classic.Assembler
> > createApplication
> > INFO: Assembling app: /home/leoks/EclipseIndigo/workspace2/Interfaces
> > Nov 28, 2013 7:21:26 PM org.apache.openejb.assembler.classic.JndiBuilder
> > bindJava
> > INFO: Jndi(name="java:global/Interfaces/EJBTwo!SomeInterface")
> > Nov 28, 2013 7:21:26 PM org.apache.openejb.assembler.classic.JndiBuilder
> > bindJava
> > INFO: Jndi(name="java:global/Interfaces/EJBTwo")
> > Nov 28, 2013 7:21:26 PM org.apache.openejb.assembler.classic.JndiBuilder
> > bindJava
> > INFO: Jndi(name="java:global/Interfaces/EJBOne!EJBOne")
> > Nov 28, 2013 7:21:26 PM org.apache.openejb.assembler.classic.JndiBuilder
> > bindJava
> > INFO: Jndi(name="java:global/Interfaces/EJBOne")
> > Nov 28, 2013 7:21:26 PM org.apache.openejb.cdi.CdiBuilder initSingleton
> > INFO: Existing thread singleton service in SystemInstance():
> > org.apache.openejb.cdi.ThreadSingletonServiceImpl@119126ab
> > Nov 28, 2013 7:21:26 PM org.apache.openejb.cdi.OpenEJBLifecycle
> > startApplication
> > INFO: OpenWebBeans Container is starting...
> > Nov 28, 2013 7:21:26 PM org.apache.webbeans.plugins.PluginLoader startUp
> > INFO: Adding OpenWebBeansPlugin : [CdiPlugin]
> > Nov 28, 2013 7:21:26 PM org.apache.webbeans.plugins.PluginLoader startUp
> > INFO: Adding OpenWebBeansPlugin : [OpenWebBeansJsfPlugin]
> > Nov 28, 2013 7:21:26 PM org.apache.webbeans.config.BeansDeployer
> > validateInjectionPoints
> > INFO: All injection points were validated successfully.
> > Nov 28, 2013 7:21:26 PM org.apache.openejb.cdi.OpenEJBLifecycle
> > startApplication
> > INFO: OpenWebBeans Container has started, it took 55 ms.
> > Nov 28, 2013 7:21:26 PM org.apache.openejb.assembler.classic.Assembler
> > startEjbs
> > INFO: Created Ejb(deployment-id=EJBTwo, ejb-name=EJBTwo,
> container=Default
> > Stateless Container)
> > Nov 28, 2013 7:21:26 PM org.apache.openejb.assembler.classic.Assembler
> > startEjbs
> > INFO: Created Ejb(deployment-id=EJBOne, ejb-name=EJBOne,
> container=Default
> > Stateless Container)
> > Nov 28, 2013 7:21:26 PM org.apache.openejb.assembler.classic.Assembler
> > startEjbs
> > INFO: Started Ejb(deployment-id=EJBTwo, ejb-name=EJBTwo,
> container=Default
> > Stateless Container)
> > Nov 28, 2013 7:21:26 PM org.apache.openejb.assembler.classic.Assembler
> > startEjbs
> > INFO: Started Ejb(deployment-id=EJBOne, ejb-name=EJBOne,
> container=Default
> > Stateless Container)
> > Nov 28, 2013 7:21:26 PM org.apache.openejb.assembler.classic.Assembler
> > createApplication
> > INFO: Deployed
> > Application(path=/home/leoks/EclipseIndigo/workspace2/Interfaces)
> > Exception in thread "main" java.lang.ClassCastException:
> > com.sun.proxy.$Proxy31 cannot be cast to EJBTwo
> >     at Test.main(Test.java:17)
> >
> >
> >
> > []
> >
> > Leo
> >
> >
> > On Thu, Nov 28, 2013 at 6:34 PM, Jean-Louis MONTEIRO <[email protected]
> > >wrote:
> >
> > > Can you share a simple exemple to reproduce, not sure I understand.
> > >
> > > JLouis
> > >
> > >
> > > 2013/11/28 Leonardo K. Shikida <[email protected]>
> > >
> > > > 160
> > > > Em 28/11/2013 16:29, "Thiago Veronezi" <[email protected]>
> escreveu:
> > > >
> > > > > Whats the version of the server?
> > > > > 1.6.0 or trunk?
> > > > >
> > > > > []s,
> > > > > Thiago.
> > > > >
> > > > >
> > > > >
> > > > > On Thu, Nov 28, 2013 at 2:15 PM, Leonardo K. Shikida <
> > > [email protected]
> > > > > >wrote:
> > > > >
> > > > > > Hi
> > > > > >
> > > > > > Just noticed that when I code something like
> > > > > >
> > > > > >         ejbContainer = EJBContainer.createEJBContainer(p);
> > > > > >         context = ejbContainer.getContext();
> > > > > >
> > > > > >         networkDriversConfigurationFacadeEJB =
> > > > > > (NetworkDriversConfigurationFacadeEJB2)
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> context.lookup("java:global/NEAS/"+NetworkDriversConfigurationFacadeEJB2.class.getSimpleName());
> > > > > >
> > > > > > and NetworkDriversConfigurationFacadeEJB2 is a class that does
> not
> > > > > > implement any interface, it works.
> > > > > >
> > > > > > but if I implement any interface in
> > > > > NetworkDriversConfigurationFacadeEJB2,
> > > > > > I get an exception like
> > > > > >
> > > > > >  java.lang.ClassCastException: com.sun.proxy.$Proxy105 cannot be
> > cast
> > > > > to...
> > > > > >
> > > > > > is that expected?
> > > > > >
> > > > > > []
> > > > > >
> > > > > > Leo
> > > > > >
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Jean-Louis
> > >
> >
>
>
>
> --
> Jean-Louis
>

Reply via email to