Camunda Spring Boot starter with embedded forms - java

I am trying to use embedded forms with a start event with the Camunda spring boot starter.
My startEvent is described like this:
<bpmn:startEvent id="StartEvent_1" name="Rechnungseingang" camunda:formKey="embedded:app:forms/rechnungseingang.html">
<bpmn:outgoing>SequenceFlow_0dtfc1a</bpmn:outgoing>
</bpmn:startEvent>
The form itself is located under "src/main/webapp/forms/rechnungseingang.html", from my understanding this should be the correct path.
If I try to start the process after starting the spring boot app, I am receiving the error: "Form failure: The context path is either empty or not defined."
In the browser console, I can see a request to http://localhost:8080/test/api/engine/engine/default/process-definition/Rechnungseingang:1:927f0aa4-e590-11e7-973d-e2cbd8678b9f/startForm with the response:
{"key":"embedded:app:forms/rechnungseingang.html","contextPath":null}
Obviously the application can't handle the null value in the contextPath. How am I able to set the contextPath for Camunda in Spring Boot? In the application.properties I already tried to set server.context-path with no effect.

1.) there is no src/main/webapp with spring boot applications, use src/main/resources/static
2.) for camunda to link the resource to the engine, you will need a process application. This is done easily by adding "#EnableProcessApplication" to your spring boot app.
3.) Autodeployment requires a src/main/resources/META-INF/processes.xml file, but you can leave it empty
4.) there is a full example for embedded forms with camunda spring boot here: https://github.com/camunda/camunda-bpm-examples/tree/master/spring-boot-starter/example-twitter

Related

What "no code generation“ in Spring Boot means

Spring Boot doc states "Absolutely no code generation and no requirement for XML configuration."
What is "code generation" in that context?
It states that Spring Boot doesn't generate or edit code
Spring Boot does not generate code or make edits to your files. Instead, when you start your application, Spring Boot dynamically wires up beans and settings and applies them to your application context.
It means no extra code is generated and executed except your code and spring boot dependencies you added

Use Spring Boot Cloud Config to change application.properties in classpath

I have to change my custom defined spring properties (defined via #ConfigurationProperties beans) during runtime of my Spring Boot application.
Is there any elegant way of doing this using Spring Cloud Config?
I don't want to use an external application.properties in a git repository (as the spring boot application gets shipped to customers and I dont' want to create a git repository for everyone of them).
I just want to access and change the local application.properties (the one in the classpath, located in src/main/resources) file in my Spring container or (if thats not possible) in the Spring Cloud Config Server, which I could embed into my Spring Boot app. Is that possible somehow?
BTW: The goal is to create a visual editor for the customers, so that they can change the application.properties during runtime in their spring boot app.
Spring Boot supports profile based application configuration. Just add application-<profile>.properties file. Then just when running the application select a profile depending on the environment making use of spring.profiles.active.
-Dspring.profiles.active=dev
This will run the application with application-dev.properties file (overriding the default application.properties, i.e you can just leave the common stuff in the default file and change the rest depending on the env)
On a side note, having a repo for configuration is not a must. You could just place them in the class path and give a search-location.
spring:
application:
name: config-server
profiles:
active: native
cloud:
config:
server:
native:
search-locations: classpath:configs/
It actually is possible and in the end quite easy to achieve. It just took me a whole day to get all the information together. Maybe this helps someone:
You basically just need Spring Actuator, but for a certain endpoint, you also need the spring cloud dependency. (to make Post requests to the /env endpoint of Spring Actuator)
To alter your config at runtime, just add the following to your application.properties:
management.endpoints.web.exposure.include: env,refresh
management.endpoint.env.post.enabled: true //this property is only available when spring cloud is added as dependency to your project
If you (like me) don't need the feature of an externalized config, then you also have to add the following (otherwise, your Spring app will not start and throw an error that some config is missing)
spring.cloud.config.enabled: false
Now, if you send a POST request to /actuator/env endpoint with an object in the HTTP body in the form of {"name":"...", "value":"..."} (name is the name of a config property), then your config gets changed. To check that, you can do a GET request to /actuator/env/[name_of_config_property] and see that your config property has changed. No need to restart your app.
Don't forget to secure the /actuator endpoint in your SecurityConfig if you use a custom one.
It seems to me that you neither need the #RefreshScope annotation at your config classes nor the /actuator/refresh endpoint to "apply" the config changes.
Maybe what your looking for could be achieved with Spring cloud config and spring cloud bus. It's explained here: https://cloud.spring.io/spring-cloud-config/reference/html/#_push_notifications_and_spring_cloud_bus
In summary, any change on configuration sent an event to the spring cloud bus and you can then reload app context or configuration with new properties.

Integrating Camunda webapps in spring framework

I setup Camunda in my Spring 3 project (Tomcat server) using this guide. I embedded the workflow engine in my project.
However, I cannot access the cockpit when I go to the url http://localhost:8080/camunda/app/. I get a 404 error.
I see that there is a dependency to be added in case of Spring boot according to this guide
But I see no such dependencies available for Spring. Do we not get access to webapps while integrating Camunda with Spring?
Also asked this question in the camunda form: https://forum.camunda.org/t/integrating-camunda-webapps-in-spring-framework/27661
You'll need the following dependency.
<dependency>
<groupId>org.camunda.bpm.webapp</groupId>
<artifactId>camunda-webapp-webjar</artifactId>
</dependency>
Then ensure you have the required configurations. Refer the spring boot auto configuration set up here and the web app initialiser here.

Not able to create custom error for Spring jersey application

We have a web based application with Front end in Angular JS 1 and REST service with Spring jersey frame work.We are using Spring 3.We have deployed our project in Tomcat 9.We have deployed angular js part as a separate project and REST service is build as a war file and deployed separately.
Suppose our application url is https://10.100.200.300:8443/DEMO.When we are trying to access the URL with a wrong value say https://10.100.200.300:8443/DEMO_TEST we are getting the error 404 i.e. resource not found by the tomcat server.We want to show some customized error page for 404 or any other tomcat error. Please suggest how to do it?
You can have a look here - Configure spring boot to redirect 404 to a single page app
Make spring configuration as mentioned in above answer and reroute it to your desired page.

Spring Boot - Proper location for html files

I am new to Spring Boot and I am trying to add a simple html page for my project
At the moment, my project's structure is the following:
Having read the following:
https://spring.io/blog/2013/12/19/serving-static-web-content-with-spring-boot
http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-web-applications.html#boot-features-spring-mvc-static-content
and other answers in StackOverflow, I'd expect to see the contents of index.html when I visit http://localhost:8080/
What could I be missing?
As there is no webapp in SpringBoot project , we can place the html files in either in
src/main/resources/resources/index.html
src/main/resources/static/index.html
src/main/resources/public/index.html
Remember the above is in highest to lowest precedence.
To check your file run the main class in eclipse and go to http://localhost:8080/index.html
First of all the correct way to serve files in Spring Boot is described in
cannot find html pages with spring boot
After adding the directories required, I tried /services/login.html where "services" is the mapping for my Dispatcher servlet.
So what happens here is that Spring Boot will only answer to requests sent to /services/* even if these requests are pointing to something other than a controller.
I guess that this makes sense in the world of Spring Boot but when I tried in the same in a Spring MVC project (no Spring Boot) I was able to access simple html files that I had simply added into my WEB-INF directory

Categories

Resources