Skip to content

Java VS Code Case API Troubleshooting

MsaasAPI edited this page Oct 3, 2018 · 14 revisions
⏮API Prev API Next⏭

📑This list is NOT intended to be exhaustive.📑

CONTENTS

COMMON ISSUES

Dependency Resolution Issue

  • Symptom: In spite of correct dependency entry in pom.xml, the following error occurs in code.
    [Java] The import xxx cannot be resolved
    
  • Suggestions

GIT Detached HEAD

  • Symptom:
    When running GIT command:

    git status
    

    It returns:

    HEAD detached at b9aee7d
    nothing to commit, working tree clean
    

    When running GIT command:

    git merge
    

    It returns:

    fatal: No current branch.
    

    When running GIT command:

    git symbolic-ref HEAD
    

    It returns:

    fatal: ref HEAD is not a symbolic ref
    

  • Analysis: per Stack Overflow article: HEAD is the symbolic name for the currently checked out commit. When HEAD is not detached (the “normal”1 situation: you have a branch checked out), HEAD actually points to a branch’s “ref” and the branch points to the commit. HEAD is thus “attached” to a branch. When HEAD is detached, it points directly to a commit—instead of indirectly pointing to one through a branch. You can think of a detached HEAD as being on an unnamed branch.

  • Suggestions: Run the following commands per same Stack Overflow article.

    git branch temp
    git checkout temp
    git log --graph --decorate --pretty=oneline --abbrev-commit master origin/master temp
    git diff master temp
    git diff origin/master temp
    git branch -f master temp
    git checkout master
    git branch -d temp
    git push origin master
    

Log4j StaticLoggerBinder Loading Warnings

  • Symptom: When running console debugger, the following warning appears.
    SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
    SLF4J: Defaulting to no-operation (NOP) logger implementation
    SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
    
  • Suggestions: Add following dependency to pom.xml.
    <dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>1.7.25</version>
    </dependency>
    

Logger Appenders Not Found

  • Symptom: When running console debugger (especially after resolving StaticLoggerBinder Loading issue, the following warning appears.
    log4j:WARN No appenders could be found for logger (adal4jPii.class com.microsoft.aad.adal4j.AuthenticationContext).
    log4j:WARN Please initialize the log4j system properly.
    log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
    
  • Suggestions: Add following snippets to Program.java.
    import org.apache.log4j.BasicConfigurator;
    BasicConfigurator.configure();
    

CLASSPATH IS INCOMPLETE

  • Symptom: When running console debugger (or simply open Program.java or App.java), the following warning appears.
    Classpath is incomplete. Only syntax errors will be reported.
    
  • Suggestions: If this happens after following this wiki page to set up a skeleton project, it is possible some step(s) is missing, especially if the first two steps of Configure Project is missing. Cleanest approach might be start over the project initialization process.

NEXT STEP

  1. optional In case interested, Start Java Project from Scratch might be useful for the reader to start a brand new Java project in VS Code.