Hello Dain,

Don't worry for the late reply, I'm not in a hurry :-)
I hope that your client has come to better feelings now ;-)

I get things to work by declaring the contexts in the Catalina/localhost
repository in the tomcat conf dir.

My layout is as follow :

MyProject/
        +-- src/
        |        +-- main/
        |        |        +-- java/
        |        |        +-- resources/
        |        |        +-- webapps/
        |        |                +-- WEB-INF/
        |        |                        +-- web.xml
        |        +-- test/
        |                +-- java/
        |                +-- resources/
        +-- target/
        |        +-- MyProject-0.0.1-SNAPSHOT/
        |        |        +-- META-INF/ (empty)
        |        |        +-- WEB-INF/
        |        |                +-- classes/
        |        |                +-- lib/ (No OpenEJB jars in here)
        |        |                +-- web.xml
        |        +-- classes/
        |        +-- test-classes/
        |        +-- war/
        |        +-- MyProject.war
        +-- target-eclipse/ (Compilation directory for Eclipse)
+-- runtime/ (directory that acts as catalina.base and openejb.base)
                +-- conf/
                |        +-- Catalina/
                |        |        +-- localhost/
                |        |                +-- openejb.xml
                |        |                +-- MyProject.xml
                |        +-- context.xml
                |        +-- logging.properties
                |        +-- openejb.xml
                |        +-- server.xml
                |        +-- web.xml
                +-- logs/ (logs)
                +-- temp/ (acts as java.io.tmpdir)
                +-- txlog/ (logs)
                +-- webapps/ (empty, serves as appBase for the localhost
host in server.xml)
                +-- work/


Here above, the contents of some important files:

#########################################################################
Server.xml: I took the one in the tomcat install. I just added the OpenEJB
listener and trimmed the comments.

<Server port="8005" shutdown="SHUTDOWN">

  <Listener className="org.apache.openejb.tomcat.loader.OpenEJBListener" />
  <Listener className="org.apache.catalina.core.AprLifecycleListener"
SSLEngine="on" />
  <Listener className="org.apache.catalina.core.JasperListener" />
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
/>
  <Listener
className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

  <GlobalNamingResources>
  </GlobalNamingResources>

  <Service name="Catalina">
  
    <Connector port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

    <Engine name="Catalina" defaultHost="localhost">
      <Host name="localhost"  appBase="webapps"
            unpackWARs="false" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
            
      </Host>
    </Engine>
  </Service>
</Server>
#########################################################################

#########################################################################
openejb.xml: well, nothing special. I copied the one created by a default
installation

<?xml version="1.0" encoding="ISO-8859-1"?>
<Context docBase="C:\apache-tomcat-6.0.14\webapps\openejb" >
  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.0\.0\.1,0:0:0:0:0:0:0:1(%.*)?" deny=""/>
</Context>
#########################################################################

#########################################################################
MyProject.xml: Here again, nothing sexy.

<?xml version="1.0" encoding="ISO-8859-1"?>
<Context docBase="../../target/MyProject-0.0.1-SNAPSHOT" />
#########################################################################

#########################################################################
openejb.xml: I removed defaults and inserted a database for my project

<openejb>
        <Resource id="commonsDatabase" type="javax.sql.DataSource">
                JdbcDriver : com.mysql.jdbc.Driver
                JdbcUrl : jdbc:mysql://localhost:3306/ccv?useUnicode=true
                UserName : ccvusr
                Password : ccvpwd
        </Resource>
        
        <Resource id="commonsDatabaseUnmanaged" type="javax.sql.DataSource">
                JdbcDriver : com.mysql.jdbc.Driver
                JdbcUrl : jdbc:mysql://localhost:3306/ccv?useUnicode=true
                UserName : ccvusr
                Password : ccvpwd
                JtaManaged : false
        </Resource>
</openejb>
#########################################################################

#########################################################################
context.xml: Again, this is the original file took from a clean install of
Tomcat 6 whith comments trimmed.

<Context>
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>
#########################################################################







This is the configuration I use to start the server in Eclipse :
VM args:
        -Dcatalina.home="C:\apache-tomcat-6.0.14"
        -Dcatalina.base="."
        -Dopenejb.home="C:\apache-tomcat-6.0.14"
        -Dopenejb.base="."
        -Djava.io.tmpdir="temp"
        -Xmx128M
        -javaagent:"C:\apache-tomcat-6.0.14\lib\openejb-javaagent.jar"

Main class:
        org.apache.catalina.startup.Bootstrap

Program arguments:
        start

Classpath:
C:\apache-tomcat-6.0.14\bin\bootstrap.jar

Working directory:
        MyProject/runtime/


When I start the server, I get the following exception :
java.lang.NullPointerException
        at
org.apache.openejb.tomcat.loader.OpenEJBListener.lifecycleEvent(OpenEJBListener.java:46)
        at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
        at
org.apache.catalina.core.StandardServer.initialize(StandardServer.java:767)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:518)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:538)
        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.apache.catalina.startup.Bootstrap.load(Bootstrap.java:260)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:412)
10 juin 2008 09:01:23 org.apache.catalina.realm.JAASRealm setContainer
INFO: Set JAAS app name Catalina
10 juin 2008 09:01:23 org.apache.coyote.http11.Http11AprProtocol init
INFO: Initialisation de Coyote HTTP/1.1 sur http-8080
10 juin 2008 09:01:23 org.apache.coyote.ajp.AjpAprProtocol init
INFO: Initializing Coyote AJP/1.3 on ajp-8009
10 juin 2008 09:01:23 org.apache.catalina.core.StandardService start
INFO: Démarrage du service Catalina
10 juin 2008 09:01:23 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.14



After that, everything works fine, except that the openejb doesn't load at
the beginning but rather as per Tomcat's context loading rules
(alphabetically, that is)

So openejb starts first only if my project bears a context name that is
alphabetically after "openejb". I had to rename MyProject.xml to
zMyProject.xml to get that…

I've found this loader + eclipse problem in another post on this forum:
http://www.nabble.com/forum/ViewPost.jtp?post=16419231&framed=y


SO,

To sum up a bit :

If I declare the contexts for openEJB and my application inside the
server.xml something fails.
If I declare the same contexts in the Catalina/localhost directory,
everything works fine except for the OpenEJB loader that fails with a NPE.

Well I hope that you have a better sight of my project now…
If you need more info, I'll be glad to provide you with an Eclipse project
that produce these conditions.  

Again, thanks **a lot** for your concern.

Regards,

Juan Manuel

-- 
View this message in context: 
http://www.nabble.com/OpenEJB.war-outside-webapps-tp17666227p17749351.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to