You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Christopher Gardner <ch...@gmail.com> on 2009/07/29 19:04:55 UTC

Embedded Eclipse Configuration Issue

I'm successfully using OpenEJB as an embedded container for testing
purposes only.  Production deployments are going to another container
to be determined.

I have the following eclipse directory structure:

hca
+ conf/            # includes persistence.xml, dozer mapping files, etc.

+ openejb-home/
   + conf/        # empty before running a unit test

+ src/
  + java/            # includes many subdirectories

+ test/
   + conf/
     + openejb.xml
   + java/   # includes many subdirectories

When I set up the InitialContext, I also include the following properties:

        properties.setProperty("openejb.home", "openejb-home");
        properties.setProperty("openejb.base", "openejb-home");
        properties.setProperty("openejb.configuration",
"openejb.home/../test/conf/openejb.xml");

Everything runs fine.  The openejb.xml configuration file is found in
test/conf.  The generated properties and config files (e.g.,
logging.properties, cxf.properties) are automatically created in
openejb-home/conf.  Also, the temp directory is created under
openejb-home.  I connect to an external database, so there is no db
directory.

However, I was expecting all openejb files and directories to be
created under openejb-home, but only the aforementioned ones were.
Additionally, there is another logging.properties being created under
my main conf directory (i.e., hca/conf) and the logs directory is
being created under hca.

Why does OpenEJB seem to ignore my home and base overrides?  I don't
want to change the name of my own conf directory because it's our
standard.  Also, if I created my logging.properties file under conf,
OpenEJB would overwrite it.

Any ideas?

Thanks.

Re: Embedded Eclipse Configuration Issue

Posted by David Blevins <da...@visi.com>.
On Jul 29, 2009, at 10:04 AM, Christopher Gardner wrote:

> I'm successfully using OpenEJB as an embedded container for testing
> purposes only.  Production deployments are going to another container
> to be determined.
>
> I have the following eclipse directory structure:
>
> hca
> + conf/            # includes persistence.xml, dozer mapping files,  
> etc.
>
> + openejb-home/
>   + conf/        # empty before running a unit test
>
> + src/
>  + java/            # includes many subdirectories
>
> + test/
>   + conf/
>     + openejb.xml
>   + java/   # includes many subdirectories
>
> When I set up the InitialContext, I also include the following  
> properties:
>
>         properties.setProperty("openejb.home", "openejb-home");
>         properties.setProperty("openejb.base", "openejb-home");
>         properties.setProperty("openejb.configuration",
> "openejb.home/../test/conf/openejb.xml");
>
> Everything runs fine.  The openejb.xml configuration file is found in
> test/conf.  The generated properties and config files (e.g.,
> logging.properties, cxf.properties) are automatically created in
> openejb-home/conf.  Also, the temp directory is created under
> openejb-home.  I connect to an external database, so there is no db
> directory.
>
> However, I was expecting all openejb files and directories to be
> created under openejb-home, but only the aforementioned ones were.
> Additionally, there is another logging.properties being created under
> my main conf directory (i.e., hca/conf) and the logs directory is
> being created under hca.

Right, I would also expect these three files in conf/

       login.config
       users.properties
       groups.properties

Is it possible you can post the startup log output?

If you can set the "log4j.category.OpenEJB.security" log category to  
"DEBUG" that should print the location of the users.properties and  
groups.properties files, which will help us see where they are ending  
up.  You can set that via the InitialContext properties or as a system  
property (or in your logging.properties file, but it sounds like that  
is getting overwritten).

> Why does OpenEJB seem to ignore my home and base overrides?  I don't
> want to change the name of my own conf directory because it's our
> standard.  Also, if I created my logging.properties file under conf,
> OpenEJB would overwrite it.

That is very interesting.  Our check for the logging.properties file  
uses this logic:

     File confDir = SystemInstance.get().getBase().getDirectory("conf");
     File loggingPropertiesFile = new File(confDir,  
LOGGING_PROPERTIES_FILE);

So all should be good if openejb.base (or openejb.home) is set.  The  
other strange thing is I was pretty certain we didn't aggressively  
create a "logs" directory if you didn't already have one and instead  
resorted to logging to System.out when there wasn't a "logs" dir under  
openejb.base.

On a side note, you shouldn't need to setup a directory structure to  
get configuration control if you don't want to.  Everything you can  
configure in an openejb.xml file and logging.properties file can be  
configured in properties that are in a jndi.properties file in the  
classpath, feed to the InitialContext as properties, or set as system  
properties.  And then you really only need to specify what you want  
handled differently than what OpenEJB would normally do.

Here's an example jndi.properties file you could include in your  
classpath:


  --[jndi.properties]--
   # set the initial context factory
   java.naming.factory.initial =  
org.apache.openejb.client.LocalInitialContextFactory

   # change some logging
   log4j.category.OpenEJB.options = debug
   log4j.category.OpenEJB.startup = debug
   log4j.category.OpenEJB.startup.config = debug

   # create some resources
   movieDatabase = new://Resource?type=DataSource
   movieDatabase.JdbcDriver = org.hsqldb.jdbcDriver
   movieDatabase.JdbcUrl = jdbc:hsqldb:mem:moviedb

   # override properties on your "movie-unit" persistence unit
   movie-unit.hibernate.dialect = org.hibernate.dialect.HSQLDialect

   # set some openejb flags
   openejb.jndiname.format = {ejbName}/{interfaceClass}
   openejb.descriptors.output = true
   openejb.validation.output.level = verbose
  ---------------------

Hope this helps!  Happy to take a look at your log info when you get it.

-David