how you have esplalned i have write the following Listener: using the second
option .

basically implement org.apache.tomcat:tomcat-catalina/7.0.x
org.apache.catalina.LifecycleListener interface, doing sthg like:

       if (event.getType() == Lifecycle.START_EVENT && event.getSource()
instanceof Host) {

            System.setProperty("xxx", System.getEnv("..."));
        }

*then simply activate it in server.xml (you can also set this listener in
META-INF/context.xml of your war but you'll need to listen even INIT_EVENT
and check source is instanceof Context)
*
but from Lifecycle. i not get INIT_EVENT .
I have tried Lifecycle.BEFORE_INIT_EVENT 
or i have to use Lifecycle.AFTER_INIT_EVENT   ???????

N:B: i not have configurated into server.xml the listener . I have used it
only into web apllication.




public class MauroListener implements org.apache.catalina.LifecycleListener
{

    @Override
    public void lifecycleEvent(LifecycleEvent event) {
      
     if (event.getType() == Lifecycle.BEFORE_INIT_EVENT
              &&event.getSource() instanceof Context) { 

          this.settaggioVariabili(); 
        } 

    }
      private void settaggioVariabili(){
        String MYUSERDB, MYDBPASS, MYDBHOST, MYDBPORT, MYDBNAMEDB ;
        MYDBNAMEDB=System.getenv("OPENSHIFT_APP_NAME");
        MYUSERDB=System.getenv("OPENSHIFT_MYSQL_DB_USERNAME");
        MYDBHOST=System.getenv("OPENSHIFT_MYSQL_DB_HOST"); 
        MYDBPORT=System.getenv("OPENSHIFT_MYSQL_DB_PORT");
        MYDBPASS=System.getenv("OPENSHIFT_MYSQL_DB_PASSWORD");
             
                


System.setProperty("MYDBNAMEDB", MYDBNAMEDB);
System.setProperty("MYUSERDB", MYUSERDB);
System.setProperty("MYDBHOST", MYDBHOST);
System.setProperty("MYDBPORT", MYDBPORT);
System.setProperty("MYDBPASS", MYDBPASS);



 System.out.println("valori settati= \n"); 
 
    System.out.print("MYDBNAMEDB=");  
    System.out.println(System.getProperty("MYDBNAMEDB")); 
    
           System.out.print("MYUSERDB=");
            System.out.println(System.getProperty("MYUSERDB"));
            
              System.out.print("MYDBPASS=");
           System.out.println(System.getProperty("MYDBPASS")); 
            
            System.out.print("MYDBHOST=");
           System.out.println(System.getProperty("MYDBHOST")); 
           
           System.out.print("MYDBPORT=");
           System.out.println(System.getProperty("MYDBPORT")); 
          
          System.out.println("\n"+"----------------");
           
           
    }
    
}

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

this class it is  into my web application. not in a jar into tomee/lib

then into context.xml into my web application i have added:

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/provalistenersettaggiovariabili">
<Listener className="mauro.lifecycle.MauroListener"/>

</Context>

into web.xml of my application i have aadded;

 <listener>
        <listener-class>mauro.lifecycle.MauroListener</listener-class>
    </listener>

------------
but when i deploy i get error.



--
View this message in context: 
http://openejb.979440.n4.nabble.com/Re-i-have-tried-but-not-work-tp4664234p4664339.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to