Giter Club home page Giter Club logo

gs-rest-hateoas's Issues

Run error - ClassNotFoundException

Cloned a repo, did build and ran fat jar.

jvalkealahti@neo:/tmp/foo/gs-rest-hateoas/complete$ ./gradlew clean build
:clean
:compileJava
:processResources UP-TO-DATE
:classes
:jar
:bootRepackage
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:build

BUILD SUCCESSFUL

Total time: 6.495 secs
jvalkealahti@neo:/tmp/foo/gs-rest-hateoas/complete$ java -jar build/libs/gs-rest-hateoas-0.1.0.jar

. ____ _ __ _ _
/\ / ' __ _ ()_ __ __ _ \ \ \
( ( )_
| '_ | '| | ' / ` | \ \ \
/ )| |)| | | | | || (| | ) ) ) )
' |
| .**|| ||| |**, | / / / /
=========||==============|/=///_/
:: Spring Boot :: (v1.1.1.RELEASE)

2014-06-16 13:19:15.554 INFO 2785 --- [ main] hello.Application : Starting Application on neo with PID 2785 (/tmp/foo/gs-rest-hateoas/complete/build/libs/gs-rest-hateoas-0.1.0.jar started by jvalkealahti in /tmp/foo/gs-rest-hateoas/complete)
2014-06-16 13:19:15.596 INFO 2785 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@249c38d5: startup date [Mon Jun 16 13:19:15 BST 2014]; root of context hierarchy
2014-06-16 13:19:16.165 INFO 2785 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'beanNameViewResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.NoClassDefFoundError: org/springframework/plugin/core/support/PluginRegistryFactoryBean
at org.springframework.hateoas.config.LinkBuilderBeanDefinitionRegistrar.registerBeanDefinitions(LinkBuilderBeanDefinitionRegistrar.java:57)
at org.springframework.hateoas.config.HypermediaSupportBeanDefinitionRegistrar.registerBeanDefinitions(HypermediaSupportBeanDefinitionRegistrar.java:93)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java:319)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:139)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:116)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:324)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:243)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:254)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:94)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:609)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:120)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:683)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:944)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:933)
at hello.Application.main(Application.java:12)
... 6 more
Caused by: java.lang.ClassNotFoundException: org.springframework.plugin.core.support.PluginRegistryFactoryBean
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at org.springframework.boot.loader.LaunchedURLClassLoader.doLoadClass(LaunchedURLClassLoader.java:161)
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:131)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 23 more
2014-06-16 13:19:16.243 INFO 2785 --- [ Thread-2] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@249c38d5: startup date [Mon Jun 16 13:19:15 BST 2014]; root of context hierarchy
2014-06-16 13:19:16.248 WARN 2785 --- [ Thread-2] ationConfigEmbeddedWebApplicationContext : Exception thrown from ApplicationListener handling ContextClosedEvent

java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@249c38d5: startup date [Mon Jun 16 13:19:15 BST 2014]; root of context hierarchy
at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:346)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:333)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:880)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.doClose(EmbeddedWebApplicationContext.java:152)
at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:809)

2014-06-16 13:19:16.248 WARN 2785 --- [ Thread-2] ationConfigEmbeddedWebApplicationContext : Exception thrown from LifecycleProcessor on context close

java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@249c38d5: startup date [Mon Jun 16 13:19:15 BST 2014]; root of context hierarchy
at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:359)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:888)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.doClose(EmbeddedWebApplicationContext.java:152)
at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:809)

Update Spring Boot version

Updating the Spring Boot version is a constantly ongoing task, and it's easy to do. That makes it a good spot for beginners to get started by making a PR.

To change the Spring Boot version, you must change it in the following files:

complete/build.gradle
complete/pom.xml
initial/build.gradle
initial/pom.xml

HATEOAS JSON output doesn't have right links for collection

The json output of the links differ quite a bit from the single entity object. If I use the implementation in this example. I get the json output like this:

{
      "content":"Hello, User!",
      "_links":{
      "self":{
              "href":"http://localhost:8080/greeting?name=User"
       }
   }
}

But moment I change the output to a collection(refer the code below):

  @RequestMapping("/greeting/{name}" )
    public HttpEntity<List<Greeting>> greeting(@PathVariable(value = "name") String name) {

        Greeting greeting = new Greeting(String.format(TEMPLATE, name));
        greeting.add(linkTo(methodOn(AuditHistoryController.class).greeting(name)).withSelfRel());


        List<Greeting> greetings = new ArrayList<>();
        greetings.add(greeting);

        return new ResponseEntity<>(greetings, HttpStatus.OK);
    }

The output json is quite different. Refer the change in links

[
{
    "content": "Hello, User!",
    "links": [
        {
            "rel": "self",
            "href": "http://localhost:8899/risk-portal/api/greeting/User",
            "hreflang": null,
            "media": null,
            "title": null,
            "type": null,
            "deprecation": null
        }
    ]
}
]

Remove unused CI files

The file 'test/run.sh' is no longer required. This file and the 'test' directory can be deleted.

The file was originally used for Jenkins CI. Now that this project has been converted to GitHub Actions, this file can be removed.

methodOn is undefined

With these codes the "methodOn" is undefined. I need to add the import static to compile:

import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;

This is normal?

Thanks!

Jayway JsonPath library Error

Following the Guide and adding the JSON library to pom.xml I got the following error


Caused by: java.lang.NoClassDefFoundError: com/jayway/jsonpath/PathNotFoundException
	at org.springframework.hateoas.mediatype.hal.HalMediaTypeConfiguration.halLinkDisocoverer(HalMediaTypeConfiguration.java:62) ~[spring-hateoas-1.3.2.jar!/:1.3.2]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_302]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_302]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_302]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_302]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.8.jar!/:5.3.8]
	... 28 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.jayway.jsonpath.PathNotFoundException
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_302]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[na:1.8.0_302]
	at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:151) ~[rest-hateoas-complete-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[na:1.8.0_302]
	... 34 common frames omitted

Not using the library outputs no error.

Why it works without the library, i don't know. Just to make it more clear to newcomers.

Thanks!

Links switched to hal format

Something has been changed in spring-hateoas, spring-boot or build imports.

While waiting #2 to get fixed I added spring-plugin-core:

dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    compile("com.fasterxml.jackson.core:jackson-databind")
    compile("org.springframework.hateoas:spring-hateoas")
    compile("org.springframework.plugin:spring-plugin-core:1.1.0.RELEASE")
    testCompile("junit:junit")
}

Using request:

$ curl http://localhost:8080/greeting

should give links:

{ "links" : [ { "rel" : "self",
                "href" : "http://localhost:8080/greeting?name=World" } ],
  "content" : "Hello, World!" }

Not hal _links:

{"content":"Hello, World!","_links":{"self":{"href":"http://localhost:8080/greeting?name=World"}}}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.