Sunday, February 3, 2019

Failed to start connector [Connector[HTTP/1.1-8080]]

Hey Guys,

Today I faced an issue while starting Spring boot application .

Full stacktrace is as below :

 o.apache.catalina.core.StandardService   : Failed to start connector [Connector[HTTP/1.1-8080]]

org.apache.catalina.LifecycleException: Failed to start component [Connector[HTTP/1.1-8080]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.core.StandardService.addConnector(StandardService.java:225) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.java:256) [spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:198) [spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.startWebServer(ServletWebServerApplicationContext.java:300) [spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:162) [spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553) [spring-context-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) [spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:780) [spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412) [spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:333) [spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1277) [spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1265) [spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
        at hello.Application.main(Application.java:15) [classes!/:0.1.0]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
        at java.base/java.lang.reflect.Method.invoke(Unknown Source) ~[na:na]
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [gs-spring-boot-0.1.0.jar:0.1.0]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [gs-spring-boot-0.1.0.jar:0.1.0]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [gs-spring-boot-0.1.0.jar:0.1.0]
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [gs-spring-boot-0.1.0.jar:0.1.0]
Caused by: org.apache.catalina.LifecycleException: Protocol handler start failed
        at org.apache.catalina.connector.Connector.startInternal(Connector.java:1020) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        ... 21 common frames omitted
Caused by: java.net.BindException: Address already in use: bind
        at java.base/sun.nio.ch.Net.bind0(Native Method) ~[na:na]
        at java.base/sun.nio.ch.Net.bind(Unknown Source) ~[na:na]
        at java.base/sun.nio.ch.Net.bind(Unknown Source) ~[na:na]
        at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source) ~[na:na]
        at java.base/sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source) ~[na:na]
        at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:219) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1151) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:591) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        at org.apache.catalina.connector.Connector.startInternal(Connector.java:1018) ~[tomcat-embed-core-8.5.34.jar!/:8.5.34]
        ... 22 common frames omitted

2019-02-03 20:49:07.448  INFO 7964 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2019-02-03 20:49:07.502  INFO 7964 --- [           main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-02-03 20:49:07.508 ERROR 7964 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   :

***************************
APPLICATION FAILED TO START
***************************

Description:

The Tomcat connector configured to listen on port 8080 failed to start. The port may already be in use or the connector may be misconfigured.

Action:

Verify the connector's configuration, identify and stop any process that's listening on port 8080, or configure this application to listen on another port.

2019-02-03 20:49:07.510  INFO 7964 --- [           main] ConfigServletWebServerApplicationContext : Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@5af3afd9: startup date [Sun Feb 03 20:49:01 IST 2019]; root of context hierarchy
2019-02-03 20:49:07.512  INFO 7964 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown



The fix is simple , just add a property file like this :
application.properties--------------------------
server.port = 8989
--------------------------------------------------------

The error is due to default port 8080 is already in use.
The solution is to change the port number .


Tuesday, August 7, 2018

OAuth

Hey Guys,

In this blog we will discuss about OAuth . OAuth is used for authentication .

Basic Authentication:
It needs user id and password.
The combination of user id and password is encrypted and added to the header .

The backend validates the authentication data in the headers and allow/block the request.

OAuth 2 :
1. Grant Type : Client Credentials
2 .access token url:
3. Client ID :
4. Client Secret :
5. Scope : api 

Friday, June 22, 2018

Error: Cannot find module '@angular-devkit/core'

Hi Guys, You might have faced this error "Error: Cannot find module '@angular-devkit/core'" while calling the command "ng serve". The full stack trace is as below .





module.js:487
    throw err;
    ^

Error: Cannot find module '@angular-devkit/core'
    at Function.Module._resolveFilename (module.js:485:15)
    at Function.Module._load (module.js:437:25)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (F:\shahbaz\study\angular4\projects\my-fifth-app\test5\node_modules\@angular-devkit\schematics\src\tree\virtual.js:10:16)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)


To fix just change the following property in package.json
"@angular/cli": "1.6.0",
to
"@angular/cli": "^1.6.0",

Once done run npm update

This should solve the problem.


The "@angular/compiler-cli" package was not properly installed.


Hi Guys, You might have faced this error "The "@angular/compiler-cli" package was not properly installed. Error: Error: Cannot find module '@angular/compiler-cli'" while calling the command "ng serve". The full stack trace is as below


The "@angular/compiler-cli" package was not properly installed. Error: Error: Cannot find module '@angular/compiler-cli'
Error: The "@angular/compiler-cli" package was not properly installed. Error: Error: Cannot find module '@angular/compiler-cli'
    at Object.CompilerCliIsSupported (C:\Users\user\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@ngtools\webpack\src\ngtools_api.js:25:15)
    at new AotPlugin (C:\Users\user\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@ngtools\webpack\src\plugin.js:29:23)
    at _createAotPlugin (C:\Users\user\AppData\Roaming\npm\node_modules\@angular\cli\models\webpack-configs\typescript.js:92:16)
    at Object.getNonAotConfig (C:\Users\user\AppData\Roaming\npm\node_modules\@angular\cli\models\webpack-configs\typescript.js:100:19)
    at NgCliWebpackConfig.buildConfig (C:\Users\user\AppData\Roaming\npm\node_modules\@angular\cli\models\webpack-config.js:33:37)
    at Class.run (C:\Users\user\AppData\Roaming\npm\node_modules\@angular\cli\tasks\serve.js:71:98)
    at check_port_1.checkPort.then.port (C:\Users\user\AppData\Roaming\npm\node_modules\@angular\cli\commands\serve.js:123:26)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:169:7)

It can due to various reasons ,
1. Your node_modules folder is not having the required modules .
Check the node_modules folder and see if it has all the modules. If the modules are missing just do npm install
2. If the modules are available check the version of typescript , nodejs and angular cli.
3. If nothing works create a new project using ng new project-name and replace the src directory.

Friday, June 8, 2018

ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment:

Hi Guys,

This blog is about issues I have faced while creating a route in Angular 5.

When I try to hit a url "http://localhost:4200/home", I faced the following error.




Error: Cannot match any routes. URL Segment: 'home'
    at ApplyRedirects.noMatchError (router.js:1719)
    at CatchSubscriber.eval [as selector] (router.js:1684)
    at CatchSubscriber.error (catchError.js:105)
    at MapSubscriber.Subscriber._error (Subscriber.js:131)
    at MapSubscriber.Subscriber.error (Subscriber.js:105)
    at MapSubscriber.Subscriber._error (Subscriber.js:131)
    at MapSubscriber.Subscriber.error (Subscriber.js:105)
    at MapSubscriber.Subscriber._error (Subscriber.js:131)
    at MapSubscriber.Subscriber.error (Subscriber.js:105)
    at LastSubscriber.Subscriber._error (Subscriber.js:131)
    at ApplyRedirects.noMatchError (router.js:1719)
    at CatchSubscriber.eval [as selector] (router.js:1684)
    at CatchSubscriber.error (catchError.js:105)
    at MapSubscriber.Subscriber._error (Subscriber.js:131)
    at MapSubscriber.Subscriber.error (Subscriber.js:105)
    at MapSubscriber.Subscriber._error (Subscriber.js:131)
    at MapSubscriber.Subscriber.error (Subscriber.js:105)
    at MapSubscriber.Subscriber._error (Subscriber.js:131)
    at MapSubscriber.Subscriber.error (Subscriber.js:105)
    at LastSubscriber.Subscriber._error (Subscriber.js:131)
    at resolvePromise (zone.js:821)
    at resolvePromise (zone.js:785)
    at eval (zone.js:870)
    at ZoneDelegate.invokeTask (zone.js:421)
    at Object.onInvokeTask (core.js:4744)
    at ZoneDelegate.invokeTask (zone.js:420)
    at Zone.runTask (zone.js:188)
    at drainMicroTaskQueue (zone.js:594)

The fix is pretty simple .When I added the following line in app.module.ts file , it worked.

const appRoutes:Routes =[
{path:'home',component: HomeComponent}
];

If you are facing the same error even after adding this piece of  code then check if you have added a slash in the path {path :'\home' . Remove the slash if you have added it.

view the full source in Git

ec2-user@ec2 Permission denied