IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Java Discussion :

erreur service java après demarrage.


Sujet :

Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre actif
    Inscrit en
    Janvier 2013
    Messages
    20
    Détails du profil
    Informations forums :
    Inscription : Janvier 2013
    Messages : 20
    Par défaut erreur service java après demarrage.
    Bonjour,
    voici l'erreur que j'ai eu quand je demarre le service:

    le service ****** sur Ordinateut local a démarré et s'est ensuite arrêté.
    Certains services s'arrêtent automatiquement s'ils ne sont pas utilisés par
    d'autres services ou programes.

    ce service est en fait un .jar fait par une fonction periodique sans fin, je ne sais pas pourquoi ça s'arrête alors !!

    en voici le code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    import java.util.Timer;
    import java.util.TimerTask;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.sql.Statement;
     
     
     
    public class SampleService
    {
     
    	public static int x = 1;
        public static int y = 2000;
        public static String e = "nom";
        public static int z = 500;
        public static String t = "01/05/2013";
        public static String o = "Null";
        private Timer timer;
     
     
    	public static void main(String[] args)
    	{
    		System.out.println("SampleService application main entry point invoked...");
     
    		if (args.length == 0)
    		{
    			System.out.println("Doing nothing, no command-line parameter(s) specified");
    		}
    		else if ("start".equalsIgnoreCase(args[0]))
    		{
    			System.out.println("Start parameter specified");
    			serviceStart(args);
    		}
    		else if ("stop".equalsIgnoreCase(args[0]))
    		{
    			System.out.println("Stop parameter specified");
    			serviceStop(args);
    		}
    		else
    		{
    			System.out.println("Command-line parameter '" + args[0] + "' not recognised, doing nothing");
    		}
    	}
     
    	public static void outputJvmDetails()
    	{
    		System.out.println("JVM " + 
    							System.getProperty("java.vm.vendor", "{vm.vendor}")
    							+ " " +
    							System.getProperty("java.vm.name", "{vm.name}")
    							+ " " +
    							System.getProperty("java.vm.version", "{vm version}"));
    	}
     
     
    	public static void outputHeapDetails()
    	{
    		Runtime rt = Runtime.getRuntime();
    		final long totalBytes = rt.totalMemory();
    		final long freeBytes = rt.freeMemory();
    		rt = null;
     
    		System.out.println("Heap Size " +
    							kBytes(totalBytes)
    							+ " total, free "
    							+ kBytes(freeBytes)
    							+ " (used "
    							+ kBytes(totalBytes - freeBytes)
    							+ ")");    
    	}
     
     
    	private static String kBytes(long bytes)
    	{
    		if (bytes > 1024)
    		{
    			bytes -= (bytes % 1024); // rounding to get whole KB figures
    		}
     
    		final long kb = (long) bytes / 1024;
     
    		return Long.toString(kb) + "KB";
    	}
     
     
    	public static void serviceStart(String[] args)
    	{
    		System.out.println("Service start function invoked...");
     
    		outputJvmDetails();
    		outputHeapDetails();
     
    		getServiceInstance().execute(args);
    	}
     
    	public static void serviceStop(String[] args)
    	{
    		System.out.println("Service stop function invoked...");
     
    		getServiceInstance().abort();
     
    		outputHeapDetails();
    	}
     
     
    	private static SampleService serviceInstance = null;
     
    	private static synchronized SampleService getServiceInstance()
    	{
    		if (serviceInstance == null)
    		{
    			serviceInstance = new SampleService();
    		}
    		return serviceInstance;
    	}
     
     
    	private boolean serviceExecuting = false;
     
    	/**
             * Default constructor, for the single instance that ever exists.
             */
    	private SampleService()
    	{
    		setServiceExecuting(false);
    	}
     
    	/**
             * Thread-safe update to the service control flag, sets or clears it.
             * 
             * @param executingNow value to be stored in the flag
             */	
    	private synchronized void setServiceExecuting(boolean executingNow)
    	{
    		serviceExecuting = executingNow;
    	}
     
    	private synchronized boolean isServiceExecuting()
    	{
    		return serviceExecuting;
    	}
     
    	private void execute(String[] args)
    	{
    		final boolean useMemory = (args.length > 1);
    		System.out.println("Starting service execution");
    		if (useMemory)
    		{
    			System.out.println("(Execution loop will exercise memory heap)");
    		}
     
     
    		setServiceExecuting(true);
    	//	while (isServiceExecuting())
    	//	{
     				timer = new Timer();
    				timer.schedule(new SampleService.Tache(),0,60*60*5);
    	//		}
    		System.out.println("Ended service execution");
    	}
     
    	class Tache extends TimerTask {
     
    	public void run()
    	{
    	try
            {
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                Connection connection = DriverManager.getConnection("jdbc:odbc:database");
                try (Statement st = connection.createStatement()) {
                //    for(int i =0; i < 1; i++) {
                  st.executeUpdate("INSERT INTO tablegmao(ID,codepiece,quantite,demandeur,datecommande,datecheance) values (" +x+ "," +y+ "," +z+ ",'" +e+ "','" +t+ "','"+o+"')");
                    x++;
                    y+=10;
              //      }
                }
                connection.close();
    		} catch(ClassNotFoundException exp) {
    		System.err.println(exp);	
    		}
    		catch(SQLException exp) {
    		System.out.println(exp);
    		}
    	}
    	}
     
    	private void abort()
    	{
    		System.out.println("Aborting service execution");
    		setServiceExecuting(false);
    	}
     
    }
    merci

  2. #2
    Membre actif
    Inscrit en
    Janvier 2013
    Messages
    20
    Détails du profil
    Informations forums :
    Inscription : Janvier 2013
    Messages : 20
    Par défaut
    en voici l'erreur que ça me donne en ligne de code:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    le service ***** démarre...
    le service n'a pas pu être lancé.
    le servie n'as pas signalé d'erreur.
    vous obtiendrez une aide supplémentaire en entrant net helpmsg 3534.

Discussions similaires

  1. Réponses: 3
    Dernier message: 23/11/2011, 14h00
  2. [commons daemon] Service Java sous windows
    Par denisC dans le forum API standards et tierces
    Réponses: 9
    Dernier message: 09/09/2011, 10h34
  3. erreur client java sur web service php
    Par cotede2 dans le forum Services Web
    Réponses: 0
    Dernier message: 30/09/2010, 21h29
  4. Erreur de compilation après modification du Uses
    Par DevelOpeR13 dans le forum Langage
    Réponses: 5
    Dernier message: 30/10/2007, 14h23
  5. [Tomcat]Executer une classe JAVA au demarrage de TOMCAT
    Par dehbi dans le forum Tomcat et TomEE
    Réponses: 2
    Dernier message: 18/08/2005, 14h23

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo