Skip to content

Commit

Permalink
[#66] Activiti crashes (ClassNotFoundException: javax.script.ScriptEn…
Browse files Browse the repository at this point in the history
…ineFactory not found) on default org.codehaus.groovy:groove-all:META-INF/services/javax.script.ScriptEngineFactory with comments inside it (#68)
  • Loading branch information
vharseko authored Aug 21, 2024
1 parent 7bf71c2 commit 86db4cf
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
4 changes: 3 additions & 1 deletion custom-scripted-connector-bundler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
with the fields enclosed by brackets [] replaced by
your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"
Portions Copyrighted 2019-2024 3A Systems LLC.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -148,7 +150,7 @@
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.2.2</version>
<version>${groovy.version}</version>
</dependency>
</dependencies>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import javax.script.ScriptEngine;
import javax.sql.DataSource;
import javax.transaction.TransactionManager;
import org.activiti.engine.ProcessEngine;
Expand All @@ -44,6 +45,8 @@
import org.activiti.engine.impl.interceptor.SessionFactory;
import org.activiti.engine.impl.scripting.ResolverFactory;
import org.activiti.engine.impl.scripting.ScriptBindingsFactory;
import org.activiti.engine.impl.scripting.ScriptingEngines;
import org.activiti.osgi.Extender;
import org.activiti.osgi.OsgiScriptingEngines;
import org.activiti.osgi.blueprint.ProcessEngineFactory;
import org.forgerock.openidm.datasource.DataSourceService;
Expand Down Expand Up @@ -74,7 +77,10 @@
import org.forgerock.openidm.workflow.activiti.impl.session.OpenIDMSessionFactory;
import org.forgerock.util.promise.Promise;
import org.h2.jdbcx.JdbcDataSource;
import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceFactory;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
import org.osgi.service.component.ComponentContext;
Expand Down Expand Up @@ -471,12 +477,37 @@ protected void unbindProcessEngine(ProcessEngine processEngine) {
target = "(service.pid=org.forgerock.openidm.script)")
protected void bindScriptRegistry(ScriptRegistry scriptRegistry) {
this.idmSessionFactory.setScriptRegistry(scriptRegistry);
Extender.getBundleContext().registerService(Extender.ScriptEngineResolver.class, new ServiceFactory<Extender.ScriptEngineResolver>() {
@Override
public Extender.ScriptEngineResolver getService(Bundle bundle, ServiceRegistration<Extender.ScriptEngineResolver> serviceRegistration) {
return new Extender.ScriptEngineResolver() {
@Override
public ScriptEngine resolveScriptEngine(String s) {
if (!"groovy".equalsIgnoreCase(s)) {
throw new RuntimeException("unknown resolveScriptEngine "+s);
}
return new org.codehaus.groovy.jsr223.GroovyScriptEngineImpl();
}
};
};

@Override
public void ungetService(Bundle bundle, ServiceRegistration<Extender.ScriptEngineResolver> serviceRegistration, Extender.ScriptEngineResolver scriptEngineResolver) {

}
},null);
}

protected void unbindScriptRegistry(ScriptRegistry scriptRegistry) {
this.idmSessionFactory.setScriptRegistry(null);
}

@Reference(
name = "JavaDelegateServiceReference",
service = JavaDelegate.class,
unbind = "unbindService",
cardinality = ReferenceCardinality.MULTIPLE,
policy = ReferencePolicy.DYNAMIC)
public void bindService(JavaDelegate delegate, Map<String, Object> props) {
expressionManager.bindService(delegate, props);
}
Expand Down
2 changes: 2 additions & 0 deletions openidm-zip/src/main/assembly/zip.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
information: "Portions Copyrighted [year] [name of copyright owner]".
Copyright (c) 2011-2016 ForgeRock AS. All rights reserved.
Portions Copyrighted 2019-2024 3A Systems LLC.
-->
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand Down Expand Up @@ -1207,6 +1208,7 @@
<exclude>org.apache.httpcomponents:httpcore</exclude>
<exclude>jakarta*</exclude>
<exclude>org.bouncycastle:bc*-fips</exclude>
<exclude>org.openjdk.nashorn:*</exclude>
</excludes>
</dependencySet>
<dependencySet>
Expand Down

0 comments on commit 86db4cf

Please sign in to comment.