Friday, March 27, 2020

ERROR 1046 (3D000): No database selected



Error Blog 

Hi Guys ,
This blog is about the error   ERROR 1046 (3D000): No database selected

Problem Statement

unable to query in mysql usiing command line client 


Error Details 

error Log

ERROR DETAILS 


mysql> select * from all_tables
    -> ;
ERROR 1046 (3D000): No database selected
mysql>




Error Code 

Please check if the database is selected 

  
   
  

Solution

select a database

Code Changes 

execute the following command 

  
        

mysql> use mydb
Database changed
mysql>

         
OUTPUT



Thanks for reading . Let me know your thoughts in the comments below    .

Wednesday, March 25, 2020

java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut



Error Blog 

Hi Guys ,
This blog is about the error    java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut

Problem Statement

unable to start a spring boot application on using annotation based aspect .


Error Details 

error Log

ERROR DETAILS 
Caused by: java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut 
at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:319) ~[aspectjweaver-1.9.5.jar:na]
at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:227) ~[spring-aop-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.aop.aspectj.AspectJExpressionPointcut.obtainPointcutExpression(AspectJExpressionPointcut.java:198) ~[spring-aop-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter(AspectJExpressionPointcut.java:177) ~[spring-aop-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:226) ~[spring-aop-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:289) ~[spring-aop-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:321) ~[spring-aop-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:126) ~[spring-aop-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:95) ~[spring-aop-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:76) ~[spring-aop-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:347) ~[spring-aop-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:299) ~[spring-aop-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:431) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
... 25 common frames omitted



Error Code 

Please check the aspect class

  
   
package com.example.aop;
import org.aspectj.lang.JoinPoint;import org.aspectj.lang.annotation.Aspect;import org.aspectj.lang.annotation.Before;import org.slf4j.LoggerFactory;import org.springframework.beans.factory.annotation.Configurable;import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.slf4j.Logger;import org.springframework.stereotype.Component;
@Component@Aspectpublic class MyAspect {

    private static final Logger LOGGER = LoggerFactory.getLogger(MyAspect.class);

    @Before("execution(* com.example.aop.DemoController.test() )")
    public void check(JoinPoint joinPoint){
        System.out.println("hello"+joinPoint);
        LOGGER.info("hello"+joinPoint);
    }


    @Before("@annotation(CustomAn)")
    public void annotaion(JoinPoint joinPoint,CustomAn  customAn){
        System.out.println("hello custom1"+joinPoint);

        LOGGER.info("hello custom1"+joinPoint);
        LOGGER.info("CustomAn"+customAn);

    }

}
         

Solution

remove additional parameters in your aspect class . Refer to the highlighted code .

Code Changes 

the aspect class method should not have an additional parameter .

  
        


package com.example.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

import org.slf4j.Logger;
import org.springframework.stereotype.Component;

@Component@Aspectpublic class MyAspect {

    private static final Logger LOGGER = LoggerFactory.getLogger(MyAspect.class);

    @Before("execution(* com.example.aop.DemoController.test() )")
    public void check(JoinPoint joinPoint){
        System.out.println("hello"+joinPoint);
        LOGGER.info("hello"+joinPoint);
    }


    @Before("@annotation(CustomAn)")
    public void annotaion(JoinPoint joinPoint){
        System.out.println("hello custom1"+joinPoint);

        LOGGER.info("hello custom1"+joinPoint);

    }

}


         
OUTPUT
2020-03-25 22:31:22.076 DEBUG 18068 --- [http-nio-8095-Acceptor] o.apache.tomcat.util.threads.LimitLatch  : Counting up[http-nio-8095-Acceptor] latch=0
2020-03-25 22:31:22.092  INFO 18068 --- [main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8095 (http) with context path ''
2020-03-25 22:31:22.107  INFO 18068 --- [main] com.example.aop.DemoApplication          : Started DemoApplication in 8.303 seconds (JVM running for 9.424)




Thanks for reading . Let me know your thoughts in the comments below    .

Saturday, March 21, 2020

'ng' is not recognized as an internal or external command.



Error Blog 

Hi Guys ,
This blog is about the error   Error: 'ng' is not recognized as an internal or external command.

Problem Statement

unable to run an angular app via ng serve .


Error Details 

error Log

ERROR DETAILS 
 'ng' is not recognized as an internal or external command,
operable program or batch file 



Error Code 

Please check the path 

  
   
ng serve 
         

Solution

set path for npm 

Code Changes 

set path in command prompt

  
          set path=%path%;c:\users\me\AppData\Roaming\npm;
         
OUTPUT




Thanks for reading . Let me know your thoughts in the comments below    .

Monday, March 16, 2020

No base href set . Please provide a value for the APP_BASE_HREF in the token or add a base element to the document

HiHi Guys,

This blog is about the error
No base href set . Please provide a value for the APP_BASE_HREF in the token or add a base element to the document

You may face this error while running an angular application.
The solution is to add base href tag in the head part of index.html

Sunday, March 15, 2020

Error: Cannot find module 'express'



Error Blog 

Hi Guys ,
This blog is about the error   Error: Cannot find module 'express'

Problem Statement

unable to run a file using node js .


Error Details 

error Log

ERROR DETAILS 
 Error: Cannot find module 'express'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> 
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)



Error Code 

Please validate the API endpoint .

  
     var express = require('express');
var app = express();

app.use(express.static('public'));

app.get('/'function (reqres) {
   res.send('Hello World');
})

var server = app.listen(8082function () {
   var host = server.address().address;
   var port = server.address().port;

   console.log("Example app listening at http://%s:%s"hostport)
})  
         

Solution

use npm install to install the required dependencies


Code Changes 

Install express

  
         npm install express
         
OUTPUT
node server.js     
Example app listening at http://:::8082




Thanks for reading . Let me know your thoughts in the comments below    .

Saturday, February 29, 2020

Uncaught (in promise) SyntaxError: Unexpected end of JSON input



Error Blog 

Hi Guys ,
This blog is about the error   Uncaught (in promise) SyntaxError: Unexpected end of JSON input

Problem Statement

Unable to see the response from  a http call in react js .


Error Details 

error Log

ERROR DETAILS 
 Uncaught (in promise) SyntaxError: Unexpected end of JSON input
    at <anonymous>:31:28




Solution

The http call does not return a json output . .


Code Changes 

Please validate the API endpoint .

  componentDidMount() {
        fetch(`/api/users`)
            .then(res => res.json())
            .then(result => this.setState({ users: result.users }))
    }
OUTPUT





Thanks for reading . Let me know your thoughts in the comments below    .

ec2-user@ec2 Permission denied