Search code examples
javaslf4jlombokoracle-cloud-infrastructure

@Slf4j cannot find symbol LOG


I am aware that multiple questions for the essentially same errors are posted. However, I do not think they are the same issues as mine.

In short, I am trying to compile one of the examples that come with the oci-java-sdk. It does not compile. It seems like a jar file or so has the LOG variable so I am wondering where I can find the jar file.

Here's the details. Firstly, I am using Oracle Linux, and installed the oci-java-sdk with the RPM. Following that, I copied the entire examples directory to my home directory. Here's how my CLASSPATH looks like:

$ echo $CLASSPATH
:/usr/lib64/java-oci-sdk/lib/oci-java-sdk-full-1.6.1.jar:/usr/lib64/java-oci-sdk/third-party/lib/*

For the need at my work, I am trying to build the example as follows:

$ javac -Xlint -cp $CLASSPATH:$PWD/lombok.jar:/usr/share/java/*:/usr/share/java/slf4j/* ./EventsServiceExample.java

As shown above, I have downloaded lombok.jar from lombok project web site. The javac command fails as follows:

$ javac -Xlint -cp $CLASSPATH:$PWD/lombok.jar:/usr/share/java/*:/usr/share/java/slf4j/* ./EventsServiceExample.java 
./EventsServiceExample.java:83: error: cannot find symbol
        LOG.info("Number of rules in compartment {} is {}", compartmentId, rulesList.size());
        ^
  symbol:   variable LOG
  location: class EventsServiceExample
./EventsServiceExample.java:135: error: cannot find symbol
            LOG.info(
            ^
  symbol:   variable LOG
  location: class EventsServiceExample
./EventsServiceExample.java:143: error: cannot find symbol
            LOG.error(
            ^
  symbol:   variable LOG
  location: class EventsServiceExample
./EventsServiceExample.java:164: error: cannot find symbol
            LOG.error("Failed to retrieve the Rule {}", ruleId, e);
            ^
  symbol:   variable LOG
  location: class EventsServiceExample
./EventsServiceExample.java:188: error: cannot find symbol
            LOG.info("Rule {} was updated", ruleId);
            ^
  symbol:   variable LOG
  location: class EventsServiceExample
./EventsServiceExample.java:192: error: cannot find symbol
            LOG.error("Failed to update rule {} with displayName {}", ruleId, newDisplayName, e);
            ^
  symbol:   variable LOG
  location: class EventsServiceExample
./EventsServiceExample.java:217: error: cannot find symbol
            LOG.error("Failed to list rules in compartment {}", compartmentId, e);
            ^
  symbol:   variable LOG
  location: class EventsServiceExample
./EventsServiceExample.java:232: error: cannot find symbol
            LOG.info("Rule {} was deleted", ruleId);
            ^
  symbol:   variable LOG
  location: class EventsServiceExample
./EventsServiceExample.java:234: error: cannot find symbol
            LOG.error("Failed to delete rule {}", ruleId, e);
            ^
  symbol:   variable LOG
  location: class EventsServiceExample
9 errors

It makes me think that it cannot find LOG, which must be somewhere related with slf4j. I have installed all slf4j-look-like RPMs but still got no luck.

The following link is an example of others complaining about the same error message: intellij-14-lombok-slf4j-cannot-find-symbol-log

I found more like that. Mostly, it seems like each IDE has some library, and the library & lombok should be configured well with the IDE.

I am not supposed to use any IDE. I am supposed to compile the source from the command line. Thus, I guess that I have to find where is the upstream of the jar file that has the variable, LOG. Following that, hopefully, I'd like to find an RPM that has the jar if any.


Solution

  • Both Lombok's and Groovy's @Slf4j annotations add a member named log, not LOG.