0

Serverless Functions with Spring Cloud Function is the Baeldung article I was using. I changed their recommended aws-adapter dependency because importing in maven failed, so I found the version 3.0.1.RELEASE AND used that instead. All errors gone, I uploaded project as a .jar file. I tried "maven package" and "maven clean shade" commands to create a .jar file and directly uploading to the lambda function. I followed their instructions in specifying the handler in the lambda function. Does anyone know of any other reasons I might be running into this issue.

 java.lang.ClassNotFoundException: package.MyStringHandlers
 at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
 at java.lang.Class.forName0(Native Method)
 at java.lang.Class.forName(Class.java:348)
{
 "errorMessage": "Class not found: package.MyStringHandlers",
 "errorType": "java.lang.ClassNotFoundException"
}
<dependencies>
 <dependency>
 <groupId>com.amazonaws</groupId>
 <artifactId>aws-lambda-java-events</artifactId>
 <version>2.0.2</version>
 <scope>provided</scope>
 </dependency>
 <dependency>
 <groupId>com.amazonaws</groupId>
 <artifactId>aws-lambda-java-core</artifactId>
 <version>1.1.0</version>
 <scope>provided</scope>
 </dependency>
 <!-- https://mvnrepository.com/artifact/org.springframework.boot.experimental/spring-boot-thin-layout -->
 <dependency>
 <groupId>org.springframework.boot.experimental</groupId>
 <artifactId>spring-boot-thin-layout</artifactId>
 <version>1.0.23.RELEASE</version>
 </dependency>
 <dependency>
 <groupId>org.springframework.cloud</groupId>
 <artifactId>spring-cloud-starter-function-web</artifactId>
 <version>1.0.1.RELEASE</version>
 </dependency>
 <dependency>
 <groupId>org.springframework.cloud</groupId>
 <artifactId>spring-cloud-function-adapter-aws</artifactId>
 <version>3.0.1.RELEASE</version>
 </dependency>
 </dependencies>
 <build>
 <plugins>
 <plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-deploy-plugin</artifactId>
 <configuration>
 <skip>true</skip>
 </configuration>
 </plugin>
 <plugin>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-maven-plugin</artifactId>
 </plugin>
 <plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-shade-plugin</artifactId>
 <configuration>
 <createDependencyReducedPom>false</createDependencyReducedPom>
 <shadedArtifactAttached>true</shadedArtifactAttached>
 <shadedClassifierName>aws</shadedClassifierName>
 </configuration>
 </plugin>
 </plugins>
 </build>
 </project>
John Rotenstein
273k28 gold badges456 silver badges541 bronze badges
asked Jan 9, 2020 at 19:12

1 Answer 1

1

You seem to be using some mixed and incompatible versions of function together 1.0.1.RELEASE and 3.0.1.RELEASE although your problem is probably unrelated, yet it's impossible to say without seeing your code.

The good news is:

For 3.0.1 release we jus added a Getting Started guide which takes you step by step. We've also updated the example which is also referenced in the Getting Started. With it you should be up and running in 5-10 min.

answered Jan 9, 2020 at 19:32
Sign up to request clarification or add additional context in comments.

2 Comments

That's exactly what I needed. Thank you for your time. I just ran into a different problem that I'm now working through. But for now that error is gone. Thank you again.
Thanks @Oleg Zhurakousky, This link really helped me..

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.