History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: OPENEJB-57
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: David Blevins
Reporter: Nader Aeinehchi
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
OpenEJB

OpenEJB does not work as embedded container in JUnit test under Eclipse

Created: 12/Sep/05 10:10 AM   Updated: 21/Sep/05 03:57 AM  Due: 25/Sep/06
Component/s: None
Affects Version/s: 1.0 beta 1
Fix Version/s: 1.0 beta 1

Time Tracking:
Not Specified

File Attachments:
  Size
Zip Archive javazone.zip 2005-09-21 03:56 AM Nader Aeinehchi 845 kb
Zip Archive javazone.zip 2005-09-18 02:37 AM Nader Aeinehchi 1.15 Mb
Environment: Linux, Eclipse, Sun JDK 1.5.04


 Description  « Hide
I used to successfully launch OpenEJB 0.9.2 from Eclipse in my JUnit tests. But it does not work under OpenEJB 1.0Beta. The following is the command line argument that is supplied to OpenEJB:
-Djava.naming.factory.initial=org.openejb.client.LocalInitialContextFactory
-Djava.naming.provider.url=ormi://localhost:4201
-Dopenejb.home=/home/et4045/java/openejb/openejb-0.9.2
-Dopenejb.configuration=/home/et4045/java/openejb/openejb-0.9.2/conf/openejb.conf
-Dopenejb.loader=embed
-Dopenejb.localcopy=true

I have tried all variants of the above, absolute and relative paths, but it does not work.

The JUnits are stored on development directory:
/home/et4045/dev/workspaces/javazone/javazone/bin

Apparently, the newer version of OpenEJB does not understand the home property.

Here is the error message:
-------------------------------------------------------------------------------------
Failed to configure log4j. /home/et4045/dev/workspaces/javazone/javazone/conf/logging.conf (No such file or directory)
OpenEJB 1.0-beta1 build: 20050829-2233
http://www.openejb.org
log4j:WARN No appenders could be found for logger (OpenEJB.startup).
log4j:WARN Please initialize the log4j system properly.
resources 1
javax.naming.NamingException: Attempted to load OpenEJB. Cannot load the container Default CMP Container. Received message: Cannot locate the Global_TX_Database file. The path specified is not a valid file: /home/et4045/dev/workspaces/javazone/javazone/conf/default.cmp_global_tx_database.xml [Root exception is org.openejb.OpenEJBException: Cannot load the container Default CMP Container. Received message: Cannot locate the Global_TX_Database file. The path specified is not a valid file: /home/et4045/dev/workspaces/javazone/javazone/conf/default.cmp_global_tx_database.xml]
at org.openejb.client.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:74)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:175)
at EJBWriterTest.testWrite(EJBWriterTest.java:21)
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 junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.openejb.OpenEJBException: Cannot load the container Default CMP Container. Received message: Cannot locate the Global_TX_Database file. The path specified is not a valid file: /home/et4045/dev/workspaces/javazone/javazone/conf/default.cmp_global_tx_database.xml
at org.openejb.alt.assembler.classic.ContainerBuilder.buildContainer(ContainerBuilder.java:176)
at org.openejb.alt.assembler.classic.ContainerBuilder.build(ContainerBuilder.java:124)
at org.openejb.alt.assembler.classic.AssemblerTool.assembleContainers(AssemblerTool.java:127)
at org.openejb.alt.assembler.classic.Assembler.buildContainerSystem(Assembler.java:227)
at org.openejb.alt.assembler.classic.Assembler.build(Assembler.java:153)
at org.openejb.OpenEJB.init(OpenEJB.java:243)
at org.openejb.OpenEJB.init(OpenEJB.java:129)
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.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:76)
at org.openejb.client.LocalInitialContextFactory.init(LocalInitialContextFactory.java:86)
at org.openejb.client.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:72)
... 20 more

-------------------------------------------------------------------------------------


 All   Comments   Work Log   Change History   Subversion Commits   FishEye      Sort Order: Ascending order - Click to sort in descending order
Nader Aeinehchi - 12/Sep/05 10:27 AM
Hi

Sorry, for mispelled path:

In OpenEJB 1.0Beta, of course, I use the following path:
-Djava.naming.factory.initial=org.openejb.client.LocalInitialContextFactory
-Djava.naming.provider.url=ormi://localhost:4201
-Dopenejb.home=/home/et4045/java/openejb/openejb-1.0-beta1
-Dopenejb.configuration=/home/et4045/java/openejb/openejb-1.0-beta1/conf/openejb.conf
-Dopenejb.loader=embed
-Dopenejb.localcopy=true

Nader Aeinehchi - 13/Sep/05 04:38 AM
Hello

I found a workaround for my problem. Below is the workaround. But I still like to report this as a bug since obvsiosly openejb.home nor openejb.base does not function properly when openejb is embedded in another application.

The workaroud:
In transaction configuration files (global_tx_database.xml, local_tx_database.xml) use absolute file path. This solves the problem except for logging.conf

David Blevins - 16/Sep/05 11:49 AM
Hi Nader,

If you want to attach a small sample eclipse project that we could try, we'd be happy to workout these issue and get this running smoothly for you.

Even better if you'd be ok donating small sample, we could check it in under our examples directory so others could see how it's done.

Thanks!
David

Nader Aeinehchi - 18/Sep/05 02:38 AM
I have created a small demo eclipse project which was used under JavaZone, September, Norway.

This demo compares POJO and EJB development. It uses Apache Derby database as backend and XStream for automizing input data.

See index.html under docs directory for information about how to configure and use the demo in the attached file javazone.zip

David Blevins - 19/Sep/05 06:29 AM
What is the value of these two .classpath entries?

<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/hsqldb"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/DerbyClient"/>


David Blevins - 19/Sep/05 06:32 AM
Never mind... I wasn't reading directions, "See index.html under docs directory...."

David Blevins - 20/Sep/05 10:51 AM
Hi Nader,

Ok, I found what was going on with the system properties and fixed it. I've put together a new set of binaries for you to try.

    http://openejb.org/unstable/v1.0-20050920/openejb-1.0-20050920.zip
    http://openejb.org/Latest+Unstable

Also, the property handling in 1.0-x is way better than in 0.9.2. You *should* be able to get by with just the following System properties:
-Djava.naming.factory.initial=org.openejb.client.LocalInitialContextFactory
-Dopenejb.home=/home/et4045/java/openejb/openejb-1.0-20050920

We have also noticed that Castor sometimes has an issue finding the mapping.xml file listed in the local and global database.xml files. If you run into this, just delete any directory prefixes from the mapping file path and Castor will assume that the mapping file is right next to the database.xml file and locate it safely.

In other words, this:
  - <mapping href="conf/default.cmp_mapping.xml" />
  + <mapping href="default.cmp_mapping.xml" />

Let us know if you have more issues. We'll keep this Jira Item open till you are fully running again.

Nader Aeinehchi - 21/Sep/05 03:56 AM
Hi David

Thanks for fixing the problem.

This demo applies to openejb-1.0-20050920 and higher.
Updated with the most recent configuration file. The documentation is updated.

Only the following arguments are needed:
-Djava.naming.factory.initial=org.openejb.client.LocalInitialContextFactory
-Dopenejb.home=/home/et4045/java/openejb/openejb-1.0-20050920

And there is no need to provide absolute path in the configuration files anymore.

Nader Aeinehchi - 21/Sep/05 03:57 AM
The problem has been fixed as of openejb-1.0-20050920 build.