car-maven-plugin and Geronimo Bean references problem

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

car-maven-plugin and Geronimo Bean references problem

rwengr
I am packaging my first Geronimo plugin in a CAR file.  I am using car-maven-plugin.

The CAR packaging will not complete successfully.  The essence of the error is:

Caused by: org.apache.geronimo.common.DeploymentException: No reference named GeronimoServerInfo in gbean org.apache.geronimo.plugins/directory/1.5.4      /car?ServiceModule=org.apache.geronimo.plugins/directory/1.5.4/car,j2eeType=GBean,name=DirectoryService

My deployment plan is shown below.

I think the root cause of the problem is that maven boots the Geronimo kernel and runs the plugin to do the packaging.  But there will be no external gbean to reference until I start the plugin on a real instance of the server; not the maven bootstrapped one.

If I remove the thread from the source code that runs my gbean, packaging is OK.  But of course, I don't have anything useful.

How do I make external references available to my plugin when it is being activated by car-maven-plugin?  Or should I be taking another approach?

Thanks in advance.

GERONIMO DEPLOYMENT PLAN

<module xmlns="http://geronimo.apache.org/xml/ns/deployment-1.2">
  <environment>
      <moduleId>
        <groupId>org.apache.geronimo.plugins</groupId>
        <artifactId>directory</artifactId>
        <version>1.5.4</version>
        <type>car</type>
      </moduleId>
      <dependencies/>
      <hidden-classes/>
      <non-overridable-classes/>
      <private-classes/>
  </environment>
  <gbean name="ServerInfo" class="org.apache.geronimo.system.serverinfo.BasicServerInfo">
      <attribute name="useSystemProperties">true</attribute>
  </gbean>
  <gbean name="DirectoryService" class="org.apache.geronimo.directory.wasce.DirectoryGBean">
      <attribute name="configFile">var/directory/server.xml</attribute>
      <attribute name="workingDir">var/directory</attribute>
      <reference name="GeronimoServerInfo"><name>ServerInfo</name></reference>
  </gbean>
</module>
Reply | Threaded
Open this post in threaded view
|

Re: car-maven-plugin and Geronimo Bean references problem - UPDATE

rwengr
The root cause of this problem was traced back to the presence of this code in the gbean.

class SynchWorker implements Runnable {
  final Object lock = new Object();
  boolean stop;
       
  public void run() {
    while ( !stop ) {
      synchronized ( lock ) {
        try {
          lock.wait( apacheDS.getSynchPeriodMillis() );
        } catch ( InterruptedException e ) {
          log.warn( "SynchWorker failed to wait on lock.", e );
        }
      }
      try {
        apacheDS.getDirectoryService().sync();
      } catch ( Exception e ) {
        log.error( "SynchWorker failed to synch directory.", e );
      }
    }
  }
}

First of all, the Junit passes.  All indications are the problem is related to a class load issue that must occur when car-maven-plugin is starting Geronimo.

Commenting out the code made it work OK so I tried to defeat it by adding a system property to the run line

if (System.getProperty("car-maven-plugin) == null) { .... }

It should not run when the Java world is car-maven-plugin.  But car-maven-plug still fails. So I experimented with rewriting the SynchWorker class using a constructor, instead of relying on default no-arg constructor and now it works if that makes any sense.  A bad day for open source.
Reply | Threaded
Open this post in threaded view
|

Re: car-maven-plugin and Geronimo Bean references problem - UPDATE

rwengr
I redesigned the way this code was implementing a thread and now the car-maven-plugin does not get an error, which to me does not make any sense.  Basically, the code does the same thing, but now the thread has a constructor.  It does not rely on default constructor.