Lambda deploy from Eclipse not working: JAXBException

0

Hello,

    • I could not run option: AWS Toolkit for Eclipse -> Upload function to AWS Lambda, on eclipse jee-2021-09, Version: 2021-09 (4.21.0), Build id: 20210910-1417
  • The archive is created on local drive, but it is not uploaded; so, the jaxb issue is not related to archive internals, but to some aws-eclipse interraction
  • AWS Explorer is working
  • Eclipse error: An internal error occurred during: "Uploading function code to Lambda": javax/xml/bind/JAXBException
  • I looked for solutions in the internet but they did not worked (seams that is a java version deprecation of jaxb)
  • Where from should I get the jaxb package and dependencies (please add link to work with com.amazonaws.eclipse.javasdk) and how should I add them to Eclipse ?
  • Full error stack: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException at com.amazonaws.util.Md5Utils.md5AsBase64(Md5Utils.java:104) at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1647) at com.amazonaws.eclipse.lambda.upload.wizard.util.UploadFunctionUtil.performFunctionUpload(UploadFunctionUtil.java:95) at com.amazonaws.eclipse.lambda.upload.wizard.UploadFunctionWizard.doFinish(UploadFunctionWizard.java:111) at com.amazonaws.eclipse.core.plugin.AbstractAwsJobWizard$1.run(AbstractAwsJobWizard.java:35) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63) Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException cannot be found by com.amazonaws.eclipse.javasdk_1.11.248 at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:511) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:414) at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:153) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ... 6 more

Thanks a lot for answer,

Mihai

asked a year ago358 views
2 Answers
0
Accepted Answer

Hello Mihai,

I understand that you are getting following error, when trying to upload lambda function code using AWS Toolkit for Eclipse.

“ An internal error occurred during: "Uploading function code to Lambda": javax/xml/bind/JAXBException”

For newer version of Eclipse, it is likely that Java 11 is being used. AWS Toolkit for Eclipse prerequisite need use of Java 1.8 (https://docs.aws.amazon.com/toolkit-for-eclipse/v1/user-guide/setup-install.html).

AWS toolkit looks for JAXB class, in order to upload the code to S3 bucket, which is only available in Java 8. This class is deprecated in Java 9 & 10, and removed from Java 11.

As a workaround, you can use Java 1.8 with Eclipse. You can ensure this by specifying the JVM that Eclipse should use on a startup (https://wiki.eclipse.org/Eclipse.ini#Specifying_the_JVM).

There are related Github issues, created with official aws-toolkit-eclipse SDK team:

Please feel free to reach out directly to (aws-toolkit-eclipse) (https://github.com/aws/aws-toolkit-eclipse) team, for further insight into this issue.

AWS
SUPPORT ENGINEER
Isha_K
answered a year ago
profile picture
EXPERT
reviewed 10 months ago
  • Hello,

    This seams to work. I changed the eclipse.ini and make the deploy. Eclipse did not returned any more the JAXBException and the package was deployed in S3 and installed in Lambda, even if there was another error in Eclipse that I added also here in re:Post in another thread.

    Thanks a lot, Mihai

0

Hello Mihali,

The JAXB was deprecated in Java 9 & 10, and removed from Java 11. If your'e running Eclipse under Java 9, 10, or 11, Eclipse/AWS Toolkit won't find JAXB and you'll get this error.

As an alternative you can mitigate the issue by using alternate versions of the Java EE technologies. Add the Maven dependencies that contain the classes you need:

For reference, If you are using the Java 11 runtime you can add the JAXB class by using the following maven dependency:

<dependency>
  <groupId>jakarta.xml.bind</groupId>
  <artifactId>jakarta.xml.bind-api</artifactId>
  <version>4.0.0</version>
</dependency>
<dependency>
  <groupId>com.sun.xml.bind</groupId>
  <artifactId>jaxb-impl</artifactId>
  <version>4.0.0</version>
  <scope>runtime</scope>
</dependency>

[+] (https://search.maven.org/artifact/jakarta.xml.bind/jakarta.xml.bind-api) (https://search.maven.org/artifact/com.sun.xml.bind/jaxb-impl)

Kindly, test the above mentioned insights in your testing environment and let us know if the above insights helped you to mitigate the issue.

There is an open issue on the GitHub describing the same (https://github.com/aws/aws-toolkit-eclipse/issues/217) feel free to add your queries on the on-going issue.

AWS
Akhil
answered a year ago
  • Hello,

    As I specified in main question, the archive is built and stored on local drive. So, there is no need for some extra maven configurations inside the application code, that will not affect the wizard that is building and deploying the package in AWS S3. I already did this kind of attempts before writing this question, but no results. I tried this kind of maven dependency in application , but did you have something else in mind ? Where did you intend to add those configurations ?

    Have a good day, Mihai

  • Hello, It would be nice if your configurations were related to Eclipse settings because newer versions of Eclipse require Java 11 with this argument in eclipse.ini: -Dosgi.requiredJavaVersion=11 Thank you, Mihai

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions