Starting Cockpit in Embedded mode

I’m trying to deploy Cockpit on jetty using embedded mode.
Here is the main class I used for this:


I run this class using these commands:
mvn exec:java -Dexec.mainClass=“org.camunda.bpm.Main”
but I got this exception:
2020-05-05 17:50:22.638:WARN:oejuc.AbstractLifeCycle:FAILED o.e.j.w.WebAppContext{/camunda,file:/home/shehab/git/webalo/camunda-bpm-webapp/src/main/java/org/camunda/bpm/cockpit/impl/web/bootstrap/}: java.lang.NoClassDefFoundError: org/camunda/bpm/engine/ProcessEngineException
java.lang.NoClassDefFoundError: org/camunda/bpm/engine/ProcessEngineException
at org.camunda.bpm.cockpit.impl.web.bootstrap.CockpitContainerBootstrap$CockpitEnvironment.setup(CockpitContainerBootstrap.java:61)
at org.camunda.bpm.cockpit.impl.web.bootstrap.CockpitContainerBootstrap.contextInitialized(CockpitContainerBootstrap.java:40)
at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:782)
at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:424)
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:774)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:249)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1242)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:494)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
at org.eclipse.jetty.server.Server.doStart(Server.java:282)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.camunda.bpm.Main.main(Main.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:293)
at java.lang.Thread.run(Thread.java:748)

If I had to guess, you’re missing a number of dependencies (e.g. camunda-engine). Take a closer look at the project dependencies and make sure you have the necessary ones available on your class path.

Maybe even start with mvn jetty:run -Pdevelop.

Thank you for your response.
I think I have included them all.

Actually this main runs well when using webAppContext.setWar(). So I think there isn’t any problem with the project configuration.

Do you think mvn jetty:run -Pdevelop will run my Main class too ?

No, I just meant mvn jetty:run -Pdevelop from the camunda-bpm-webapp project just to get you started with something, but it sounds like you have something running already.

The profile snippet you posted, is that from your pom? I wouldn’t expect those dependencies to be pulled in if you’re running mvn exec:java -Dexec.mainClass=“org.camunda.bpm.Main”.

Can you share your project on Github or somewhere similar? It’s hard to say without knowing more about your setup, but your stack is fairly straightforward with java.lang.NoClassDefFoundError.

Yes, It’s from my pom. I could run the project on jetty using mvn jetty:run -Pdevelop.
But I’m trying to run jetty in embedded mode so I made .war file from my project and make small main that uses webAppContext.setWar it works fine. But now I’m trying to make a self-executable war. So I added the main class into the camunda project it self.
The project tree is like:


This project was cloned from: git clone git@github.com:camunda/camunda-bpm-webapp.git

I still think you’re having dependencies issues based on the maven command you’re running. Notice, mvn -Pdevelop exec:java -Dexec.mainClass=“org.camunda.bpm.Main” gives you a different result.

It’s hard to make a recommendation for a project structure without having a better idea of what you’re trying to achieve. Even harder trying to wedge it in the context of the camunda-bpm-webapp project.

2 Likes

Thanks this command works with me.