serverless / examples

Serverless Examples – A collection of boilerplates and examples of serverless architectures built with the Serverless Framework on AWS Lambda, Microsoft Azure, Google Cloud Functions, and more.
https://www.serverless.com/examples/
Other
11.43k stars 4.47k forks source link

aws-node-rest-api-with-dynamodb-and-offline class not found error #226

Open ghost opened 6 years ago

ghost commented 6 years ago

Please LMK if I've made a basic mistake, or if more info is needed.

Steps to reproduce:

Computer:aws-node-rest-api-with-dynamodb-and-offline paul$ export SLS_DEBUG=*
Computer:aws-node-rest-api-with-dynamodb-and-offline paul$ serverless offline start
Serverless: Load command run
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command emit
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command dynamodb
Serverless: Load command dynamodb:migrate
Serverless: Load command dynamodb:seed
Serverless: Load command dynamodb:start
Serverless: Load command dynamodb:noStart
Serverless: Load command dynamodb:remove
Serverless: Load command dynamodb:install
Serverless: Load command offline
Serverless: Load command offline:start
Serverless: Invoke offline:start
Dynamodb Local Started, Visit: http://localhost:8000/shell
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/logging/log4j/spi/ExtendedLogger
    at com.amazonaws.services.dynamodbv2.local.shared.logging.LogManager.<clinit>(LogManager.java:28)
    at com.amazonaws.services.dynamodbv2.local.server.DynamoDBProxyServer.<clinit>(DynamoDBProxyServer.java:36)
    at com.amazonaws.services.dynamodbv2.local.main.ServerRunner.createServer(ServerRunner.java:124)
    at com.amazonaws.services.dynamodbv2.local.main.ServerRunner.createServerFromCommandLineArgs(ServerRunner.java:120)
    at com.amazonaws.services.dynamodbv2.local.main.ServerRunner.main(ServerRunner.java:71)
Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.spi.ExtendedLogger
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 5 more
DynamoDB Local failed to start with code 1
Serverless: DynamoDB - Error - 

  Networking Error ---------------------------------------

  connect ECONNREFUSED 127.0.0.1:8000

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Stack Trace --------------------------------------------

NetworkingError: connect ECONNREFUSED 127.0.0.1:8000
    at Object._errnoException (util.js:1031:13)
    at _exceptionWithHostPort (util.js:1052:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1195:14)
From previous event:
    at PluginManager.invoke (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:366:22)
    at PluginManager.run (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:397:17)
    at variables.populateService.then (/usr/local/lib/node_modules/serverless/lib/Serverless.js:104:33)
    at runCallback (timers.js:800:20)
    at tryOnImmediate (timers.js:762:5)
    at processImmediate [as _immediateCallback] (timers.js:733:5)
From previous event:
    at Serverless.run (/usr/local/lib/node_modules/serverless/lib/Serverless.js:91:74)
    at serverless.init.then (/usr/local/lib/node_modules/serverless/bin/serverless:42:50)
    at <anonymous>

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Forums:        forum.serverless.com
     Chat:          gitter.im/serverless/serverless

  Your Environment Information -----------------------------
     OS:                     darwin
     Node Version:           9.2.1
     Serverless Version:     1.24.1
ghost commented 6 years ago
Computer:aws-node-rest-api-with-dynamodb-and-offline paul$ sudo lsof -PiTCP -sTCP:LISTEN
COMMAND   PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
launchd     1 root   12u  IPv6 0xf8787fa43b9e13c1      0t0  TCP localhost:8021 (LISTEN)
launchd     1 root   13u  IPv4 0xf8787fa43b9e4d21      0t0  TCP localhost:8021 (LISTEN)
launchd     1 root   15u  IPv6 0xf8787fa43b9e13c1      0t0  TCP localhost:8021 (LISTEN)
launchd     1 root   16u  IPv4 0xf8787fa43b9e4d21      0t0  TCP localhost:8021 (LISTEN)
geth    20144 paul   32u  IPv6 0xf8787fa43b464e81      0t0  TCP *:30303 (LISTEN)
geth    20144 paul   46u  IPv4 0xf8787fa43ef0ed21      0t0  TCP localhost:8545 (LISTEN)
ptrivedi9400 commented 6 years ago

an example can be executed without running the migration. I am guessing it required readme file update as the offline command is twice. if not then definitely a bug in the example. Hope this helps.

Lekha30 commented 3 years ago

I also hit an error something related to this. As soon as I run Serverless offline start, I get some outputs pertaining to the start and then this exception:

exception in thread "main" java.io.IOException: Failed to bind to 0.0.0.0/0.0.0.0:8000
        at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:346)
        at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:308)
        at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
        at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:236)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.server.Server.doStart(Server.java:396)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at com.amazonaws.services.dynamodbv2.local.server.DynamoDBProxyServer.start(DynamoDBProxyServer.java:83)
        at com.amazonaws.services.dynamodbv2.local.main.ServerRunner.main(ServerRunner.java:76)
Caused by: java.net.BindException: Address already in use
        at sun.nio.ch.Net.bind0(Native Method)
        at sun.nio.ch.Net.bind(Net.java:444)
        at sun.nio.ch.Net.bind(Net.java:436)
        at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:225)
        at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
        at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:342)
        ... 8 more

The curl commands specified in README doesn't work either.