Sunday, April 26, 2015

"ArtifactTransferException: Failure to transfer com.sun.jmx:jmxri:jar:1.2.1", How to resolved this Maven Error?

While I was creating a maven module for my project, I noticed an Error Message in my Eclipse Problem window or when you open the POM.xml and see the Red “X” and it shows:

Multiple annotations found at this line:
                - ArtifactTransferException: Failure to transfer com.sun.jmx:jmxri:jar:1.2.1 from https://maven-repository.dev.java.net/nonav/repository was cached in the local repository, 
                 resolution will not be reattempted until the update interval of java.net has elapsed or updates are forced. Original error: Could not transfer artifact com.sun.jmx:jmxri:jar:1.2.1 from/to 
                 java.net (https://maven-repository.dev.java.net/nonav/repository): No connector available to access repository java.net (https://maven-repository.dev.java.net/nonav/repository) of type 
                 legacy using the available factories AetherRepositoryConnectorFactory, WagonRepositoryConnectorFactory
                - ArtifactTransferException: Failure to transfer com.sun.jdmk:jmxtools:jar:1.2.1 from https://maven-repository.dev.java.net/nonav/repository was cached in the local repository, 
                 resolution will not be reattempted until the update interval of java.net has elapsed or updates are forced. Original error: Could not transfer artifact com.sun.jdmk:jmxtools:jar:1.2.1 from/to 
                 java.net (https://maven-repository.dev.java.net/nonav/repository): No connector available to access repository java.net (https://maven-repository.dev.java.net/nonav/repository) of type 
                 legacy using the available factories AetherRepositoryConnectorFactory, WagonRepositoryConnectorFactory
                - Missing artifact com.sun.jdmk:jmxtools:jar:1.2.1
                - Missing artifact com.sun.jmx:jmxri:jar:1.2.1

To cut the story short, this was caused when I added the log4j 1.2.15 in my pom.xml as shown below:

      <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.15</version>
      </dependency>

To fix the problem, I excluded the jdmk.jmxtools, jmxri and jms by using following code snippet for my log4j 1.2.15 dependency:

      <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.15</version>
                  <exclusions>
                        <exclusion>
                              <groupId>com.sun.jdmk</groupId>
                              <artifactId>jmxtools</artifactId>
                        </exclusion>
                        <exclusion>
                              <groupId>com.sun.jmx</groupId>
                              <artifactId>jmxri</artifactId>
                        </exclusion>
                        <exclusion>
                              <groupId>javax.jms</groupId>
                              <artifactId>jms</artifactId>
                        </exclusion>
                  </exclusions>
      </dependency>

Friday, April 10, 2015

How to make 'tail' command with color in SSH or Unix

While I was debugging the logs early in the morning for an application issue, it's hard to identify which is ERROR or INFO or the CLASS that I'm looking for when you're dealing with one color (i.e. green), it's hard. When remote and tailing a logs for debugging, it's not easy especially if you have a lot of application logs writing to your file. My approach in a way to make it understandable and easy to trace, I just change the color while tailing it, so that, it's easy for me to trace which one is ERROR or even the specific text based on your keyword or the name of your Java Class You may try the following command below and you can also experiment it.

Quick notes: /INFO/ and /ERROR/ are the keyword and you can replace it.

Command below will print all line with INFO in GREEN and all line with ERROR in RED

tail -1000f <log.file>| awk '/INFO/ {print "\033[32m" $0 "\033[39m"} /ERROR/ {print "\033[31m" $0 "\033[39m"}'

Command below will print all line in WHITE except for the line with ERROR. The line with ERROR will be print in RED.

tail -1000f <log.file>| awk '// {print "\033[37m" $0 "\033[39m"} /ERROR/ {print "\033[31m" $0 "\033[39m"}'

Please post your suggestion to make this "tail" and "awk" works better.

For Colors:
            
   30 - black   34 - blue          40 - black    44 - blue
   31 - red     35 - magenta       41 - red      45 - magenta
   32 - green   36 - cyan          42 - green    46 - cyan
   33 - yellow  37 - white         43 - yellow   47 - white