2014-07-16 4 views
0

나는 주어진 사용자에게 전자 메일을 보내는 Activti bpm으로 serviceTask를 시작한다고 가정하는 이클립스 maven 프로젝트를 만들었습니다.아파치 공유지에 의해 덮어 쓰여진 포트와 호스트

아파치 제임스 서버를 사용하고 Gmail 용으로 구성 했으므로 텔넷을 통해 이메일을 보낼 수는 있지만 서비스 작업은 사용하지 않습니다.

문제점은 아파치 공유지의 Email이라는 클래스가 내 구성을 덮어 쓰게되는 문제입니다. 이 클래스가 호출되는 이유를 모르겠다. Java 코드에서 apache.commons를 사용하지 않습니다.

제임스 구성 : config.xml의

<servernames autodetect="true" autodetectIP="true"> 
    <servername>smtp.gmail.com</servername> 
    </servernames> 

    <dnsserver> 
    <servers> 
    <!--Enter ip address of your DNS server, one IP address per server --> 
    <!-- element. --> 
    <!-- 
    <server>127.0.0.1</server> 
    --> 
    <server> 8.8.8.8 </server> 
    <server> 8.8.4.4 </server> 
    </servers> 
    <!-- Change autodiscover to false if you would like to turn off autodiscovery --> 
    <!-- and set the DNS servers manually in the <servers> section --> 
    <autodiscover>true</autodiscover> 
    <authoritative>false</authoritative> 

    <!-- Maximum number of entries to maintain in the DNS cache --> 
    <maxcachesize>50000</maxcachesize> 
    </dnsserver> 

...이 프로세스 정의 함유 bpmn20.xml이다

smtpserver enabled="true"> 
    <port>587</port> 

... :

<definitions id="definitions" 
    targetNamespace="http://activiti.org/bpmn20" 
    xmlns:activiti="http://activiti.org/bpmn" 
    xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"> 
    <process id="EmailNotification" name="emailNotification"> 
    <documentation>Simple Email Notification Task</documentation> 
    <startEvent id="startevent1" name="Start"></startEvent> 
    <sequenceFlow id="flow1" name="" sourceRef="startevent1" 
    targetRef="mailtask1"></sequenceFlow> 
    <endEvent id="endevent1" name="End"></endEvent> 
    <sequenceFlow id="flow2" name="" sourceRef="mailtask1" 
    targetRef="endevent1"></sequenceFlow> 
    <serviceTask id="mailtask1" name="Email Notification" 
    activiti:type="mail"> 
    <extensionElements> 
    <activiti:field name="to" expression="[email protected]" 
    ></activiti:field> 
    <activiti:field name="from" expression="[email protected]" 
    ></activiti:field> 
    <activiti:field name="subject" expression="Simple Email Notification" 
    ></activiti:field> 
    <activiti:field name="html"> 
    <activiti:expression><![CDATA[Here is a simple Email Notification 
    from a user.]]></activiti:expression> 
    </activiti:field> 
    </extensionElements> 
    </serviceTask> 
    </process> 
    </definitions> 

이것은 일입니다. 전자 자바 코드 :이 문제는 이제 해결

<?xml version="1.0" encoding="UTF-8"?> 
    <beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans.xsd"> 

    <bean id="processEngineConfiguration"  
    class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration" > 
    <!-- Database configurations --> 
    <property name="databaseType" value="h2" /> 
    <property name="jdbcUrl 
    value="jdbc:h2:C:/Users/Alexandra/tmp/activiti;AUTO_SERVER=TRUE" /> 
    <property name="jdbcDriver" value="org.h2.Driver" /> 
    <property name="jdbcUsername" value="sa" /> 
    <property name="jdbcPassword" value="" /> 

    <!-- Database configurations --> 
    <property name="databaseSchemaUpdate" value="true" /> 

    <!-- job executor configurations --> 
    <property name="jobExecutorActivate" value="true" /> 

    <!-- mail server configurations --> 
    <property name="mailServerHost" value="smtp.gmail.com" /> 
    <property name="mailServerPort" value="587" /> 
    <property name="mailServerUsername" value="root" /> 
    <property name="mailServerPassword" value="root" /> 

    <property name="history" value="full" /> 

    <property name="customPostDeployers"> 
    <list> 
    <bean class="org.activiti.engine.impl.rules.RulesDeployer" /> 
    </list> 
    </property> 

    </bean> 

</beans> 
+0

James가 어떻게 구성되어 있는지 확인하고 싶다면 apache.commons (아파치 프로젝트)를 사용하기 때문에 이메일 코드를 게시하십시오. –

+0

코드를 추가했습니다. 도움을받을 수 있기를 바랍니다 :) – agiledevpro

답변

0

:

// Create Activiti process engine 
    ProcessEngine processEngine = ProcessEngineConfiguration 
    .createStandaloneInMemProcessEngineConfiguration() 
    .buildProcessEngine(); 

    // Get Activiti services 
    RepositoryService repositoryService = processEngine.getRepositoryService(); 
    RuntimeService runtimeService = processEngine.getRuntimeService(); 

    // Deploy the process definition 
    repositoryService.createDeployment() 
    .addClasspathResource("risk.bpmn20.xml") 
    .deploy(); 


    // Start a process instance 
    String procId = 
    runtimeService.startProcessInstanceByKey("EmailNotification").getId(); 

이것은 activiti.cfg.xml 파일입니다. 프로세스 엔진의 데이터를 설정하여 문제를 해결했습니다.

 ProcessEngine processEngine = ProcessEngineConfiguration 
    .createStandaloneInMemProcessEngineConfiguration() 
    .setMailServerHost("smtp.gmail.com") 
    .setMailServerPort(587) 
    .setMailServerUsername("root") 
    .setMailServerPassword("root") 
    .setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE) 
    .setMailServerUseSSL(true) 
    .setMailServerUseTLS(true) 
    .setMailServerDefaultFrom("[email protected]") 
    .buildProcessEngine();