How to use spring-cloud-task with spring-cloud-deployer-cloudfoundry? - spring-cloud

I am investigating using spring-cloud-task to execute short-lived jobs in my Cloud Foundry environments.
Looking through the documentation and some youtube videos, I gathered that there should be 3 components (applications) involved for my setup:
The task-requester: a spring-boot app that places a TaskLaunchRequest on a spring-cloud-stream Rabbit/Kafka queue/topic
The task-launcher: a spring-boot app annotated with #EnableTaskLauncher and which has the following dependencies: spring-cloud-starter-task, spring-cloud-starter-stream-rabbit, spring-cloud-deployer-cloudfoundry, spring-cloud-deployer-resource-maven
The task-definition: a spring-boot app annotated with #EnableTask and which has the logic to be performed by the short-lived job
I have several questions about the process and configurations required to get a task deployed in CloudFoundry using this setup.
What is the difference between configuring environmentProperties, deploymentProperties and applicationName in the TaskLaunchRequest (in the task-submitter) versus configuring the CloudFoundryDeploymentProperties (in the task-launcher)? Also, where should the SPRING_APPLICATION_JSON be defined and what does it do exactly?
All of the examples I have seen for spring-cloud-task use the maven:// scheme to indicate the TaskLaunchRequest#uri. Why doesn't the spring-cloud-deployer-cloudfoundry dependency come bundled with the spring-cloud-deployer-resource-maven dependency? Is there a different URI scheme that is preferred when deploying to CloudFoundry?
When I cf-push the task bootJar to Cloud Foundry with instances=0, when the task-launcher launches the task then everything works fine. The only problem in this case is that even when publishing a new version of the SNAPSHOT bootJar to the remote repository, the original bootJar from the cf-push is used instead (even when setting maven.remote-repositories.my-repo.snapshot-policy.update-policy: always). Is the maven artifact not actually considered if the Cloud Foundry application is already defined for the application that is trying to be dynamically executed by spring-cloud-task? In other words, does every new version (SNAPSHOT or RELEASE) of the maven artifact require a new Cloud Foundry application?
When I do not cf-push the task bootJar to Cloud Foundry and do not pre-create the task application, then I expect that the task-launcher will create the application in Cloud Foundry for me using the maven artifact I specified (with spring.cloud.deployer.cloudfoundry.push-task-apps-enabled: true). When I attempt this, then I get an error in the launcher indicating Application [...] failed during stagingand this error stems from the following:org.cloudfoundry.operations.applications.DefaultApplications.pushManifest(DefaultApplications.java:431)`. I can see that the task-launcher has created the application in Cloud Foundry successfully, but that it failed to stage it. What am I missing to get this working?
Here are the logs from the task application that fails to stage:
2020-09-25T14:05:43.69-0400 [API/2] OUT Uploading bits for app with guid d598b251-4827-4c55-9e56-1d0c8301b5c3
2020-09-25T14:05:59.66-0400 [API/0] OUT Updated app with guid d598b251-4827-4c55-9e56-1d0c8301b5c3 ({"state"=>"STOPPED"})
2020-09-25T14:06:00.26-0400 [API/0] OUT Creating build for app with guid d598b251-4827-4c55-9e56-1d0c8301b5c3
2020-09-25T14:06:00.61-0400 [API/0] OUT Updated app with guid d598b251-4827-4c55-9e56-1d0c8301b5c3 ({"state"=>"STARTED"})
2020-09-25T14:06:01.00-0400 [STG/0] OUT Cell 884d3852-1063-452a-8e94-c11ea9307c4a creating container for instance cc9b7101-2fc4-4c56-9f86-019736eb6b71
2020-09-25T14:06:01.79-0400 [STG/0] OUT Cell 884d3852-1063-452a-8e94-c11ea9307c4a successfully created container for instance cc9b7101-2fc4-4c56-9f86-019736eb6b71
2020-09-25T14:06:01.95-0400 [STG/0] OUT Downloading app package...
2020-09-25T14:06:02.37-0400 [STG/0] OUT Downloaded app package (12.4M)
2020-09-25T14:06:04.08-0400 [STG/0] OUT -----> Java Buildpack v4.29.1 | https://github.com/cloudfoundry/java-buildpack.git#3dbe582
2020-09-25T14:06:04.08-0400 [STG/0] ERR [Buildpack] ERROR Finalize failed with exception #<RuntimeError: No container can run this application. Please ensure that you've pushed a valid JVM artifact or artifacts using the -p command line argument or path manifest entry. Information about valid JVM artifacts can be found at https://github.com/cloudfoundry/java-buildpack#additional-documentation. >
2020-09-25T14:06:04.08-0400 [STG/0] ERR No container can run this application. Please ensure that you've pushed a valid JVM artifact or artifacts using the -p command line argument or path manifest entry. Information about valid JVM artifacts can be found at https://github.com/cloudfoundry/java-buildpack#additional-documentation.
2020-09-25T14:06:04.08-0400 [STG/0] ERR Failed to compile droplet: Failed to run finalize script: exit status 1
2020-09-25T14:06:04.11-0400 [STG/0] OUT Exit status 223
2020-09-25T14:06:04.52-0400 [STG/0] OUT Cell 884d3852-1063-452a-8e94-c11ea9307c4a stopping instance cc9b7101-2fc4-4c56-9f86-019736eb6b71
2020-09-25T14:06:04.52-0400 [STG/0] OUT Cell 884d3852-1063-452a-8e94-c11ea9307c4a destroying container for instance cc9b7101-2fc4-4c56-9f86-019736eb6b71
2020-09-25T14:06:04.61-0400 [API/4] ERR Failed to stage build: staging failed
2020-09-25T14:06:05.15-0400 [STG/0] OUT Cell 884d3852-1063-452a-8e94-c11ea9307c4a successfully destroyed container for instance cc9b7101-2fc4-4c56-9f86-019736eb6b71
Following what was said in the logs, I have checked that the maven artifact is in fact a valid bootJar of 15.1MB, but the logs show that my app package is only "12.4M". The buildpack version (4.29.1) is also not the version I indicated in spring.cloud.deployer.cloudfoundry.buildpacks property. I think the problem may be with the buildpack configuration not being set correctly, but I'm not sure.
Note: I do not want to introduce spring-cloud-dataflow into my architecture at this time.

For the discrepancy between a manual cf push and a CF Java Client app deployment, I finally discovered that the reactive cf java-client 4.0.9.RELEASE+ has an issue with Netty 4.1.51.Final where Netty fails to perform file uploads. I upgraded my dependencies to use Netty 4.1.52.Final and now the client is able to properly deploy my application.
See https://github.com/cloudfoundry/cf-java-client/releases for the details of the issue between these 2 components.

Related

Try to run sbt shell gives me error server failed to start error 5

I was following the tutorial for build an scalable websocket app in Heroku, following the tutorial Writing Scalable WebSocket Applications on Heroku and trying to set up Play Framework to work on Eclipse IDE, downloaded play-samples-play-java-hello-world-tutorial from Play Framework site, added sbt-plugin annotation in plugins.sbt file, git bashed from project folder and tried the command sbt, it gives me, following error and I can't proceed with compile command:
server failed to start on local:sbt-server-cc02d04ca19b451f676c. java.io.IOException: Could
not create lock for \\.\pipe\sbt-server-cc02d04ca19b451f676c_lock, error 5

Exception creating solver in KIE execution server

I am trying to deploy my kjar to KIE execution server but getting an exception while creating a solver 'taskPlanningSolver' using PUT on URL:
http://localhost:8080/kie-server/services/rest/server/containers/taskplanning1/solvers/taskPlanningSolver
Here's what I have:
A. I have a KIE execution server running on tomcat(windows). It supports BRMS and BPM.
B. I have a maven project (that uses optaplanner) and it's installed to my local maven repo.
C. I successfully created a container in KIE server using PUT on:
http://localhost:8080/kie-server/services/rest/server/containers/taskplanning1
with body:
<kie-container container-id="taskplanning1">
<release-id>
<group-id>com.kairos.planning</group-id>
<artifact-id>task-planning</artifact-id>
<version>1.0.1-SNAPSHOT</version>
</release-id>
</kie-container>
I need help with creating a solver which is throwing exception:
"Unexpected error during processing: sun.reflect.annotation.TypeNotPresentExceptionProxy"
Notes:
I do have kmodule.xml in jar installed in maven repo and its inside META-INF and it's content is only:
2017-08-30 11:56:07,977 ERROR [org.kie.server.remote.rest.optaplanner.SolverResource] (default task-3) Unexpected error creating solver 'taskPlanningSolver' on container 'taskplanning2': sun.reflect.annotation.TypeNotPresentExceptionProxy: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:724)
at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:531)
at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:355)
at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:286)
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120)
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72)
at java.lang.Class.createAnnotationData(Class.java:3521)
at java.lang.Class.annotationData(Class.java:3510)
at java.lang.Class.getAnnotation(Class.java:3415)
at com.thoughtworks.xstream.mapper.AnnotationMapper$UnprocessedTypesSet.add(AnnotationMapper.java:614)
at com.thoughtworks.xstream.mapper.AnnotationMapper$UnprocessedTypesSet.add(AnnotationMapper.java:599)
at com.thoughtworks.xstream.mapper.AnnotationMapper.processAnnotations(AnnotationMapper.java:162)
at com.thoughtworks.xstream.XStream.processAnnotations(XStream.java:2036)
at com.thoughtworks.xstream.XStream.processAnnotations(XStream.java:2047)
at org.kie.server.api.marshalling.xstream.XStreamMarshaller.configureMarshaller(XStreamMarshaller.java:186)
at org.kie.server.api.marshalling.xstream.XStreamMarshaller.<init>(XStreamMarshaller.java:103)
at org.kie.server.api.marshalling.BaseMarshallerBuilder.build(BaseMarshallerBuilder.java:37)
at org.kie.server.api.marshalling.MarshallerFactory.getMarshaller(MarshallerFactory.java:52)
at org.kie.server.services.impl.KieContainerInstanceImpl.getMarshaller(KieContainerInstanceImpl.java:175)
I also see a lot of exceptions while creating container but container gets created successfully. All the errors are NoClassDefFoundError and even though I added all the dependencies to my project's pom I still get a new class that causes NoClassDefFoundError.
I also dont have a good guide to deploy kjar to kie execution server. I'll be creating one after successfully testing it. Please help if possible. Thanks in advance.
The Kie execution server already has optaplanner jars and it has all the dependencies that will ever be need including all logging dependencies. So, you need to make sure your project's pom has zero runtime dependencies. All the dependencies you require in your project should be marked provided scope like:
<dependency>
<groupId>org.optaplanner</groupId>
<artifactId>optaplanner-persistence-common</artifactId>
<version>${version.optaplanner.bom}</version>
<scope>provided</scope>
</dependency>

Error while Deploying WAR in WebSphere using ANT

We are trying to checkout, build and deploy EAR files ( IBM Integration Designer developed Mediation Modules.. but mostly similar to Java EAR files ). While deploying to WAS ND I am getting the below error...
[wsadmin] WASX7017E: Exception received while running file "C:\Users\INSTAL~2\AppData\Local\Temp\wsant1588202279705404612jacl"; exception information: com.ibm.ws.scripting.ScriptingException: WASX7132E: Application install for C:\Ant_Automation\ESB\MMCheckout\KY_SF1520_CPRServices_MMApplication\KY_SF1520_CPRServices_MM.ear failed: see previous messages for details.
[wsadmin] WASX7341W: No "save" was performed before the interactive scripting session exited; configuration changes will not be saved.
BUILD FAILED
C:\Ant_Automation\ESB\build.xml:124: Java returned: 105
Total time: 1 minute 53 seconds
I think we have to save the configuration after deployment in a ND deployment, but I am not sure how we can save using ANT.
DMGR System log
[28-06-16 16:43:13:572 CEST] 000003ef InstallSchedu I ADMA5016I: Installation of KY_SF1520_CPRServices_MMApp started.
[28-06-16 16:43:14:384 CEST] 000003ef Configuration I com.ibm.bpm.config.spi.ConfigurationSpi getDeploymentEnvironment Effective deployment target is WebSphere:cell=KYDevBMP02Cell01,node=KYDevBMP02CellManager01,server=dmgr
[28-06-16 16:43:14:400 CEST] 000003ef Configuration I com.ibm.bpm.config.spi.ConfigurationSpi getDeploymentEnvironment Effective deployment target is WebSphere:cell=KYDevBMP02Cell01,node=KYDevBMP02CellManager01,server=dmgr
[28-06-16 16:43:14:493 CEST] 000003ef WBIAAbstractT I com.ibm.ws.wbia.deployment.WBIAAbstractTask performTask CWLRD0101I: No WebSphere Business Integration Adapter files are found in the application KY_SF1520_CPRServices_MMApp.
[28-06-16 16:43:15:134 CEST] 000003ef Configuration I com.ibm.bpm.config.spi.ConfigurationSpi getDeploymentEnvironment Effective deployment target is WebSphere:cell=KYDevBMP02Cell01,node=KYDevBMP02CellManager01,server=dmgr
[28-06-16 16:43:15:149 CEST] 000003ef InstallSchedu I ADMA5014E: The installation of application KY_SF1520_CPRServices_MMApp failed.
You don't need to save if you are using , check this link for Ant script example Using Ant scripts for testing in headless WebSphere Business Process Manager
You have to look for error details either in the Ant console output or server SystemOut.log.
Look at your messages:
Effective deployment target is WebSphere:cell=KYDevBMP02Cell01,node=KYDevBMP02CellManager01,server=dmgr
This is not correct, you are installing application to either Cluster of some server, but for sure not DeploymentManager.
You have to provide options to your wsInstallApp task that will define target. See AdminApp.install command for details.

Maven offline build fails when it encouners google guava url with invalid character

I need to make my Tycho-Maven build work in offline mode, so I can deploy it to environments with no Internet connection and let people run the build from the previously downloaded artifacts for the third party code my app depends on. The product being built is an Eclipse RCP product, using the org.eclipse.tycho:target-platform-configuration plug-in to load the dependencies from an RCP target file.
First I run mvn -Dmaven.repo.local=/some/path/ -DgeneratePom=true clean install to create the artifacts, and that build succeeds. Then when I run mvn -Dmaven.repo.local=/some/path/ -o clean install it fails because it's running in offline mode and there is no local cache available for http://download.eclipse.org/tools/cdt/releases/8.6
So then I run mvn -Dmaven.repo.local=/some/path/ dependency:go-offline to make it download all the artifacts it needs for the build, but it fails with this message:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-dependency-plugin:2.8:resolve-plugins
(resolve-plugins) on project : Nested: Could not transfer
artifact com.google.guava:guava:jar:[10.0.1,14.0.1] from/to central
(https://repo.maven.apache.org/maven2): Illegal character in path at
index 60:
https://repo.maven.apache.org/maven2/com/google/guava/guava/[10.0.1,14.0.1]/guava-[10.0.1,14.0.1].jar
Index 60 is the "[" character in the version range specifier for the guava jar. I have no idea where that URL gets created and why it's not URL-encoded. It would be nice to get the dependency:go-offline goal to complete execution, but I don't think it's the source of my problem.
The reason I say that is when I run that goal, I see this in the output
[INFO] Adding repository
http://download.eclipse.org/tools/cdt/releases/8.6 [INFO] Fetching
p2.index from http://download.eclipse.org/tools/cdt/releases/8.6/r/
(0B at 0B/s)
I don't know why it downloads 0 Bytes, but I assume this is why I can't find a cache of the CDT bundles when I try to do an offline build.
If anyone has an idea how to work around this failure, or any other approach to make an offline build work, that would be very helpful.
I created this Maven bug report in the issue tracker.
In the course of creating a stripped down project to demonstrate the problem, I discovered the cause. The presence of org.eclipse.xtend:xtend-maven-plugin in the pom was causing the problem. The plug-in is not used, and was perhaps misconfigured, per a message I saw in the build output.

NoClassDefFoundError when using instrumentation on Bluemix

I am trying to add a javaagent to my bluemix app, this agent uses Instrumentation. The thing is that when I run the application I get the following error:
premain() - Instrumentation is already running
...
CWWKF0004E: An unknown exception occurred while installing or removing features. Exception: java.lang.NoClassDefFoundError: agent.ClassInstrumentorTransform
ERR at com.ibm.ws.kernel.feature.internal.subsystem.SubsystemFeatureDefinitionImpl.setHeader(SubsystemFeatureDefinitionImpl.java)
ERR at [internal classes]
I have tried creating another agent with the same Premain-Class and Agent-Class structure but with my own classes and it works, I have tried uploading my own copy of Instrumentation classes and point the javaagent to it using Class-Path but the error still appears.
Any sugestion what can be the problem?
I suspect maybe the Bluemix enviorment uses the Instrumentation, any ideas how this might be checked and how I can solve the inter dependency?
Based on the error message, it looks like you have a class in a feature bundle that is trying to access a class from the javaagent, but you have not added the javaagent package to org.osgi.framework.bootdelegation as described in the Specifying Liberty profile bootstrap properties" topic in the knowledge center topic.