You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by faizbash <fa...@gmail.com> on 2009/10/17 10:23:12 UTC

OpenEJB 3.1 as embeddable container

Hello,

I ve been trying to launch OpenEJB as an embeddable container for JUnit
tests, but I keep getting the following error:

Cannot instantiate class:
org.apache.openejb.client.LocalInitialContextFactory
javax.naming.NoInitialContextException
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:197)
...


I am using OpenEJB 3.1, and when I checked the library, the
"LocalInitialContextFactory" class 
is missing but the "RemoteInitialContextFactory" is available and I could
run the tests remotely, 
but not locally.

I ve been searching forums but could find solution to this problem. 
Can anyone please tell me what is the problem?


-- 
View this message in context: http://www.nabble.com/OpenEJB-3.1-as-embeddable-container-tp25936338p25936338.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: OpenEJB 3.1 as embeddable container

Posted by Quintin Beukes <qu...@skywalk.co.za>.
Sorry, I made a mistake with the JAR version. I'm so used to typing
3.1.2 that I did it without realizing. Since you're using 3.1.1, you
need to use openejb-core-3.1.1.jar

Quintin Beukes



On Sat, Oct 17, 2009 at 4:50 PM, Quintin Beukes <qu...@skywalk.co.za> wrote:
> You have to include openejb-core-3.1.2.jar in your test classpath as
> well. Most IDEs have a separate classpath for unit tests. This
> classpath will be appended onto your normal classpath.
>
> The reason for including core is because for the unit tests to run the
> embedded container, you are basically running a complete openejb
> instance inside of the JVM, and for this you need the core of OpenEJB
> included. Further, a LocalInitialContextFactory only makes sense in an
> embedded container or application server of some sort, because it can
> only work for EJB references inside the same JVM, which is why it's
> only included in the core jar.
>
> One more question, are you using the openejb-api jar for one/more of
> the LocalClient/RemoteClient/EjbDeployment annotations?
>
> This should solve your problem.
>
> Quintin Beukes
>
>
>
> On Sat, Oct 17, 2009 at 3:31 PM, faizbash <fa...@gmail.com> wrote:
>>
>> Quintin,
>> Thanks for the response.
>>
>> I'm using openejb-api-3.1.1.jar and openejb-client-3.1.1.jar. I am not using
>> Maven.
>> This is what I got after running
>> System.out.println(System.getProperty("java.class.path"));
>>
>>
>> /home/faizbash/NetBeansProjects/CASE_management_sys/CASE_management_sys-ejb/build/jar:
>> /home/faizbash/netbeans-6.7/java2/modules/ext/junit-3.8.2.jar:
>> /home/faizbash/netbeans-6.7/platform10/modules/ext/junit-4.5.jar:
>> /home/faizbash/lib/openejb-3.1.1/lib/openejb-api-3.1.1.jar:
>> /home/faizbash/lib/openejb-3.1.1/lib/openejb-client-3.1.1.jar
>> ...
>>
>> and lots more.
>>
>> Sorry I forgot to include my code in the previous post:
>>
>>    @Before
>>    public void bootContainer() throws Exception{
>>        Properties props = new Properties();
>>        props.put(Context.INITIAL_CONTEXT_FACTORY,
>>                "org.apache.openejb.client.LocalInitialContextFactory");
>>        Context context = new InitialContext(props);
>>        crudService = (CrudService) context.lookup("CrudServiceBean");
>>    }
>>
>>
>>
>>
>> Quintin Beukes-2 wrote:
>>>
>>> Two questions:
>>>
>>> 1. Which jars are you including in your classpath. Can you do a
>>> System.out.println(System.getProperty("java.class.path"));
>>> 2. If you are using maven, can you please paste your <dependencies>
>>> element of the POM.
>>>
>>> Quintin Beukes
>>>
>>>
>>>
>>> On Sat, Oct 17, 2009 at 10:23 AM, faizbash <fa...@gmail.com> wrote:
>>>>
>>>> Hello,
>>>>
>>>> I ve been trying to launch OpenEJB as an embeddable container for JUnit
>>>> tests, but I keep getting the following error:
>>>>
>>>> Cannot instantiate class:
>>>> org.apache.openejb.client.LocalInitialContextFactory
>>>> javax.naming.NoInitialContextException
>>>> at
>>>> javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
>>>> at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
>>>> at javax.naming.InitialContext.init(InitialContext.java:223)
>>>> at javax.naming.InitialContext.<init>(InitialContext.java:197)
>>>> ...
>>>>
>>>>
>>>> I am using OpenEJB 3.1, and when I checked the library, the
>>>> "LocalInitialContextFactory" class
>>>> is missing but the "RemoteInitialContextFactory" is available and I could
>>>> run the tests remotely,
>>>> but not locally.
>>>>
>>>> I ve been searching forums but could find solution to this problem.
>>>> Can anyone please tell me what is the problem?
>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/OpenEJB-3.1-as-embeddable-container-tp25936338p25936338.html
>>>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>
>> --
>> View this message in context: http://www.nabble.com/OpenEJB-3.1-as-embeddable-container-tp25936338p25938290.html
>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>
>>
>

Re: OpenEJB 3.1 as embeddable container

Posted by Quintin Beukes <qu...@skywalk.co.za>.
> It may sound like too much of a quick fix, but are you using the embeddable distribution and all libs with it?

It does feel like a quick fix, but for unit testing I don't think it's
too much of a problem. And in another way, for an unmanaged project
format it actually makes things easier because you can keep upgrading
your version by simply copying all jars from each new distribution,
compared to having to filter through them every time.

RE: OpenEJB 3.1 as embeddable container

Posted by "John D. Ament" <my...@gmail.com>.
It may sound like too much of a quick fix, but are you using the embeddable distribution and all libs with it?  I believe that class you're looking for is in the Geronimo-transaction jar file in your distro.

-----Original Message-----
From: faizbash [mailto:faizbash@gmail.com] 
Sent: Saturday, October 17, 2009 12:01 PM
To: users@openejb.apache.org
Subject: Re: OpenEJB 3.1 as embeddable container


I included openejb-core-3.1.2.jar and it solved the problem but I am getting
another exception now:

Attempted to load OpenEJB. OpenEJB has encountered a fatal error and cannot
be started: 
OpenEJB encoutnered an unexpected error while attempting to instantiate the
assembler.: 
org/apache/geronimo/transaction/manager/XAWork

javax.naming.NamingException
at
org.apache.openejb.client.LocalInitialContextFactory.init(LocalInitialContextFactory.java:55)
at
org.apache.openejb.client.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.
java:42)
at javax.naming.spi.NamingManager.getInitialContext(NamingManage.java:667)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:228)
...

The exception is caused by:
Context context = new InitialContext(props);

I dont think I am using the openejb-api.jar for anything.




Quintin Beukes-2 wrote:
> 
> You have to include openejb-core-3.1.2.jar in your test classpath as
> well. Most IDEs have a separate classpath for unit tests. This
> classpath will be appended onto your normal classpath.
> 
> The reason for including core is because for the unit tests to run the
> embedded container, you are basically running a complete openejb
> instance inside of the JVM, and for this you need the core of OpenEJB
> included. Further, a LocalInitialContextFactory only makes sense in an
> embedded container or application server of some sort, because it can
> only work for EJB references inside the same JVM, which is why it's
> only included in the core jar.
> 
> One more question, are you using the openejb-api jar for one/more of
> the LocalClient/RemoteClient/EjbDeployment annotations?
> 
> This should solve your problem.
> 
> Quintin Beukes
> 
> 
> 
> On Sat, Oct 17, 2009 at 3:31 PM, faizbash <fa...@gmail.com> wrote:
>>
>> Quintin,
>> Thanks for the response.
>>
>> I'm using openejb-api-3.1.1.jar and openejb-client-3.1.1.jar. I am not
>> using
>> Maven.
>> This is what I got after running
>> System.out.println(System.getProperty("java.class.path"));
>>
>>
>> /home/faizbash/NetBeansProjects/CASE_management_sys/CASE_management_sys-ejb/build/jar:
>> /home/faizbash/netbeans-6.7/java2/modules/ext/junit-3.8.2.jar:
>> /home/faizbash/netbeans-6.7/platform10/modules/ext/junit-4.5.jar:
>> /home/faizbash/lib/openejb-3.1.1/lib/openejb-api-3.1.1.jar:
>> /home/faizbash/lib/openejb-3.1.1/lib/openejb-client-3.1.1.jar
>> ...
>>
>> and lots more.
>>
>> Sorry I forgot to include my code in the previous post:
>>
>>    @Before
>>    public void bootContainer() throws Exception{
>>        Properties props = new Properties();
>>        props.put(Context.INITIAL_CONTEXT_FACTORY,
>>                "org.apache.openejb.client.LocalInitialContextFactory");
>>        Context context = new InitialContext(props);
>>        crudService = (CrudService) context.lookup("CrudServiceBean");
>>    }
>>
>>
>>
>>
>> Quintin Beukes-2 wrote:
>>>
>>> Two questions:
>>>
>>> 1. Which jars are you including in your classpath. Can you do a
>>> System.out.println(System.getProperty("java.class.path"));
>>> 2. If you are using maven, can you please paste your <dependencies>
>>> element of the POM.
>>>
>>> Quintin Beukes
>>>
>>>
>>>
>>> On Sat, Oct 17, 2009 at 10:23 AM, faizbash <fa...@gmail.com> wrote:
>>>>
>>>> Hello,
>>>>
>>>> I ve been trying to launch OpenEJB as an embeddable container for JUnit
>>>> tests, but I keep getting the following error:
>>>>
>>>> Cannot instantiate class:
>>>> org.apache.openejb.client.LocalInitialContextFactory
>>>> javax.naming.NoInitialContextException
>>>> at
>>>> javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
>>>> at
>>>> javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
>>>> at javax.naming.InitialContext.init(InitialContext.java:223)
>>>> at javax.naming.InitialContext.<init>(InitialContext.java:197)
>>>> ...
>>>>
>>>>
>>>> I am using OpenEJB 3.1, and when I checked the library, the
>>>> "LocalInitialContextFactory" class
>>>> is missing but the "RemoteInitialContextFactory" is available and I
>>>> could
>>>> run the tests remotely,
>>>> but not locally.
>>>>
>>>> I ve been searching forums but could find solution to this problem.
>>>> Can anyone please tell me what is the problem?
>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/OpenEJB-3.1-as-embeddable-container-tp25936338p25936338.html
>>>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/OpenEJB-3.1-as-embeddable-container-tp25936338p25938290.html
>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/OpenEJB-3.1-as-embeddable-container-tp25936338p25939549.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 8.5.422 / Virus Database: 270.14.20/2441 - Release Date: 10/16/09 18:39:00


Re: OpenEJB 3.1 as embeddable container

Posted by faizbash <fa...@gmail.com>.
I included all the jars and the problem is solved.
will look into Maven for future projects.

Thanks a lot.


Quintin Beukes-2 wrote:
> 
> Sorry, you said you weren't using maven. I wasn't even thinking and
> giving you dependencies like I remember I use them. Apologies.
> 
> If you can, do your future projects with maven, because then the 2nd
> level dependencies are managed by Maven. You just say openejb-client
> and openejb-core, and the rest is automatic.
> 
> Take the OpenEJB distribution, and add ALL the jars in the lib/
> directory. There are many dependencies you will end up going through
> if we try and do it like this.
> 
> Quintin Beukes
> 
> 
> 
> On Sat, Oct 17, 2009 at 6:00 PM, faizbash <fa...@gmail.com> wrote:
>>
>> I included openejb-core-3.1.2.jar and it solved the problem but I am
>> getting
>> another exception now:
>>
>> Attempted to load OpenEJB. OpenEJB has encountered a fatal error and
>> cannot
>> be started:
>> OpenEJB encoutnered an unexpected error while attempting to instantiate
>> the
>> assembler.:
>> org/apache/geronimo/transaction/manager/XAWork
>>
>> javax.naming.NamingException
>> at
>> org.apache.openejb.client.LocalInitialContextFactory.init(LocalInitialContextFactory.java:55)
>> at
>> org.apache.openejb.client.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.
>> java:42)
>> at
>> javax.naming.spi.NamingManager.getInitialContext(NamingManage.java:667)
>> at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:228)
>> ...
>>
>> The exception is caused by:
>> Context context = new InitialContext(props);
>>
>> I dont think I am using the openejb-api.jar for anything.
>>
>>
>>
>>
>> Quintin Beukes-2 wrote:
>>>
>>> You have to include openejb-core-3.1.2.jar in your test classpath as
>>> well. Most IDEs have a separate classpath for unit tests. This
>>> classpath will be appended onto your normal classpath.
>>>
>>> The reason for including core is because for the unit tests to run the
>>> embedded container, you are basically running a complete openejb
>>> instance inside of the JVM, and for this you need the core of OpenEJB
>>> included. Further, a LocalInitialContextFactory only makes sense in an
>>> embedded container or application server of some sort, because it can
>>> only work for EJB references inside the same JVM, which is why it's
>>> only included in the core jar.
>>>
>>> One more question, are you using the openejb-api jar for one/more of
>>> the LocalClient/RemoteClient/EjbDeployment annotations?
>>>
>>> This should solve your problem.
>>>
>>> Quintin Beukes
>>>
>>>
>>>
>>> On Sat, Oct 17, 2009 at 3:31 PM, faizbash <fa...@gmail.com> wrote:
>>>>
>>>> Quintin,
>>>> Thanks for the response.
>>>>
>>>> I'm using openejb-api-3.1.1.jar and openejb-client-3.1.1.jar. I am not
>>>> using
>>>> Maven.
>>>> This is what I got after running
>>>> System.out.println(System.getProperty("java.class.path"));
>>>>
>>>>
>>>> /home/faizbash/NetBeansProjects/CASE_management_sys/CASE_management_sys-ejb/build/jar:
>>>> /home/faizbash/netbeans-6.7/java2/modules/ext/junit-3.8.2.jar:
>>>> /home/faizbash/netbeans-6.7/platform10/modules/ext/junit-4.5.jar:
>>>> /home/faizbash/lib/openejb-3.1.1/lib/openejb-api-3.1.1.jar:
>>>> /home/faizbash/lib/openejb-3.1.1/lib/openejb-client-3.1.1.jar
>>>> ...
>>>>
>>>> and lots more.
>>>>
>>>> Sorry I forgot to include my code in the previous post:
>>>>
>>>>    @Before
>>>>    public void bootContainer() throws Exception{
>>>>        Properties props = new Properties();
>>>>        props.put(Context.INITIAL_CONTEXT_FACTORY,
>>>>                "org.apache.openejb.client.LocalInitialContextFactory");
>>>>        Context context = new InitialContext(props);
>>>>        crudService = (CrudService) context.lookup("CrudServiceBean");
>>>>    }
>>>>
>>>>
>>>>
>>>>
>>>> Quintin Beukes-2 wrote:
>>>>>
>>>>> Two questions:
>>>>>
>>>>> 1. Which jars are you including in your classpath. Can you do a
>>>>> System.out.println(System.getProperty("java.class.path"));
>>>>> 2. If you are using maven, can you please paste your <dependencies>
>>>>> element of the POM.
>>>>>
>>>>> Quintin Beukes
>>>>>
>>>>>
>>>>>
>>>>> On Sat, Oct 17, 2009 at 10:23 AM, faizbash <fa...@gmail.com> wrote:
>>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> I ve been trying to launch OpenEJB as an embeddable container for
>>>>>> JUnit
>>>>>> tests, but I keep getting the following error:
>>>>>>
>>>>>> Cannot instantiate class:
>>>>>> org.apache.openejb.client.LocalInitialContextFactory
>>>>>> javax.naming.NoInitialContextException
>>>>>> at
>>>>>> javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
>>>>>> at
>>>>>> javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
>>>>>> at javax.naming.InitialContext.init(InitialContext.java:223)
>>>>>> at javax.naming.InitialContext.<init>(InitialContext.java:197)
>>>>>> ...
>>>>>>
>>>>>>
>>>>>> I am using OpenEJB 3.1, and when I checked the library, the
>>>>>> "LocalInitialContextFactory" class
>>>>>> is missing but the "RemoteInitialContextFactory" is available and I
>>>>>> could
>>>>>> run the tests remotely,
>>>>>> but not locally.
>>>>>>
>>>>>> I ve been searching forums but could find solution to this problem.
>>>>>> Can anyone please tell me what is the problem?
>>>>>>
>>>>>>
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://www.nabble.com/OpenEJB-3.1-as-embeddable-container-tp25936338p25936338.html
>>>>>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/OpenEJB-3.1-as-embeddable-container-tp25936338p25938290.html
>>>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/OpenEJB-3.1-as-embeddable-container-tp25936338p25939549.html
>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/OpenEJB-3.1-as-embeddable-container-tp25936338p25939915.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: OpenEJB 3.1 as embeddable container

Posted by Quintin Beukes <qu...@skywalk.co.za>.
Sorry, you said you weren't using maven. I wasn't even thinking and
giving you dependencies like I remember I use them. Apologies.

If you can, do your future projects with maven, because then the 2nd
level dependencies are managed by Maven. You just say openejb-client
and openejb-core, and the rest is automatic.

Take the OpenEJB distribution, and add ALL the jars in the lib/
directory. There are many dependencies you will end up going through
if we try and do it like this.

Quintin Beukes



On Sat, Oct 17, 2009 at 6:00 PM, faizbash <fa...@gmail.com> wrote:
>
> I included openejb-core-3.1.2.jar and it solved the problem but I am getting
> another exception now:
>
> Attempted to load OpenEJB. OpenEJB has encountered a fatal error and cannot
> be started:
> OpenEJB encoutnered an unexpected error while attempting to instantiate the
> assembler.:
> org/apache/geronimo/transaction/manager/XAWork
>
> javax.naming.NamingException
> at
> org.apache.openejb.client.LocalInitialContextFactory.init(LocalInitialContextFactory.java:55)
> at
> org.apache.openejb.client.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.
> java:42)
> at javax.naming.spi.NamingManager.getInitialContext(NamingManage.java:667)
> at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:228)
> ...
>
> The exception is caused by:
> Context context = new InitialContext(props);
>
> I dont think I am using the openejb-api.jar for anything.
>
>
>
>
> Quintin Beukes-2 wrote:
>>
>> You have to include openejb-core-3.1.2.jar in your test classpath as
>> well. Most IDEs have a separate classpath for unit tests. This
>> classpath will be appended onto your normal classpath.
>>
>> The reason for including core is because for the unit tests to run the
>> embedded container, you are basically running a complete openejb
>> instance inside of the JVM, and for this you need the core of OpenEJB
>> included. Further, a LocalInitialContextFactory only makes sense in an
>> embedded container or application server of some sort, because it can
>> only work for EJB references inside the same JVM, which is why it's
>> only included in the core jar.
>>
>> One more question, are you using the openejb-api jar for one/more of
>> the LocalClient/RemoteClient/EjbDeployment annotations?
>>
>> This should solve your problem.
>>
>> Quintin Beukes
>>
>>
>>
>> On Sat, Oct 17, 2009 at 3:31 PM, faizbash <fa...@gmail.com> wrote:
>>>
>>> Quintin,
>>> Thanks for the response.
>>>
>>> I'm using openejb-api-3.1.1.jar and openejb-client-3.1.1.jar. I am not
>>> using
>>> Maven.
>>> This is what I got after running
>>> System.out.println(System.getProperty("java.class.path"));
>>>
>>>
>>> /home/faizbash/NetBeansProjects/CASE_management_sys/CASE_management_sys-ejb/build/jar:
>>> /home/faizbash/netbeans-6.7/java2/modules/ext/junit-3.8.2.jar:
>>> /home/faizbash/netbeans-6.7/platform10/modules/ext/junit-4.5.jar:
>>> /home/faizbash/lib/openejb-3.1.1/lib/openejb-api-3.1.1.jar:
>>> /home/faizbash/lib/openejb-3.1.1/lib/openejb-client-3.1.1.jar
>>> ...
>>>
>>> and lots more.
>>>
>>> Sorry I forgot to include my code in the previous post:
>>>
>>>    @Before
>>>    public void bootContainer() throws Exception{
>>>        Properties props = new Properties();
>>>        props.put(Context.INITIAL_CONTEXT_FACTORY,
>>>                "org.apache.openejb.client.LocalInitialContextFactory");
>>>        Context context = new InitialContext(props);
>>>        crudService = (CrudService) context.lookup("CrudServiceBean");
>>>    }
>>>
>>>
>>>
>>>
>>> Quintin Beukes-2 wrote:
>>>>
>>>> Two questions:
>>>>
>>>> 1. Which jars are you including in your classpath. Can you do a
>>>> System.out.println(System.getProperty("java.class.path"));
>>>> 2. If you are using maven, can you please paste your <dependencies>
>>>> element of the POM.
>>>>
>>>> Quintin Beukes
>>>>
>>>>
>>>>
>>>> On Sat, Oct 17, 2009 at 10:23 AM, faizbash <fa...@gmail.com> wrote:
>>>>>
>>>>> Hello,
>>>>>
>>>>> I ve been trying to launch OpenEJB as an embeddable container for JUnit
>>>>> tests, but I keep getting the following error:
>>>>>
>>>>> Cannot instantiate class:
>>>>> org.apache.openejb.client.LocalInitialContextFactory
>>>>> javax.naming.NoInitialContextException
>>>>> at
>>>>> javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
>>>>> at
>>>>> javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
>>>>> at javax.naming.InitialContext.init(InitialContext.java:223)
>>>>> at javax.naming.InitialContext.<init>(InitialContext.java:197)
>>>>> ...
>>>>>
>>>>>
>>>>> I am using OpenEJB 3.1, and when I checked the library, the
>>>>> "LocalInitialContextFactory" class
>>>>> is missing but the "RemoteInitialContextFactory" is available and I
>>>>> could
>>>>> run the tests remotely,
>>>>> but not locally.
>>>>>
>>>>> I ve been searching forums but could find solution to this problem.
>>>>> Can anyone please tell me what is the problem?
>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/OpenEJB-3.1-as-embeddable-container-tp25936338p25936338.html
>>>>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/OpenEJB-3.1-as-embeddable-container-tp25936338p25938290.html
>>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/OpenEJB-3.1-as-embeddable-container-tp25936338p25939549.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>

Re: OpenEJB 3.1 as embeddable container

Posted by faizbash <fa...@gmail.com>.
I included openejb-core-3.1.2.jar and it solved the problem but I am getting
another exception now:

Attempted to load OpenEJB. OpenEJB has encountered a fatal error and cannot
be started: 
OpenEJB encoutnered an unexpected error while attempting to instantiate the
assembler.: 
org/apache/geronimo/transaction/manager/XAWork

javax.naming.NamingException
at
org.apache.openejb.client.LocalInitialContextFactory.init(LocalInitialContextFactory.java:55)
at
org.apache.openejb.client.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.
java:42)
at javax.naming.spi.NamingManager.getInitialContext(NamingManage.java:667)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:228)
...

The exception is caused by:
Context context = new InitialContext(props);

I dont think I am using the openejb-api.jar for anything.




Quintin Beukes-2 wrote:
> 
> You have to include openejb-core-3.1.2.jar in your test classpath as
> well. Most IDEs have a separate classpath for unit tests. This
> classpath will be appended onto your normal classpath.
> 
> The reason for including core is because for the unit tests to run the
> embedded container, you are basically running a complete openejb
> instance inside of the JVM, and for this you need the core of OpenEJB
> included. Further, a LocalInitialContextFactory only makes sense in an
> embedded container or application server of some sort, because it can
> only work for EJB references inside the same JVM, which is why it's
> only included in the core jar.
> 
> One more question, are you using the openejb-api jar for one/more of
> the LocalClient/RemoteClient/EjbDeployment annotations?
> 
> This should solve your problem.
> 
> Quintin Beukes
> 
> 
> 
> On Sat, Oct 17, 2009 at 3:31 PM, faizbash <fa...@gmail.com> wrote:
>>
>> Quintin,
>> Thanks for the response.
>>
>> I'm using openejb-api-3.1.1.jar and openejb-client-3.1.1.jar. I am not
>> using
>> Maven.
>> This is what I got after running
>> System.out.println(System.getProperty("java.class.path"));
>>
>>
>> /home/faizbash/NetBeansProjects/CASE_management_sys/CASE_management_sys-ejb/build/jar:
>> /home/faizbash/netbeans-6.7/java2/modules/ext/junit-3.8.2.jar:
>> /home/faizbash/netbeans-6.7/platform10/modules/ext/junit-4.5.jar:
>> /home/faizbash/lib/openejb-3.1.1/lib/openejb-api-3.1.1.jar:
>> /home/faizbash/lib/openejb-3.1.1/lib/openejb-client-3.1.1.jar
>> ...
>>
>> and lots more.
>>
>> Sorry I forgot to include my code in the previous post:
>>
>>    @Before
>>    public void bootContainer() throws Exception{
>>        Properties props = new Properties();
>>        props.put(Context.INITIAL_CONTEXT_FACTORY,
>>                "org.apache.openejb.client.LocalInitialContextFactory");
>>        Context context = new InitialContext(props);
>>        crudService = (CrudService) context.lookup("CrudServiceBean");
>>    }
>>
>>
>>
>>
>> Quintin Beukes-2 wrote:
>>>
>>> Two questions:
>>>
>>> 1. Which jars are you including in your classpath. Can you do a
>>> System.out.println(System.getProperty("java.class.path"));
>>> 2. If you are using maven, can you please paste your <dependencies>
>>> element of the POM.
>>>
>>> Quintin Beukes
>>>
>>>
>>>
>>> On Sat, Oct 17, 2009 at 10:23 AM, faizbash <fa...@gmail.com> wrote:
>>>>
>>>> Hello,
>>>>
>>>> I ve been trying to launch OpenEJB as an embeddable container for JUnit
>>>> tests, but I keep getting the following error:
>>>>
>>>> Cannot instantiate class:
>>>> org.apache.openejb.client.LocalInitialContextFactory
>>>> javax.naming.NoInitialContextException
>>>> at
>>>> javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
>>>> at
>>>> javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
>>>> at javax.naming.InitialContext.init(InitialContext.java:223)
>>>> at javax.naming.InitialContext.<init>(InitialContext.java:197)
>>>> ...
>>>>
>>>>
>>>> I am using OpenEJB 3.1, and when I checked the library, the
>>>> "LocalInitialContextFactory" class
>>>> is missing but the "RemoteInitialContextFactory" is available and I
>>>> could
>>>> run the tests remotely,
>>>> but not locally.
>>>>
>>>> I ve been searching forums but could find solution to this problem.
>>>> Can anyone please tell me what is the problem?
>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/OpenEJB-3.1-as-embeddable-container-tp25936338p25936338.html
>>>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/OpenEJB-3.1-as-embeddable-container-tp25936338p25938290.html
>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/OpenEJB-3.1-as-embeddable-container-tp25936338p25939549.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: OpenEJB 3.1 as embeddable container

Posted by Quintin Beukes <qu...@skywalk.co.za>.
You have to include openejb-core-3.1.2.jar in your test classpath as
well. Most IDEs have a separate classpath for unit tests. This
classpath will be appended onto your normal classpath.

The reason for including core is because for the unit tests to run the
embedded container, you are basically running a complete openejb
instance inside of the JVM, and for this you need the core of OpenEJB
included. Further, a LocalInitialContextFactory only makes sense in an
embedded container or application server of some sort, because it can
only work for EJB references inside the same JVM, which is why it's
only included in the core jar.

One more question, are you using the openejb-api jar for one/more of
the LocalClient/RemoteClient/EjbDeployment annotations?

This should solve your problem.

Quintin Beukes



On Sat, Oct 17, 2009 at 3:31 PM, faizbash <fa...@gmail.com> wrote:
>
> Quintin,
> Thanks for the response.
>
> I'm using openejb-api-3.1.1.jar and openejb-client-3.1.1.jar. I am not using
> Maven.
> This is what I got after running
> System.out.println(System.getProperty("java.class.path"));
>
>
> /home/faizbash/NetBeansProjects/CASE_management_sys/CASE_management_sys-ejb/build/jar:
> /home/faizbash/netbeans-6.7/java2/modules/ext/junit-3.8.2.jar:
> /home/faizbash/netbeans-6.7/platform10/modules/ext/junit-4.5.jar:
> /home/faizbash/lib/openejb-3.1.1/lib/openejb-api-3.1.1.jar:
> /home/faizbash/lib/openejb-3.1.1/lib/openejb-client-3.1.1.jar
> ...
>
> and lots more.
>
> Sorry I forgot to include my code in the previous post:
>
>    @Before
>    public void bootContainer() throws Exception{
>        Properties props = new Properties();
>        props.put(Context.INITIAL_CONTEXT_FACTORY,
>                "org.apache.openejb.client.LocalInitialContextFactory");
>        Context context = new InitialContext(props);
>        crudService = (CrudService) context.lookup("CrudServiceBean");
>    }
>
>
>
>
> Quintin Beukes-2 wrote:
>>
>> Two questions:
>>
>> 1. Which jars are you including in your classpath. Can you do a
>> System.out.println(System.getProperty("java.class.path"));
>> 2. If you are using maven, can you please paste your <dependencies>
>> element of the POM.
>>
>> Quintin Beukes
>>
>>
>>
>> On Sat, Oct 17, 2009 at 10:23 AM, faizbash <fa...@gmail.com> wrote:
>>>
>>> Hello,
>>>
>>> I ve been trying to launch OpenEJB as an embeddable container for JUnit
>>> tests, but I keep getting the following error:
>>>
>>> Cannot instantiate class:
>>> org.apache.openejb.client.LocalInitialContextFactory
>>> javax.naming.NoInitialContextException
>>> at
>>> javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
>>> at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
>>> at javax.naming.InitialContext.init(InitialContext.java:223)
>>> at javax.naming.InitialContext.<init>(InitialContext.java:197)
>>> ...
>>>
>>>
>>> I am using OpenEJB 3.1, and when I checked the library, the
>>> "LocalInitialContextFactory" class
>>> is missing but the "RemoteInitialContextFactory" is available and I could
>>> run the tests remotely,
>>> but not locally.
>>>
>>> I ve been searching forums but could find solution to this problem.
>>> Can anyone please tell me what is the problem?
>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/OpenEJB-3.1-as-embeddable-container-tp25936338p25936338.html
>>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/OpenEJB-3.1-as-embeddable-container-tp25936338p25938290.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>

Re: OpenEJB 3.1 as embeddable container

Posted by faizbash <fa...@gmail.com>.
Quintin,
Thanks for the response.

I'm using openejb-api-3.1.1.jar and openejb-client-3.1.1.jar. I am not using
Maven.
This is what I got after running
System.out.println(System.getProperty("java.class.path"));


/home/faizbash/NetBeansProjects/CASE_management_sys/CASE_management_sys-ejb/build/jar:
/home/faizbash/netbeans-6.7/java2/modules/ext/junit-3.8.2.jar:
/home/faizbash/netbeans-6.7/platform10/modules/ext/junit-4.5.jar:
/home/faizbash/lib/openejb-3.1.1/lib/openejb-api-3.1.1.jar:
/home/faizbash/lib/openejb-3.1.1/lib/openejb-client-3.1.1.jar
...

and lots more.

Sorry I forgot to include my code in the previous post:

    @Before
    public void bootContainer() throws Exception{
        Properties props = new Properties();
        props.put(Context.INITIAL_CONTEXT_FACTORY,
                "org.apache.openejb.client.LocalInitialContextFactory");
        Context context = new InitialContext(props);
        crudService = (CrudService) context.lookup("CrudServiceBean");        
    }




Quintin Beukes-2 wrote:
> 
> Two questions:
> 
> 1. Which jars are you including in your classpath. Can you do a
> System.out.println(System.getProperty("java.class.path"));
> 2. If you are using maven, can you please paste your <dependencies>
> element of the POM.
> 
> Quintin Beukes
> 
> 
> 
> On Sat, Oct 17, 2009 at 10:23 AM, faizbash <fa...@gmail.com> wrote:
>>
>> Hello,
>>
>> I ve been trying to launch OpenEJB as an embeddable container for JUnit
>> tests, but I keep getting the following error:
>>
>> Cannot instantiate class:
>> org.apache.openejb.client.LocalInitialContextFactory
>> javax.naming.NoInitialContextException
>> at
>> javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
>> at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
>> at javax.naming.InitialContext.init(InitialContext.java:223)
>> at javax.naming.InitialContext.<init>(InitialContext.java:197)
>> ...
>>
>>
>> I am using OpenEJB 3.1, and when I checked the library, the
>> "LocalInitialContextFactory" class
>> is missing but the "RemoteInitialContextFactory" is available and I could
>> run the tests remotely,
>> but not locally.
>>
>> I ve been searching forums but could find solution to this problem.
>> Can anyone please tell me what is the problem?
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/OpenEJB-3.1-as-embeddable-container-tp25936338p25936338.html
>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/OpenEJB-3.1-as-embeddable-container-tp25936338p25938290.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: OpenEJB 3.1 as embeddable container

Posted by Quintin Beukes <qu...@skywalk.co.za>.
Two questions:

1. Which jars are you including in your classpath. Can you do a
System.out.println(System.getProperty("java.class.path"));
2. If you are using maven, can you please paste your <dependencies>
element of the POM.

Quintin Beukes



On Sat, Oct 17, 2009 at 10:23 AM, faizbash <fa...@gmail.com> wrote:
>
> Hello,
>
> I ve been trying to launch OpenEJB as an embeddable container for JUnit
> tests, but I keep getting the following error:
>
> Cannot instantiate class:
> org.apache.openejb.client.LocalInitialContextFactory
> javax.naming.NoInitialContextException
> at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
> at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
> at javax.naming.InitialContext.init(InitialContext.java:223)
> at javax.naming.InitialContext.<init>(InitialContext.java:197)
> ...
>
>
> I am using OpenEJB 3.1, and when I checked the library, the
> "LocalInitialContextFactory" class
> is missing but the "RemoteInitialContextFactory" is available and I could
> run the tests remotely,
> but not locally.
>
> I ve been searching forums but could find solution to this problem.
> Can anyone please tell me what is the problem?
>
>
> --
> View this message in context: http://www.nabble.com/OpenEJB-3.1-as-embeddable-container-tp25936338p25936338.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>