java - run the startUp method at the deploy a web service -


i try execute startup method when deploy web services, doesn`t work.

i'm using:

windows 7

tomcat 8.0.30

axis2 1.7.0

i've tryed deploy service pojo service try generating *.aar , placing in:

apache-tomcat-8.0.30\webapps\axis2\web-inf\services when run tomcat, , deploy , other services, startup method dont launch. code:

import java.io.*; import java.util.*; import org.apache.axis2.context.configurationcontext; import org.apache.axis2.description.axisservice; import org.apache.axis2.engine.servicelifecycle;  public class login implements servicelifecycle{      static string ipprop = "";     static string rutadb = "c:/resources/users_db.txt";     static string rutauddixml = "c:/resources/uddi.xml";     static string rutaip = "c:/resources/ip.txt";     static boolean registrado=false;     static string comp ="";      public static void main(string[] args) {          ip();         string nombreservicio = "login";         string rutaservicio = "http://"+ ipprop +":8080/axis2/services/login";         simplepublishportable spp = new simplepublishportable(rutauddixml);         spp.publish(nombreservicio, rutaservicio);         system.out.println("te registraste");     }      public static void createuser(string user, string pass) {         interacfich("crea", user, pass);     }      public static string loginaccess(string user, string pass) {         return interacfich("login", user, pass);     }      public static string runcomprobation(){         return "deployed service" + comp;     }       public static string regcomprobation(){         if(registrado==true){             return "registered";         }         else{             return "failed";         }     }      private static string gettoken() {         string cadenaaleatoria = "";          int = 0;         while (i < 10) {             char c = (char) ((int) (math.random() * 255 + 1));             if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z')) {                 cadenaaleatoria += c;                 i++;             }         }         return cadenaaleatoria;     }      private static string interacfich(string accion, string user, string pass) {         string usuario = "";         linkedhashmap<string, string> usuarios = new linkedhashmap<string, string>();          file archivo = new file(rutadb);          // leer fichero y meterlo en el mapa         if (archivo.exists() == false) {             try {                 archivo.createnewfile();             } catch (ioexception e) {                 e.printstacktrace();             }         } else {             try (bufferedreader br = new bufferedreader(new filereader(archivo))) {                 while (br.ready()) {                     usuario = br.readline();                     string[] param = usuario.split("\\*");                     usuarios.put(param[0], param[1]);                  }                 br.close();             } catch (ioexception e) {                 e.printstacktrace();             }         }         switch (accion) {         case "crea":             usuarios.put(user + "-" + pass, gettoken());              try (bufferedwriter bw = new bufferedwriter(new filewriter(archivo))) {                 set<string> keysusuarios = usuarios.keyset();                 (string k : keysusuarios) {                     bw.write(k + "*" + usuarios.get(k).tostring());                     bw.write("\n");                  }                 system.out.println("todo escrito");                 bw.close();                  return "el fichero se crea";             } catch (ioexception e) {                 e.printstacktrace();             }             break;         case "login":             if (usuarios.containskey(user + "-" + pass)) {                 return usuarios.get(user + "-" + pass);             }             return "user o pass erroneos";         default:             break;          }          return null;     }      private static void ip() {         file archivo = new file(rutaip);         try (bufferedreader br = new bufferedreader(new filereader(archivo))) {             br.readline();             ipprop = br.readline();       br.close();     } catch (ioexception e) {         e.printstacktrace();     }      return;  } @override public void startup(configurationcontext arg0, axisservice arg1) {     ///////////////     //registrarse//     ///////////////     comp="entramos";     ip();     string nombreservicio = "login";     string rutaservicio = "http://"+ ipprop +":8080/axis2/services/login";     simplepublishportable spp = new simplepublishportable(rutauddixml);     spp.publish(nombreservicio, rutaservicio);     registrado=true; }  @override public void shutdown(configurationcontext arg0, axisservice arg1) {     // todo auto-generated method stub  }  } 

have created service definition (services.xml) file, on describe services?

i referring file similar example in code listing 3: service definition file in following link (axis2 quick start):

https://axis.apache.org/axis2/java/core/docs/quickstartguide.html#services


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -