Skip to content

Provide working maven example #726

@GuyJackson

Description

@GuyJackson

I'm trying to trial Powertools in my demo project (specifically around logging).

I've copied this pom in your example repo and get a series of issues in my demo project - when I package (mvn clean package) and upload the produced jar to aws.

1. Cloudwatch error - Exception when using private final static Logger log = LogManager.getLogger(); in App class.

java.lang.ExceptionInInitializerError
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Unknown Source)
Caused by: java.lang.UnsupportedOperationException: No class provided, and an appropriate one cannot be found.

Resolved by putting in private final static Logger log = LogManager.getLogger(**App.class**);

2. Cloudwatch error - Exception related to maven shade plugin:

ERROR StatusLogger Unrecognized conversion specifier [d]

Seems to relate to this stackoverflow post.

Resolved by adding this config to the shade plugin:

<configuration>
                    <createDependencyReducedPom>false</createDependencyReducedPom>
                    <finalName>hello-world</finalName>
                    <filters>
                        <filter>
                            <artifact>*:*</artifact>
                            <excludes>
                                <exclude>**/Log4j2Plugins.dat</exclude>
                                <exclude>module-info.class</exclude>
                            </excludes>
                        </filter>
                    </filters>
                </configuration>

3. Cloudwatch warning:

WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.

Not entirely sure on the resolution for this but doesn't break things as it stands.

4. Cloudwatch Error related to log4j2.xml which is copied from your repo here.

ERROR Console contains an invalid element or attribute "LambdaJsonLayout"

I don't know how to progress past this.

Many Thanks,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions