isis-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vladimir Nišević <>
Subject Integration of Raspberry PI with Isis - issue with IsisContext.getSessionFactory().doInSession(),
Date Mon, 21 Aug 2017 18:33:12 GMT
Hi, I am using Isis framework with Raspberry PI (RPI) , and use PI4J ( ) to read/write GPIO (general input/ouptut pins) and to
listen on external events happen on the GPIO pins.  E.g. when an button on
RPI connected to specific pin is pressed.

The PI4J documentation explains how to do that

When my application tries to access Isis persistence layer based on GPIO
event, I get next exception:

[main] INFO org.eclipse.jetty.server.Server - Started @39099ms
Exception in thread "pi4j-gpio-event-executor-0"
java.lang.RuntimeException: An error occurred while executing code in
a temporary session
        at org.apache.isis.core.runtime.system.session.IsisSessionFactory.doInSession(
        at org.apache.isis.core.runtime.system.session.IsisSessionFactory.doInSession(
        at org.apache.isis.core.runtime.system.session.IsisSessionFactory.doInSession(
        at domainapp.modules.simple.dom.rpi.RaspberryClient.handleGpioPinDigitalStateChangeEvent(
        at java.util.concurrent.ThreadPoolExecutor.runWorker(
        at java.util.concurrent.ThreadPoolExecutor$
Caused by: java.lang.NullPointerException
        at org.apache.isis.applib.query.QueryAbstract.getResultType(
        at org.apache.isis.core.runtime.system.persistence.PersistenceQueryFactory.specFor(
        at org.apache.isis.core.runtime.system.persistence.PersistenceQueryFactory.createPersistenceQueryFor(
        at org.apache.isis.core.runtime.system.persistence.PersistenceSession.createPersistenceQueryFor(
        at org.apache.isis.core.runtime.system.persistence.PersistenceSession.findInstancesInTransaction(
        at org.apache.isis.core.runtime.system.persistence.PersistenceSession.allMatchingQuery(
        at domainapp.modules.simple.dom.rpi.RaspberryClient.lambda$handleGpioPinDigitalStateChangeEvent$0(
        at org.apache.isis.core.runtime.system.session.IsisSessionFactory$
        at org.apache.isis.core.runtime.system.session.IsisSessionFactory$
        at org.apache.isis.core.runtime.system.session.IsisSessionFactory.doInSession(
        ... 7 more

I do basically the same as in other situations where I need to get/attach
IsisSession, but here I get exception, as I can't create transaction. I
guess it has something with the way how PI4J calls event handler, but not
sure how to deal with this.

Here the piece of code shows RPI integration and event handling (also
available in my Github Isis fork. )

It works only on RPI device, so it can't be reproduced in windows

I tried also to declare event handler method
as synchronized, but get the same result.

Here the domain service where I get the exception - whole example is on my
Github Simpleapp fork

DomainService(nature = NatureOfService.DOMAIN)
public class RaspberryClient implements GpioPinListenerDigital {

    private GpioController gpio = null;
    private GpioPinDigitalInput pinPushKey;

    public void initializeRpiGpioDevices() {
        if (gpio == null) {
            if (!System.getProperty("").startsWith("Linux")) {
                log.warn("Recognized operating system: " +
System.getProperty("") + ",RPI GPIO deactivated");

            gpio = GpioFactory.getInstance();
            if (gpio == null) {
                log.warn("RPI GPIO controller initialization failed!");
  "RPI GPIO controller initialized");

        pinPushKey = gpio

"GPIO_16_PUSH_KEY", PinPullResistance.PULL_UP);
        // hornPushedKeyListener = new HornPushKeyListener(this);

    public void shutdown() {
        if (gpio == null) {
        }"Shutting down RPI GPIO controller");

    @Override public void handleGpioPinDigitalStateChangeEvent(final
GpioPinDigitalStateChangeEvent gpioPinDigitalStateChangeEvent) {
        log.debug("Push key on GPIO 16, pressed");
        IsisContext.getSessionFactory().doInSession(() -> {
            // just a test to check if we can access to persistence
layer when GPIO event handler fired
  "Found devices" +

    @Inject RepositoryService repositoryService;


Maybe somebody has an idea how to solve this?


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message