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

Wildfly/JBoss Java Discussion :

Pour utiliser JBPM avec persistance sous MySQL


Sujet :

Wildfly/JBoss Java

  1. #1
    Membre régulier Avatar de anas.eh
    Profil pro
    Inscrit en
    Février 2007
    Messages
    181
    Détails du profil
    Informations personnelles :
    Âge : 38
    Localisation : Maroc

    Informations forums :
    Inscription : Février 2007
    Messages : 181
    Points : 119
    Points
    119
    Par défaut Pour utiliser JBPM avec persistance sous MySQL
    Bonjour tout le monde,

    J'ai besoin dans mon projet d'utiliser jBpm avec la persistance sur une base de données MySQL, j'ai créé la base de données sous MySQL (jbpm_bd), ci-dessous le 'hibernate.cfg.xml' (j'ai suivi ce tutoriel http://docs.jboss.com/jbpm/v3/userguide/tutorial.html) :

    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
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
     
    <hibernate-configuration> 
      <session-factory> 
        <!-- JDBC connection properties (end) -->
        <property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
        <!-- JDBC connection properties (begin) -->
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.password">anas</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/jbpm</property>
        <property name="hibernate.connection.username">root</property>
        <!-- hibernate dialect -->
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
        <!-- DataSource properties (begin)-->
        <!--  <property name="hibernate.connection.datasource">java:/JbpmDS</property>-->
        <!-- DataSource properties (end) -->
        <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
      </session-factory>
    </hibernate-configuration>
    Le code est le suivant :

    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
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    import org.jbpm.JbpmConfiguration;
    import org.jbpm.JbpmContext;
    import org.jbpm.JbpmException;
    import org.jbpm.db.GraphSession;
    import org.jbpm.graph.def.ProcessDefinition;
    import org.jbpm.graph.exe.ProcessInstance;
    import org.jbpm.graph.exe.Token;
     
    public class jbpm {
     
      static JbpmConfiguration jbpmConfiguration = null; 
     
      static {
        // An example configuration file such as this can be found in 
        // 'src/config.files'.  Typically the configuration information is in the 
        // resource file 'jbpm.cfg.xml', but here we pass in the configuration 
        // information as an XML string.
     
        // First we create a JbpmConfiguration statically.  One JbpmConfiguration
        // can be used for all threads in the system, that is why we can safely 
        // make it static.
     
        jbpmConfiguration = JbpmConfiguration.parseXmlString(
          "<jbpm-configuration>" +
     
          // A jbpm-context mechanism separates the jbpm core 
          // engine from the services that jbpm uses from 
          // the environment.  
     
          "  <jbpm-context>" +
          "    <service name='persistence' " +
          "             factory='org.jbpm.persistence.db.DbPersistenceServiceFactory' />" + 
          "<service name=\"tx\" factory=\"org.jbpm.tx.TxServiceFactory\" />"+
     
          "  </jbpm-context>" +
     
          // Also all the resource files that are used by jbpm are 
          // referenced from the jbpm.cfg.xml
     
          "  <string name='resource.hibernate.cfg.xml' " +
          "          value='hibernate.cfg.xml' />"+
          "</jbpm-configuration>"
          );
      }
     
      public void setUp() {
        jbpmConfiguration.createSchema();
      }
     
      public void tearDown() {
        jbpmConfiguration.dropSchema();
      }
     
      public void testSimplePersistence() {
        // Between the 3 method calls below, all data is passed via the 
        // database.  Here, in this unit test, these 3 methods are executed
        // right after each other because we want to test a complete process
        // scenario.  But in reality, these methods represent different 
        // requests to a server.
     
        // Since we start with a clean, empty in-memory database, we have to 
        // deploy the process first.  In reality, this is done once by the 
        // process developer.
     
     
     
          deployProcessDefinition();
     
        // Suppose we want to start a process instance (=process execution)
        // when a user submits a form in a web application...
     
        //processInstanceIsCreatedWhenUserSubmitsWebappForm();
     
        // Then, later, upon the arrival of an asynchronous message the 
        // execution must continue.
     
        //theProcessInstanceContinuesWhenAnAsyncMessageIsReceived();
      }
     
      public void deployProcessDefinition() {
        // This test shows a process definition and one execution 
        // of the process definition.  The process definition has 
        // 3 nodes: an unnamed start-state, a state 's' and an 
        // end-state named 'end'.
          ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
                  "<process-definition name='hello world'>" +
                  "  <start-state name='start'>" +
                  "    <transition to='s' />" +
                  "  </start-state>" +
                  "  <state name='s'>" +
                  "    <transition to='end' />" +
                  "  </state>" +
                  "  <end-state name='end' />" +
                  "</process-definition>"
                );
     
        // Lookup the pojo persistence context-builder that is configured above
        JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
     
        try {
          // Deploy the process definition in the database 
          jbpmContext.deployProcessDefinition(processDefinition);
     
        } 
        catch (JbpmException ex)
        {
            System.out.println(ex.getMessage());
        }
        finally {
          // Tear down the pojo persistence context.
          // This includes flush the SQL for inserting the process definition  
          // to the database.
          jbpmContext.close();
        }
      }
     
      public void processInstanceIsCreatedWhenUserSubmitsWebappForm() {
        // The code in this method could be inside a struts-action 
        // or a JSF managed bean. 
     
        // Lookup the pojo persistence context-builder that is configured above
        JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
        try {
     
          GraphSession graphSession = jbpmContext.getGraphSession();
     
          ProcessDefinition processDefinition = 
              graphSession.findLatestProcessDefinition("hello world");
     
          // With the processDefinition that we retrieved from the database, we 
          // can create an execution of the process definition just like in the 
          // hello world example (which was without persistence).
          ProcessInstance processInstance = 
              new ProcessInstance(processDefinition);
     
          Token token = processInstance.getRootToken(); 
     
          //assertEquals("start", token.getNode().getName());
          // Let's start the process execution
          token.signal();
          // Now the process is in the state 's'.
          //assertEquals("s", token.getNode().getName());
     
          // Now the processInstance is saved in the database.  So the 
          // current state of the execution of the process is stored in the 
          // database.  
          jbpmContext.save(processInstance);
          // The method below will get the process instance back out 
          // of the database and resume execution by providing another 
          // external signal.
     
        } finally {
          // Tear down the pojo persistence context.
          jbpmContext.close();
        }
      }
     
      public void theProcessInstanceContinuesWhenAnAsyncMessageIsReceived() {
        // The code in this method could be the content of a message driven bean.
     
        // Lookup the pojo persistence context-builder that is configured above
        JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
        try {
     
          GraphSession graphSession = jbpmContext.getGraphSession();
          // First, we need to get the process instance back out of the database.
          // There are several options to know what process instance we are dealing 
          // with here.  The easiest in this simple test case is just to look for 
          // the full list of process instances.  That should give us only one 
          // result.  So let's look up the process definition.
     
          ProcessDefinition processDefinition = 
              graphSession.findLatestProcessDefinition("hello world");
     
          // Now, we search for all process instances of this process definition.
     
          //List processInstances = 
            //  graphSession.findProcessInstances(processDefinition.getId());
     
          // Because we know that in the context of this unit test, there is 
          // only one execution.  In real life, the processInstanceId can be 
          // extracted from the content of the message that arrived or from 
          // the user making a choice.
     
          //ProcessInstance processInstance = 
            //  (ProcessInstance) processInstances.get(0);
     
          // Now we can continue the execution.  Note that the processInstance
          // delegates signals to the main path of execution (=the root token).
     
          //processInstance.signal();
     
          // After this signal, we know the process execution should have 
          // arrived in the end-state.
     
          //assertTrue(processInstance.hasEnded());
     
          // Now we can update the state of the execution in the database
     
          //jbpmContext.save(processInstance);
     
        } finally {
          // Tear down the pojo persistence context.
          jbpmContext.close();
        }
      }
    }
    Quand j'exécute la méthode deployProcessDefinition() j'obtiens les erreurs suivantes :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    log4j:WARN No appenders could be found for logger (org.jbpm.JbpmConfiguration).
    log4j:WARN Please initialize the log4j system properly.
    org.hibernate.MappingException: Named query not known: GraphSession.findLatestProcessDefinitionQuery
        at org.hibernate.impl.AbstractSessionImpl.getNamedQuery(AbstractSessionImpl.java:70)
        at org.hibernate.impl.SessionImpl.getNamedQuery(SessionImpl.java:1260)
        at org.jbpm.db.GraphSession.findLatestProcessDefinition(GraphSession.java:150)
        at org.jbpm.db.GraphSession.deployProcessDefinition(GraphSession.java:67)
        at org.jbpm.JbpmContext.deployProcessDefinition(JbpmContext.java:173)
        at jbpm.deployProcessDefinition(jbpm.java:102)
        at jbpm.testSimplePersistence(jbpm.java:67)
        at jbpmMain.main(jbpmMain.java:5)
    couldn't find process definition 'hello world'
    Merci de m'aider et si vous avez un tutoriel très clair ou un exemple veuillez me le donner,

    Merci encore une fois,

  2. #2
    Membre à l'essai
    Étudiant
    Inscrit en
    Juillet 2008
    Messages
    23
    Détails du profil
    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juillet 2008
    Messages : 23
    Points : 22
    Points
    22
    Par défaut Solution :yaisse2:
    Bonjour anas.eh
    pour la premier erreur
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    log4j:WARN No appenders could be found
    il faut ajouter un fichier dans le repertoire de configuration
    nom:
    contenue:
    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
    # Set root logger level to DEBUG and its only appender to CONSOLE.
    log4j.rootLogger=DEBUG, CONSOLE
     
    # CONSOLE
    log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
    log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
    log4j.appender.CONSOLE.layout.ConversionPattern=%d{HH:mm:ss,SSS} [%t] %-5p %C{1} : %m%n
     
    # LIMIT CATEGORIES
    log4j.logger.org.jbpm=DEBUG
    #log4j.logger.org.jbpm.graph=DEBUG
     
    # Hibernate debugging levels and their output
    log4j.logger.org.hibernate=INFO
    #Log all SQL DML statements as they are executed
    #log4j.logger.org.hibernate.SQL=TRACE
    #Log all JDBC parameters
    #log4j.logger.org.hibernate.type=TRACE
    #Log all SQL DDL statements as they are executed
    #log4j.logger.org.hibernate.tool.hbm2ddl=DEBUG	
    #Log the state of all entities (max 20 entities) associated with the session at flush time
    #log4j.logger.org.hibernate.pretty=DEBUG	
    #Log all second-level cache activity
    #log4j.logger.org.hibernate.cache=DEBUG	
    #Log transaction related activity
    #log4j.logger.org.hibernate.transaction=DEBUG	
    #Log all JDBC resource acquisition
    #log4j.logger.org.hibernate.jdbc=TRACE	
    #Log HQL and SQL ASTs and other information about query parsing
    #log4j.logger.org.hibernate.hql.ast=DEBUG	
    #Log all JAAS authorization requests
    #log4j.logger.org.hibernate.secure=DEBUG	
    #Log everything (a lot of information, but very useful for troubleshooting)
    #log4j.logger.org.hibernate=DEBUG	
    #log4j.logger.org.hibernate.tools=DEBUG
    pour la suite
    suivi ce lien Comment déployée un processus avec JBPM dans MySQL

  3. #3
    Membre à l'essai
    Inscrit en
    Février 2009
    Messages
    8
    Détails du profil
    Informations forums :
    Inscription : Février 2009
    Messages : 8
    Points : 12
    Points
    12
    Par défaut JAVA JBPM
    Bonjour a tous je suis débutant dans la technologie JBPM
    jusqu'ici j ai certes réussi a designer un processus et a l implémenter sans problème j utilise JBPM-JPDL V 3.2.3
    mon problème ici c est que je veux embarquer mon processus déjà designer dans une application web (RIA).
    je ne sais pas comment m y prendre

    si quelqu'un a une une idee une doc pour mettre sur le chemin
    sa va beaucoup m aider.

Discussions similaires

  1. Réponses: 0
    Dernier message: 09/03/2014, 21h30
  2. Réponses: 7
    Dernier message: 08/06/2006, 22h51
  3. Problème avec select sous MYSQL
    Par Thomad dans le forum Langage SQL
    Réponses: 2
    Dernier message: 26/01/2006, 11h26
  4. Un Tuto pour utiliser MyODBC avec Visual C++
    Par Jean-Michel dans le forum MFC
    Réponses: 2
    Dernier message: 12/08/2005, 15h18

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