Skip to content

Commit

Permalink
[#66] Activiti crashes (ClassNotFoundException: javax.script.ScriptEn…
Browse files Browse the repository at this point in the history
…gineFactory not found) on default org.codehaus.groovy:groove-all:META-INF/services/javax.script.ScriptEngineFactory with comments inside it
  • Loading branch information
vharseko committed Aug 21, 2024
1 parent 7bf71c2 commit b243523
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion custom-scripted-connector-bundler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,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
1 change: 1 addition & 0 deletions openidm-zip/src/main/assembly/zip.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,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 b243523

Please sign in to comment.