cancel
Showing results for 
Search instead for 
Did you mean: 

activiti & osgi, book examples

christoph_retti
Champ in-the-making
Champ in-the-making
Hi, I tried to run activit 5.8 & osgi installation steps as described in "Activiti in Action MEAP v8" (page 230)  and after installing the book-osgi example I get an exeption
saying


karaf@root> D:\dev\svc\apache-karaf-2.2.5\bin>karaf.bat
        __ __                  ____
       / //_/____ __________ _/ __/
      / ,<  / __ `/ ___/ __ `/ /_
     / /| |/ /_/ / /  / /_/ / __/
    /_/ |_|\__,_/_/   \__,_/_/

  Apache Karaf (2.2.5)

Hit '<tab>' for a list of available commands
and '[cmd] –help' for help on a specific command.
Hit '<ctrl-d>' or 'osgi:shutdown' to shutdown Karaf.

karaf@root> features:list
State         Version           Name                          Repository             Description
[installed  ] [3.0.5.RELEASE  ] spring                        book-osgi-1.0.0
[installed  ] [5.8            ] activiti                      book-osgi-1.0.0
[installed  ] [1.0.0          ] book-osgi                     book-osgi-1.0.0
[uninstalled] [0.3            ] transaction                   karaf-enterprise-2.2.5 OSGi Transactio
n Manager
[uninstalled] [0.3            ] jpa                           karaf-enterprise-2.2.5 OSGi Persistenc
e Container
[uninstalled] [0.3            ] jndi                          karaf-enterprise-2.2.5 OSGi Service Re
gistry JNDI access
[uninstalled] [0.3            ] application-without-isolation karaf-enterprise-2.2.5
[uninstalled] [2.2.5          ] karaf-framework               karaf-2.2.5
[uninstalled] [2.5.6.SEC02    ] spring                        karaf-2.2.5
[uninstalled] [2.5.6.SEC02    ] spring-web                    karaf-2.2.5
[uninstalled] [3.0.6.RELEASE  ] spring                        karaf-2.2.5
[uninstalled] [3.0.6.RELEASE  ] spring-aspects                karaf-2.2.5
[uninstalled] [1.2.1          ] spring-dm                     karaf-2.2.5
[uninstalled] [1.2.1          ] spring-dm-web                 karaf-2.2.5
[uninstalled] [3.0.6.RELEASE  ] spring-instrument             karaf-2.2.5
[uninstalled] [3.0.6.RELEASE  ] spring-jdbc                   karaf-2.2.5
[uninstalled] [3.0.6.RELEASE  ] spring-jms                    karaf-2.2.5
[uninstalled] [3.0.6.RELEASE  ] spring-struts                 karaf-2.2.5
[uninstalled] [3.0.6.RELEASE  ] spring-test                   karaf-2.2.5
[uninstalled] [3.0.6.RELEASE  ] spring-orm                    karaf-2.2.5
[uninstalled] [3.0.6.RELEASE  ] spring-oxm                    karaf-2.2.5
[uninstalled] [3.0.6.RELEASE  ] spring-tx                     karaf-2.2.5
[uninstalled] [3.0.6.RELEASE  ] spring-web                    karaf-2.2.5
[uninstalled] [3.0.6.RELEASE  ] spring-web-portlet            karaf-2.2.5
[uninstalled] [2.2.5          ] wrapper                       karaf-2.2.5
[uninstalled] [2.2.5          ] obr                           karaf-2.2.5
[installed  ] [2.2.5          ] config                        karaf-2.2.5
[uninstalled] [7.5.4.v20111024] jetty                         karaf-2.2.5
[uninstalled] [2.2.5          ] http                          karaf-2.2.5
[uninstalled] [2.2.5          ] war                           karaf-2.2.5
[installed  ] [2.2.5          ] kar                           karaf-2.2.5
[uninstalled] [2.2.5          ] webconsole-base               karaf-2.2.5
[uninstalled] [2.2.5          ] webconsole                    karaf-2.2.5
[installed  ] [2.2.5          ] ssh                           karaf-2.2.5
[installed  ] [2.2.5          ] management                    karaf-2.2.5
[uninstalled] [2.2.5          ] eventadmin                    karaf-2.2.5
[uninstalled] [2.2.5          ] jasypt-encryption             karaf-2.2.5
karaf@root> org.h2.jdbc.JdbcSQLException: Verbindung ist unterbrochen: "Connection refused: connect"

Connection is broken: "Connection refused: connect" [90067-143]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:327)
        at org.h2.message.DbException.get(DbException.java:156)
        at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:380)
        at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:271)
        at org.h2.engine.SessionRemote.createSession(SessionRemote.java:265)
        at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:110)
        at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:94)
        at org.h2.jdbcx.JdbcDataSource.getJdbcConnection(JdbcDataSource.java:179)
        at org.h2.jdbcx.JdbcDataSource.getConnection(JdbcDataSource.java:154)
        at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.initDatabaseType(ProcessEngin
eConfigurationImpl.java:475)
        at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.initDataSource(ProcessEngineC
onfigurationImpl.java:438)
        at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.init(ProcessEngineConfigurati
onImpl.java:293)
        at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.buildProcessEngine(ProcessEng
ineConfigurationImpl.java:270)
        at org.activiti.osgi.blueprint.ProcessEngineFactory.init(ProcessEngineFactory.java:46)
        at org.activiti.osgi.blueprint.ProcessEngineFactoryWithELResolver.init(ProcessEngineFactoryW
ithELResolver.java:22)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:226)
        at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:824)
        at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:636)
        at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:724)
        at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:64)
        at org.apache.aries.blueprint.di.RefRecipe.internalCreate(RefRecipe.java:60)
        at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:64)
        at org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:218)
        at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:706)
        at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:64)
        at org.apache.aries.blueprint.di.RefRecipe.internalCreate(RefRecipe.java:60)
        at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:64)
        at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintReposit
ory.java:219)
        at org.apache.aries.blueprint.container.BlueprintRepository.createInstance(BlueprintReposito
ry.java:198)
        at org.apache.aries.blueprint.container.BlueprintRepository.create(BlueprintRepository.java:
137)
        at org.apache.aries.blueprint.container.ServiceRecipe.createRecipe(ServiceRecipe.java:370)
        at org.apache.aries.blueprint.container.ServiceRecipe.createService(ServiceRecipe.java:278)
        at org.apache.aries.blueprint.container.ServiceRecipe.internalGetService(ServiceRecipe.java:
248)
        at org.apache.aries.blueprint.container.ServiceRecipe.getService(ServiceRecipe.java:327)
        at org.apache.aries.blueprint.container.ServiceRecipe$TriggerServiceFactory.getService(Servi
ceRecipe.java:430)
        at org.apache.felix.framework.ServiceRegistrationImpl.getFactoryUnchecked(ServiceRegistratio
nImpl.java:310)
        at org.apache.felix.framework.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.jav
a:221)
        at org.apache.felix.framework.ServiceRegistry.getService(ServiceRegistry.java:297)
        at org.apache.felix.framework.Felix.getService(Felix.java:3021)
        at org.apache.felix.framework.BundleContextImpl.getService(BundleContextImpl.java:329)
        at org.activiti.osgi.Extender.addingService(Extender.java:89)
        at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:896)
        at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:261)
        at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:233)
        at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:840)
        at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispat
cher.java:871)
        at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java
:733)
        at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:662
)
        at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:3772)
        at org.apache.felix.framework.Felix.access$000(Felix.java:80)
        at org.apache.felix.framework.Felix$2.serviceChanged(Felix.java:729)
        at org.apache.felix.framework.ServiceRegistry.registerService(ServiceRegistry.java:107)
        at org.apache.felix.framework.Felix.registerService(Felix.java:2861)
        at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:251)
        at org.apache.aries.blueprint.container.BlueprintContainerImpl.registerService(BlueprintCont
ainerImpl.java:404)
        at org.apache.aries.blueprint.container.ServiceRecipe.register(ServiceRecipe.java:184)
        at org.apache.aries.blueprint.container.BlueprintContainerImpl.registerServices(BlueprintCon
tainerImpl.java:662)
        at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.
java:330)
        at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.ja
va:227)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Scheduled
ThreadPoolExecutor.java:98)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadP
oolExecutor.java:206)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
Caused by: java.net.ConnectException: Connection refused: connect
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:529)
        at org.h2.util.NetUtils.createSocket(NetUtils.java:109)
        at org.h2.util.NetUtils.createSocket(NetUtils.java:91)
        at org.h2.engine.SessionRemote.initTransfer(SessionRemote.java:91)
        at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:376)
        … 68 more


Does anyone experience similar issues?

  regards, chris
4 REPLIES 4

bidek
Champ in-the-making
Champ in-the-making
Exception "says": cant connect to database, connection refused

It may by firewall issue, or misconfigured database.
Check for example, whether the database is running or database socket accepting connections

christoph_retti
Champ in-the-making
Champ in-the-making
hmm … its using the embedded h2 database, so I guess it should be auto-started with the engine?

christoph_retti
Champ in-the-making
Champ in-the-making
Hi together, I found the source of the problem: in the blueprint of the book-osgi-engine
the H2 datasource is specified as


  <bean id="dataSource" class="org.h2.jdbcx.JdbcDataSource">
    <property name="URL" value="jdbc:h2:tcp://localhost/activiti" />
    <property name="user" value="sa" />
    <property name="password" value="" />
  </bean>

but should at least be


  <bean id="dataSource" class="org.h2.jdbcx.JdbcDataSource">
    <property name="URL" value="jdbc:h2:tcp://localhost/~/activiti" />
    <property name="user" value="sa" />
    <property name="password" value="" />
  </bean>

Note the ~ in jdbc:h2:tcp://localhost/~/activiti as this will then make H2 create the database in the users folder where it has
enough rights under Windows 7.

Nevertheless this approach (at least I think so) is not the ideal one as it requires H2 to be started in server mode and therefore needs
a process to run outside of Karaf.

Maybe the best solution (at least for the demo) would be to use

 
  <bean id="dataSource" class="org.h2.jdbcx.JdbcDataSource">
    <property name="URL" value="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000" />
    <property name="user" value="sa" />
    <property name="password" value="" />
  </bean>

so, starting H2 in memory mode. This way there are no dependencies outside of OSGI and the demo runs nicely.

I hope the book authors read this post, so they can correct this in the sources.

  regards, Chris

trademak
Star Contributor
Star Contributor
Hi,

We decided to use a standalone H2 database instance just like for example the Activiti Explorer.
I don't see why this would be wrong approach. And then the current database URL is also fine.
If you want to run it embedded, that's just fine and you can use the configuration as you described.

Best regards,