I have some troubles with running my code in Camunda
Camunda 7.17.0 - run container based on camunda/camunda-bpm-platform:7.17.0
Dockerfile for my custom image
FROM camunda/camunda-bpm-platform:7.17.0
COPY camunda_test_engine.jar /camunda/lib
COPY context.xml /camunda/conf/
ENV JAVA_OPTS="-Xmx4096m -Xms2024m"
JDK - liberica 11.0.22
delegate code
public class getStore implements JavaDelegate{
@Override
public void execute(DelegateExecution execution) throws Exception {
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("java:/comp/env/jdbc/tstECOM");
try (Connection connection = ds.getConnection()) {
try {
Store Store = new Store(connection);
Store.getStoreFromECOM();
Store.getStocksForStore();
Store.getHubForThisStore();
try{
ObjectValue typedStoreValue = Variables.objectValue(Store)
.serializationDataFormat(SerializationDataFormats.JAVA)
.create();
execution.setVariable("store", typedStoreValue);
} catch (Exception e) {
e.getMessage();
}
} catch (Exception e) {
throw new BpmnError("cantCreateInstanceOfStore", "can't create Store");
}
} catch (SQLException e) {
throw new BpmnError("cantGetStoreFromECOM", "can't reach to DB");
}
}
}
Also I add connection to context.xml in
<Resource name="jdbc/tstECOM" auth="Container" type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://database.org:3306/ecom" username="user" password="password" maxTotal="20" maxIdle="10" maxWaitMillis="-1"/>
after deploy I try to run my process and got that:
org.camunda.bpm.engine.impl.pvm.PvmException: couldn't execute activity <serviceTask id="getStoreFromECOM" ...>: Name [comp/env/jdbc/tstECOM] is not bound in this Context. Unable to find [comp].
I'm newbie in Java & Camunda - maybe I should add resource from context.xml anywhere else?
I tried to add resource to Camunda's web.xml file, but it broke my container after restart