aws 2.0 > step function > java.lang.NoClassDefFoundError: software/amazon/awssdk/core/runtime/transform/Unmarshaller - amazon-web-services

Getting this below error,
java.lang.NoClassDefFoundError: software/amazon/awssdk/core/runtime/transform/Unmarshaller
When executing the below code,
#Test
public void testStateFunction() {
SfnClient sfnClient = SfnClient.create();
System.out.println(sfnClient);
}
Have the below dependencies defined in build.gradle
dependencies {
implementation platform('software.amazon.awssdk:bom:2.17.29')
// implementation group: 'software.amazon.awssdk', name: 'core', version: '2.17.29', ext: 'pom'
implementation 'software.amazon.awssdk:core:2.17.29'
// implementation 'software.amazon.awssdk:aws-core:2.17.29'
// implementation 'software.amazon.awssdk:sdk-core:2.17.29'
implementation 'software.amazon.awssdk:s3'
implementation 'software.amazon.awssdk:stepfunctions:2.0.0-preview-11'
implementation 'com.amazonaws:aws-lambda-java-core:1.2.1'
implementation 'com.amazonaws:aws-lambda-java-events:3.10.0'
runtimeOnly 'com.amazonaws:aws-lambda-java-log4j2:1.2.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
implementation 'com.google.code.gson:gson:2.8.8'
implementation 'commons-io:commons-io:2.6'
implementation 'org.apache.logging.log4j:log4j-api:2.13.0'
implementation 'org.apache.logging.log4j:log4j-core:2.13.0'
runtimeOnly 'org.apache.logging.log4j:log4j-slf4j18-impl:2.13.0'
compileOnly 'org.projectlombok:lombok:1.18.8'
annotationProcessor 'org.projectlombok:lombok:1.18.8'
}
Tried many online searches, can't fix it yet.
From the InteliJ left menu Gradle libraries, when I try to expand
sdk-core, cannot find the class software/amazon/awssdk/core/runtime/transform/Unmarshaller in any jars.

Looks like you are trying to use AWS Step Functions using the AWS SDK for Java V2. To get this use working, you can follow this AWS end to end example that walks you through this use case and you will create the following workflow using AWS Step Functions.
Follow this document:
Create AWS serverless workflows by using the AWS SDK for Java
It uses Maven - but shows you the required dependencies (Once you get it working with Maven, then port the dependencies to gradle).

After further investigation found out that
The right latest dependency is
implementation 'software.amazon.awssdk:sfn:2.17.29'
And seems the below one which I tried initially was outdated and hence it did not worked with AWS 2.0 core jar /Unmarshaller which does not exist.
Reference: https://github.com/aws/aws-sdk-java-v2/issues/2094
Thanks
implementation 'software.amazon.awssdk:stepfunctions:2.0.0-preview-11'

Related

Looking for documentation setup jest for unit test of admin plugin

my project was created with the swdc create-project ...
Is there a documentation, a tutorial or description for the right setup/configuration unit testing with JEST for custom plugin in administration?
This tutorial describes only how to write a test
But i think there must be a official setup documentation because of versions etc.
EDIT: a tutorial with code is now avialable
Using the suggested solution and execute the test, throws an configuration error:
● Test suite failed to run
Configuration error:
Could not locate module src/core/factory/module.factory mapped as:
undefined/src$1.
Please check your configuration for these entries:
{
"moduleNameMapper": {
"/^src(.*)$/": "undefined/src$1"
},
"resolver": undefined
}
...
Cause of error:
process.env.ADMIN_PATH not setted but required in %Project%/custom/plugins/%MyPlugin%/src/Resources/app/administration/node_modules/#shopware-ag/jest-preset-sw6-admin/jest-preset.js
My solution:
set process.env.ADMIN_PATH in %Project%/custom/plugins/%MyPlugin%/src/Resources/app/administration/jest.config.js
// jest.config.js
...
const { join, resolve } = require('path');
process.env.ADMIN_PATH = resolve('../../../../../../../src/Administration/Resources/app/administration');
...
I think it is easiest to just copy and adapt from a plugin that already has jest tests set up. Look at the administration directory for SwagPayPal for example. Copy the dependency and script sections from their package.json. Also copy the entire jest.config.js. Then within the administration directory of your plugin you should be able to npm install followed by npm run unit or npm run unit-watch and it should find *.spec.js files within the test sub-directory.

Intellij 2021 Cannot resolve symbol if it's from a custom maven repo?

I have a project where I'm using a dependency from a custom repository. This is what my build.gradle looks like (I have blurred out some dependencies for privacy):
plugins {
id 'org.springframework.boot' version '2.5.6'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'groovy'
}
group = 'com.myproject.projectx.sms'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
maven {
url "s3://myproject-maven-repo"
authentication {
awsIm(AwsImAuthentication)
}
}
}
dependencies {
implementation 'org.postgresql:postgresql'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.security:spring-security-core'
implementation 'com.myproject.top:secret-project:1.2' <------------ Gradle won't download this. why?
testImplementation 'org.spockframework:spock-spring:2.0-groovy-3.0'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
exclude group: 'org.junit', module: 'junit'
}
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
}
test {
useJUnitPlatform()
}
There are red squiggly underlines when I hover over code that's using the top:secret-project dependencies. This used to work in old projects, but why can't intellij recognize it in this project? Also I can run the project successfully in ubuntu terminal with gradle bootRun. It's just intellij cannot recognize it. It also able to recognize spring, postgres, lombok & spock dependencies.
Cannot resolve symbol 'com.myproject.top.secret.TopSecretService'.
When click on build for gradle, I keep getting this error.
Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied;)
I already exported the correct secret and keys in my .bashrc file. I also already configured ~/.aws/credentials. But I'm still getting the error above.
Am not really familiar with AwsImAuthentication nor the s3:// , but as it mentioned in the official doc that you need to add user/pass , or user/token as following
maven {
url 'https://my_domain-111122223333.d.codeartifact.region.amazonaws.com/maven/my_repo/'
credentials {
username "aws"
password System.env.CODEARTIFACT_AUTH_TOKEN
}
}
where CODEARTIFACT_AUTH_TOKEN is enviroment variable to store your password/session .
You can also use the gradle.properties to retrive the value , just make sure to replace System.env.CODEARTIFACT_AUTH_TOKEN with
project.findProperty.CODEARTIFACT_AUTH_TOKEN where CODEARTIFACT_AUTH_TOKEN is store the password/token in your gradle properties .

How to use a native node.js addon in React

I have a react project in which I would like to use this native node.js addon, which is a wrapper for a C++ SDK.
I've successfully used this module in the past within an Electron project, and can run the sample successfully with node as well.
My question is how I would be able to use this in React, or write my own React friendly solution using the C++ SDK.
I've tried to clone the module and place it under a lib folder in my react project, I ran npm install within that folder to install it's dependencies and tried to run the included example directly with node. This went fine. But using the sample directly from within my React app fails with the following error code ts3client.on is not a function.
So it passes the line were the library is required with var ts3client = require('../../lib/node-ts3sdk-client/api.js'); but that's the furthest I managed to get. I could play around a little bit more, but would like to get some opinions on what might be the best approach here.
Edit
As requested I have added a small example to reproduce the issue I am facing.
Create a simple react app
npm init react-app so-node-addon-react
Clone this repository under src/lib/
git clone https://github.com/svenpaulsen/node-ts3sdk-client.git
Install the module's dependencies
cd node-ts3sdk-client
npm install
Expose some part of the client example by wrapping the try-catch block starting from line 160 in an exported function like so
export function connect() {
try { ... }
catch { ... }
}
Call the function from your project's App.tsx
import { connect } from './lib/node-ts3sdk-client/examples/client_minimal'
...
connect()
Run the project
npm start
This should result in the following error: ts3client.on is not a function

AWS-SDK in nodejs Lambda function cannot find endpoint-cache module

I've been refactoring some of our AWS lambda functions and with this most recent version I am getting the following error:
"Payload": "{\"errorMessage\":\"Cannot find module '../vendor/endpoint-cache'\",\"errorType\":\"Error\",\"stackTrace\":[\"Function.Module._load (module.js:474:25)\",\"Module.require (module.js:596:17)\",\"require (internal/module.js:11:18)\",\"Object.<anonymous> (/var/task/node_modules/aws-sdk/lib/core.js:76:18)\",\"Module._compile (module.js:652:30)\",\"Object.Module._extensions..js (module.js:663:10)\",\"Module.load (module.js:565:32)\",\"tryModuleLoad (module.js:505:12)\",\"Function.Module._load (module.js:497:3)\"]}"
This module is within the vendor folder of the aws-sdk node module.
I checked the deployment artifacts to make sure that the folder exists and I've tried downgrading to the older version of the aws-sdk that was being used before.
Dependencies in package.json:
"dependencies": {
"aws-sdk": "^2.59.0",
"moment": "^2.22.2",
"underscore": "^1.8.3"
},
The build server runs npm-install and then
$path = Get-Location
$thisProject = "$($path)\pathToProject\*"
Compress-Archive -Path $thisProject -DestinationPath thisProject.zip
Been stuck on this for a while so any help is greatly appreciated.
I ran into this issue a few months back. Turns out I needed to make sure the package lock file was included in the project and had the aws-sdk version set
I had this issue yesterday, I solved it by removing the aws-sdk in the package.json & deleting + reinstalling my node_modules folder. Hope this solves your problem.
I think the aws-sdk is already included by default.
I actually encountered the same problem. And in my case the reason was in the Compress-Archive function, run on Windows. If I pack lambda with Compress-Archive, then Lambda call fails with the error in question above. But if I unpack .zip and pack with regular Windows "send to compressed directory" - everything works fine. I've found some similar issue in PowerShell github space, which made me think this is a common problem.
The problem was fixed in one of the latest releases of PowerShell Core (not sure about classic PowerShell). I'm not sure about the exact release which fixes this problem, but it was there in v.6.1, and in v.6.2.2 it's gone.
The recommended approach to specifying the SDK you want in a Lambda function is to create a lambda layer with your desired version. See here: https://aws.amazon.com/blogs/compute/working-with-aws-lambda-and-lambda-layers-in-aws-sam/

Unit testing Quartz plugin for Grails

I have some trouble writing the most basic unit test for a job. My problem can be recreated by creating a new job by running grails create-job my in the console.
This will create two files
MyJob.goovy (under the default package myApp - resides in test\unit\myApp)
MyJobSpec.groovy (under the default package myApp - resides in grails-app\jobs\myApp)
Now if i try to use the job MyJob in the test, as example
import myApp.MyJob //This is not resolved
#TestMixin(GrailsUnitTestMixin)
class MyJobSpec extends Specification {
def myJob
I get the compiler error Groovy:unable to resolve class MyJob. Everything so far was automatically created by the plugin. What is going on here? Is there something i did wrong / how do i get this to work?
Using grails 2.3.11.
I don't know which IDE are you using or if you are running everything on a terminal, but I had similar problems with Eclipse and what you need to do is to add grails-app/jobs to the classpath as a source folder.