Friday, October 13, 2017

Spring Boot: the client fails to find the service returning 404.


>PROBLEM

The application starts successfully, but the client fails to access the service getting 404.

Controller's original code:
@RestController
@RequestMapping("/api")
@CrossOrigin("*")
public class HelloController {

    @Autowired
    IHelloRepository helloRepository;

    @GetMapping("/hellos")
    public List getAllHellos() {
        Sort sortByCreatedAtDesc = new Sort(Sort.Direction.DESC, "createdAt");
        return helloRepository.findAll(sortByCreatedAtDesc);
    }



>SOLUTION

***WRONG:     @GetMapping("/hellos")
***RIGHT:        @GetMapping("/hellos/")

@RestController
@RequestMapping("/api")
@CrossOrigin("*")
public class HelloController {

    @Autowired
    IHelloRepository helloRepository;

    @GetMapping("/hellos/")
    public List getAllHellos() {
        Sort sortByCreatedAtDesc = new Sort(Sort.Direction.DESC, "createdAt");
        return helloRepository.findAll(sortByCreatedAtDesc);
    }


>ENV

Java 1.8
SpringBoot 1.5.6

Sunday, October 1, 2017

node.js: Error: Cannot find module .. bin/www


>PROBLEM

When the server is started using:
  npm start app.js
it returns the following error message:

  Error: Cannot find module 'L:\work\devcli_\javascript\node\work\ndprj01\ndprj01\bin\www'
      at Function.Module._resolveFilename (module.js:489:15)
      at Function.Module._load (module.js:439:25)
      at Function.Module.runMain (module.js:609:10)
      at startup (bootstrap_node.js:158:16)
      at bootstrap_node.js:598:3
  npm ERR! code ELIFECYCLE
  npm ERR! errno 1
  npm ERR! ndprj01@0.0.0 start: `node ./bin/www "app500c6sql"`
  npm ERR! Exit status 1
  npm ERR!
  npm ERR! Failed at the ndprj01@0.0.0 start script.
  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.


>SOLUTION

Edit "package.json" file.
The error tell at:
  Error: Cannot find module 'L:\work\devcli_\javascript\node\work\ndprj01\ndprj01\bin\www'
that it is a problem concerning "bin\www".
Find "bin\www" and take it out.

- Before:

{
  "name": "ndprj01",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "async": "^2.5.0",
    "bluebird": "^3.5.0",

- After:
{
  "name": "ndprj01",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node "
  },
  "dependencies": {
    "async": "^2.5.0",
    "bluebird": "^3.5.0",






>ENV
windows
node.js

eclipse: java: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder" or Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder

  >PROBLEM Using Eclipse, you try to run a simple logging test using "org.slf4j.Logger" like the sample below: package Test; im...