https://pulumi.com logo
#getting-started
Title
# getting-started
b

busy-kitchen-1186

09/14/2023, 8:14 PM
When I use Java with Pulumi, and try to setup slf4j + log4j, I have the following error when
pulumi up
Copy code
java.lang.IllegalStateException: java.lang.ClassNotFoundException: org.apache.logging.log4j.util.Activator
    	at com.google.common.reflect.ClassPath$ClassInfo.load(ClassPath.java:382)
    	at com.pulumi.serialization.internal.ResourcePackages.lambda$discoverResourceTypes$0(ResourcePackages.java:71)
    	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
here is part of pom.xml
Copy code
<dependencies>
        <dependency>
            <groupId>com.pulumi</groupId>
            <artifactId>pulumi</artifactId>
            <version>0.9.7</version>
        </dependency>
        <dependency>
            <groupId>com.pulumi</groupId>
            <artifactId>aws</artifactId>
            <version>5.42.0</version>
        </dependency>
        <dependency>
            <groupId>com.pulumi</groupId>
            <artifactId>awsx</artifactId>
            <version>1.0.5</version>
        </dependency>
        <dependency>
            <groupId>com.pulumi</groupId>
            <artifactId>aws-native</artifactId>
            <version>0.61.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.20.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.20.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j-impl</artifactId>
            <version>2.20.0</version>
        </dependency>
part of source code
Copy code
import com.pulumi.Pulumi;
import com.pulumi.aws.ec2.Eip;
import com.pulumi.aws.ec2.EipArgs;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class App {
    private static final Logger LOG = LoggerFactory.getLogger(App.class);

    public static void main(String[] args) {
        Pulumi.run(App::provisionStack);
    }
I checked the uber jar file, the class
org.apache.logging.log4j.util.Activator
is packaged.
does anybody have a working setup?
d

delightful-salesclerk-16161

09/15/2023, 2:10 PM
Let me see if I can get you help
l

limited-rainbow-51650

09/15/2023, 4:58 PM
@busy-kitchen-1186 First guess this is related to classloaders. Can you check which classloaders are in use, and to which parent classloaders they refer. One of the classloaders doesn't seem to have access a required class. You are also mentioning an uber jar file. Are you building a Pulumi program into an uber jar?
b

busy-kitchen-1186

09/15/2023, 5:03 PM
the default pom.xml does the uber jar
Copy code
<groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.3.0</version>
the only I did was to add some log4j/slf4j dependencies in pom, and start a log instance in App.java
oh, the log4j.properties file in resources folder
It would be better you can share a sample java project with log4j/slf4j support.