springlets | Springlets provides a series of heterogeneus | Object-Relational Mapping library

 by   DISID Java Version: Current License: Apache-2.0

kandi X-RAY | springlets Summary

springlets is a Java library typically used in Utilities, Object-Relational Mapping, Spring Boot, Spring, Hibernate, JPA applications. springlets has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has low support. You can download it from GitHub, Maven.
Springlets provides a series of heterogeneus utilities and Spring Boot starters not currently available in the Spring projects like Spring Framework, Spring Data or Spring Boot, as well as other open source projects used in Java web projects. Our goal in Springlets is to follow the conventions used in the Spring projects (naming, versioning, project structure, …​) as close as possible. As a matter of fact, you can easily view to which Spring project are related most Springlet modules, as their name has been created by replacing the spring prefix with springlets. The Springlets 1.x versions will be associated to the Spring IO platform releases (Athens, Brussels) which depend on the Spring Framework 4.3 releases and Spring Boot 1.x releases. Also JDK 7 and 8 is supported.
    Support
      Quality
        Security
          License
            Reuse
            Support
              Quality
                Security
                  License
                    Reuse

                      kandi-support Support

                        summary
                        springlets has a low active ecosystem.
                        summary
                        It has 27 star(s) with 9 fork(s). There are 14 watchers for this library.
                        summary
                        It had no major release in the last 6 months.
                        summary
                        There are 22 open issues and 44 have been closed. On average issues are closed in 38 days. There are 1 open pull requests and 0 closed requests.
                        summary
                        It has a neutral sentiment in the developer community.
                        summary
                        The latest version of springlets is current.
                        springlets Support
                          Best in #Object-Relational Mapping
                            Average in #Object-Relational Mapping
                            springlets Support
                              Best in #Object-Relational Mapping
                                Average in #Object-Relational Mapping

                                  kandi-Quality Quality

                                    summary
                                    springlets has 0 bugs and 0 code smells.
                                    springlets Quality
                                      Best in #Object-Relational Mapping
                                        Average in #Object-Relational Mapping
                                        springlets Quality
                                          Best in #Object-Relational Mapping
                                            Average in #Object-Relational Mapping

                                              kandi-Security Security

                                                summary
                                                springlets has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
                                                summary
                                                springlets code analysis shows 0 unresolved vulnerabilities.
                                                summary
                                                There are 0 security hotspots that need review.
                                                springlets Security
                                                  Best in #Object-Relational Mapping
                                                    Average in #Object-Relational Mapping
                                                    springlets Security
                                                      Best in #Object-Relational Mapping
                                                        Average in #Object-Relational Mapping

                                                          kandi-License License

                                                            summary
                                                            springlets is licensed under the Apache-2.0 License. This license is Permissive.
                                                            summary
                                                            Permissive licenses have the least restrictions, and you can use them in most projects.
                                                            springlets License
                                                              Best in #Object-Relational Mapping
                                                                Average in #Object-Relational Mapping
                                                                springlets License
                                                                  Best in #Object-Relational Mapping
                                                                    Average in #Object-Relational Mapping

                                                                      kandi-Reuse Reuse

                                                                        summary
                                                                        springlets releases are not available. You will need to build from source code and install.
                                                                        summary
                                                                        Deployable package is available in Maven.
                                                                        summary
                                                                        Build file is available. You can build the component from source.
                                                                        summary
                                                                        Installation instructions, examples and code snippets are available.
                                                                        summary
                                                                        It has 8753 lines of code, 714 functions and 187 files.
                                                                        summary
                                                                        It has low code complexity. Code complexity directly impacts maintainability of the code.
                                                                        springlets Reuse
                                                                          Best in #Object-Relational Mapping
                                                                            Average in #Object-Relational Mapping
                                                                            springlets Reuse
                                                                              Best in #Object-Relational Mapping
                                                                                Average in #Object-Relational Mapping
                                                                                  Top functions reviewed by kandi - BETA
                                                                                  kandi has reviewed springlets and discovered the below as its top functions. This is intended to give you an instant insight into springlets implemented functionality, and help decide if they suit your requirements.
                                                                                  • Creates a builder from a method invocation
                                                                                    • Creates a builder for the given controller method
                                                                                    • Returns the WebApplicationContext associated with the current thread
                                                                                    • Apply contributors to a method
                                                                                  • Serializes the result to JSON
                                                                                    • Loads an object field error message
                                                                                    • Load list items
                                                                                    • Returns the substring after a given separator
                                                                                  • Get the list of emails
                                                                                  • Serializes the given field error result to JSON
                                                                                  • Compares this role with the specified id
                                                                                  • Validate each element
                                                                                  • Convert an object to a string representation
                                                                                  • Initializes the InMemoryUserDetailsManager
                                                                                  • Returns a parser for the specified field type
                                                                                  • Create a unique hash code
                                                                                  • Compares this user with the specified id
                                                                                  • Resolves a global search parameter
                                                                                  • The Spring MVC handler mapping
                                                                                  • Handle the incoming request
                                                                                  • Gets the result
                                                                                  • Marshals the elements of the given Iterable using the given XmlAdapter
                                                                                  • Find user login info by username
                                                                                  • Returns a printer for the entity
                                                                                  • Convert the given object to a JMS queue
                                                                                  • Sends the login request
                                                                                  Get all kandi verified functions for this library.
                                                                                  Get all kandi verified functions for this library.

                                                                                  springlets Key Features

                                                                                  Springlets provides a series of heterogeneus small utilities for Spring based applications and Spring Boot starters not available in the main Spring projects: Spring Framework, Spring Data, Spring Boot, ...

                                                                                  springlets Examples and Code Snippets

                                                                                  No Code Snippets are available at this moment for springlets.
                                                                                  Community Discussions

                                                                                  Trending Discussions on springlets

                                                                                  select2 autocomplete error on views (spring roo rc1)
                                                                                  chevron right
                                                                                  How can get the object in thymeleaf select option?
                                                                                  chevron right
                                                                                  SpringRoo 2.0.RC1 - How can i use date Calenderfields in entityFormatExpression and got correct format
                                                                                  chevron right
                                                                                  Spring Roo 2.0.RC1 - Spring Security Provider Default and add Spring Security Configuration
                                                                                  chevron right
                                                                                  What are the differences between spring security providers? (Spring Roo 2 M3)
                                                                                  chevron right

                                                                                  QUESTION

                                                                                  select2 autocomplete error on views (spring roo rc1)
                                                                                  Asked 2019-Feb-20 at 16:35

                                                                                  I'm was working without any problem while generating the project with RC1. After some work on the project, i realized that the CRUD fields that use select2 to autocomplete suddenly stopped working. I get error 500 when the s2 tries to fetch the data from the /entity/s2 path.

                                                                                  Full java console error:

                                                                                  2017-03-09 11:20:46.136  WARN 42495 --- [nio-8080-exec-7] .w.s.m.s.DefaultHandlerExceptionResolver : Failed to write HTTP message: org.springframework.http.converter.HttpMessageNotWritableException: Could not write content: No converter found capable of converting from type [ar.edu.um.programacion2.oficios.reference.Disponibilidad] to type [java.lang.String] (through reference chain: io.springlets.data.web.select2.Select2DataWithConversion["results"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: No converter found capable of converting from type [ar.edu.um.programacion2.oficios.reference.Disponibilidad] to type [java.lang.String] (through reference chain: io.springlets.data.web.select2.Select2DataWithConversion["results"])
                                                                                  2017-03-09 11:20:46.137  WARN 42495 --- [nio-8080-exec-7] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved exception caused by Handler execution: org.springframework.http.converter.HttpMessageNotWritableException: Could not write content: No converter found capable of converting from type [ar.edu.um.programacion2.oficios.reference.Disponibilidad] to type [java.lang.String] (through reference chain: io.springlets.data.web.select2.Select2DataWithConversion["results"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: No converter found capable of converting from type [ar.edu.um.programacion2.oficios.reference.Disponibilidad] to type [java.lang.String] (through reference chain: io.springlets.data.web.select2.Select2DataWithConversion["results"])
                                                                                  

                                                                                  Any of that fields reference fields are not working now. This is one of the entities used as reference in that field:

                                                                                  @RooJavaBean
                                                                                  @RooToString
                                                                                  @RooJpaEntity
                                                                                  @RooEquals(isJpaEntity = true)
                                                                                  public class Localidad {
                                                                                  
                                                                                      public Localidad(String nombre, String descripcion) {
                                                                                          super();
                                                                                          this.nombre = nombre;
                                                                                          this.descripcion = descripcion;
                                                                                      }
                                                                                  
                                                                                      /**
                                                                                       * TODO Auto-generated attribute documentation
                                                                                       *
                                                                                       */
                                                                                      @Id
                                                                                      @GeneratedValue(strategy = GenerationType.AUTO)
                                                                                      private Long id;
                                                                                  
                                                                                      /**
                                                                                       * TODO Auto-generated attribute documentation
                                                                                       *
                                                                                       */
                                                                                      @Version
                                                                                      private Integer version;
                                                                                  
                                                                                      /**
                                                                                       * TODO Auto-generated attribute documentation
                                                                                       *
                                                                                       */
                                                                                      @NotNull
                                                                                      private String nombre;
                                                                                  
                                                                                      /**
                                                                                       * TODO Auto-generated attribute documentation
                                                                                       *
                                                                                       */
                                                                                      private String descripcion;
                                                                                  
                                                                                  
                                                                                      private String googleMapsString;
                                                                                  
                                                                                  
                                                                                      /**
                                                                                       * TODO Auto-generated method documentation
                                                                                       * 
                                                                                       * @return String
                                                                                       */
                                                                                      public String toString() {
                                                                                          return getNombre();
                                                                                      }
                                                                                  
                                                                                      public String getMapString(){
                                                                                          return "http://maps.googleapis.com/maps/api/staticmap?" + getGoogleMapsString() + "&key=";
                                                                                      }
                                                                                  }
                                                                                  

                                                                                  The class where the referenced field is used:

                                                                                  @RooJavaBean
                                                                                  @RooToString
                                                                                  @RooJpaEntity
                                                                                  @RooEquals(isJpaEntity = true)
                                                                                  public class Servicio {
                                                                                  
                                                                                      /**
                                                                                       * TODO Auto-generated attribute documentation
                                                                                       *
                                                                                       */
                                                                                      @Id
                                                                                      @GeneratedValue(strategy = GenerationType.AUTO)
                                                                                      private Long id;
                                                                                  
                                                                                      /**
                                                                                       * TODO Auto-generated attribute documentation
                                                                                       *
                                                                                       */
                                                                                      @Version
                                                                                      private Integer version;
                                                                                  
                                                                                      /**
                                                                                       * TODO Auto-generated attribute documentation
                                                                                       *
                                                                                       */
                                                                                      @NotNull
                                                                                      private String nombre;
                                                                                  
                                                                                      /**
                                                                                       * TODO Auto-generated attribute documentation
                                                                                       *
                                                                                       */
                                                                                      private String descripcion;
                                                                                  
                                                                                      /**
                                                                                       * TODO Auto-generated attribute documentation
                                                                                       *
                                                                                       */
                                                                                      @RooUploadedFile(contentType = "image/png")
                                                                                      @Lob
                                                                                      private byte[] logo;
                                                                                  
                                                                                      /**
                                                                                       * TODO Auto-generated attribute documentation
                                                                                       *
                                                                                       */
                                                                                      @NotNull
                                                                                      private String telefono;
                                                                                  
                                                                                      /**
                                                                                       * TODO Auto-generated attribute documentation
                                                                                       *
                                                                                       */
                                                                                      @NumberFormat
                                                                                      private float puntaje;
                                                                                  
                                                                                      @OneToOne(fetch=FetchType.LAZY)
                                                                                      @JoinColumn(name="localidad_id")
                                                                                      private Localidad localidad;
                                                                                  
                                                                                      @OneToOne(fetch=FetchType.LAZY)
                                                                                      @JoinColumn(name="disponibilidad_id")
                                                                                      private Disponibilidad disponibilidad;
                                                                                  
                                                                                      @OneToOne(fetch=FetchType.LAZY)
                                                                                      @JoinColumn(name="categoria_id")
                                                                                      private Categoria categoria;
                                                                                  
                                                                                      @OneToOne(fetch=FetchType.LAZY)
                                                                                      @JoinColumn(name="prestador_id")
                                                                                      private Prestador prestador;
                                                                                  
                                                                                      @ManyToMany
                                                                                      @JoinTable(name = "servicio_calificacion", joinColumns = @JoinColumn(name = "servicio_id"), inverseJoinColumns = @JoinColumn(name = "calificacion_id"))
                                                                                      private List listadecalificaciones;
                                                                                  
                                                                                  
                                                                                      /**
                                                                                       * TODO Auto-generated method documentation
                                                                                       * 
                                                                                       * @return String
                                                                                       */
                                                                                      public String toString() {
                                                                                          return getNombre() + " (" + getPrestador() + ")";
                                                                                      }
                                                                                  }
                                                                                  

                                                                                  One of the views were that field is used:

                                                                                  
                                                                                  
                                                                                    
                                                                                  
                                                                                      
                                                                                        Create Servicio - oficios - SpringRoo Application
                                                                                  
                                                                                      
                                                                                      
                                                                                  
                                                                                    
                                                                                  
                                                                                    
                                                                                  
                                                                                      
                                                                                        
                                                                                      
                                                                                  
                                                                                      
                                                                                      
                                                                                        
                                                                                        
                                                                                        
                                                                                          
                                                                                  
                                                                                            Create Servicio
                                                                                  
                                                                                            
                                                                                            
                                                                                  
                                                                                              
                                                                                                Servicio data 
                                                                                  
                                                                                  
                                                                                    nombre
                                                                                    
                                                                                      
                                                                                        
                                                                                        Error message.
                                                                                    
                                                                                  
                                                                                  
                                                                                    descripcion
                                                                                    
                                                                                      
                                                                                        
                                                                                        Error message.
                                                                                    
                                                                                  
                                                                                  
                                                                                    logo
                                                                                    
                                                                                      
                                                                                        
                                                                                        Error message.
                                                                                    
                                                                                  
                                                                                  
                                                                                    telefono
                                                                                    
                                                                                      
                                                                                        
                                                                                        Error message.
                                                                                    
                                                                                  
                                                                                  
                                                                                      Localidad
                                                                                      
                                                                                        
                                                                                        
                                                                                            Localidad
                                                                                        
                                                                                        
                                                                                        Error message.
                                                                                      
                                                                                  
                                                                                  
                                                                                      Disponibilidad
                                                                                      
                                                                                        
                                                                                        
                                                                                            Disponibilidad
                                                                                        
                                                                                        
                                                                                        Error message.
                                                                                      
                                                                                  
                                                                                  
                                                                                      Categoria
                                                                                      
                                                                                        
                                                                                        
                                                                                            Categoria
                                                                                        
                                                                                        
                                                                                        Error message.
                                                                                      
                                                                                  
                                                                                              
                                                                                  
                                                                                  
                                                                                                
                                                                                                
                                                                                                  
                                                                                                      Save
                                                                                                      Cancel
                                                                                                  
                                                                                                
                                                                                  
                                                                                            
                                                                                            
                                                                                  
                                                                                          
                                                                                  
                                                                                        
                                                                                        
                                                                                    
                                                                                    
                                                                                  
                                                                                    
                                                                                      
                                                                                    
                                                                                  
                                                                                    
                                                                                    
                                                                                    
                                                                                    
                                                                                    
                                                                                  
                                                                                      
                                                                                      
                                                                                      
                                                                                  
                                                                                      
                                                                                      
                                                                                      
                                                                                      
                                                                                  
                                                                                      
                                                                                      
                                                                                      
                                                                                      
                                                                                      
                                                                                  
                                                                                      
                                                                                  
                                                                                      
                                                                                  
                                                                                    
                                                                                  
                                                                                  
                                                                                  

                                                                                  Log.roo

                                                                                  // Spring Roo 2.0.0.RC1 [rev 28015e3] log opened at 2017-03-06 20:50:24
                                                                                  project setup --topLevelPackage ar.edu.um.programacion2.oficios --java 8
                                                                                  jpa setup --database MYSQL --provider HIBERNATE --hostName 127.0.0.1 --databaseName oficiosdb --userName root
                                                                                  entity jpa --class ~.reference.Persona
                                                                                  field string --fieldName username --unique
                                                                                  field string --fieldName password --notNull
                                                                                  field string --fieldName email --unique
                                                                                  field string --fieldName telefono
                                                                                  field file --fieldName avatar --contentType PNG 
                                                                                  entity jpa --class ~.domain.Prestador  --extends ~.reference.Persona
                                                                                  field string --fieldName razonsocial --notNull
                                                                                  field string --fieldName oficio --notNull
                                                                                  entity jpa --class ~.reference.Disponibilidad
                                                                                  field string --fieldName franjahoraria --notNull
                                                                                  field string --fieldName descripcion
                                                                                  entity jpa --class ~.reference.Localidad
                                                                                  field string --fieldName nombre --notNull
                                                                                  field string --fieldName descripcion
                                                                                  entity jpa --class ~.reference.Categoria
                                                                                  field string --fieldName nombre --notNull
                                                                                  field string --fieldName descripcion
                                                                                  enum type --class ~.reference.TipoCalif
                                                                                  enum constant --name POSITIVO
                                                                                  enum constant --name NEGATIVO
                                                                                  enum constant --name NEUTRAL
                                                                                  entity jpa --class ~.domain.Cliente  --extends ~.reference.Persona
                                                                                  field string --fieldName nombre --notNull 
                                                                                  field string --fieldName apellido --notNull
                                                                                  field string --fieldName domicilio
                                                                                  field string --fieldName domicilio2
                                                                                  entity jpa --class ~.domain.Calificacion
                                                                                  field string --fieldName comentario --notNull
                                                                                  field enum --fieldName tipo --type ~.reference.TipoCalif
                                                                                  entity jpa --class ~.domain.CalificacionCliente  --extends ~.domain.Calificacion
                                                                                  entity jpa --class ~.domain.Servicio
                                                                                  field string --fieldName nombre --notNull 
                                                                                  field string --fieldName descripcion
                                                                                  field file --fieldName logo --contentType PNG
                                                                                  field string --fieldName telefono --notNull
                                                                                  field number --fieldName puntaje --type float
                                                                                  entity jpa --class ~.domain.CalificacionPrestador  --extends ~.domain.Calificacion
                                                                                  repository jpa --all
                                                                                  finder add --name findByTelefono --entity ~.domain.Servicio
                                                                                  finder add --name findByNombreLike --entity ~.domain.Servicio
                                                                                  finder add --name findByPuntaje --entity ~.domain.Servicio
                                                                                  finder add --name findByUsername --entity ~.domain.Cliente
                                                                                  finder add --name findByUsername --entity ~.domain.Prestador
                                                                                  finder add --name findByEmail --entity ~.domain.Cliente
                                                                                  finder add --name findByEmail --entity ~.domain.Prestador
                                                                                  service --all
                                                                                  web mvc setup
                                                                                  web mvc view setup --type THYMELEAF
                                                                                  web mvc controller --all --responseType THYMELEAF
                                                                                  web mvc templates setup --type THYMELEAF
                                                                                  web mvc language --code es --useAsDefault
                                                                                  // script --file script_roo
                                                                                  // Spring Roo 2.0.0.RC1 [rev 28015e3] log opened at 2017-03-06 21:19:16
                                                                                  help
                                                                                  // Spring Roo 2.0.0.RC1 [rev 28015e3] log closed at 2017-03-07 09:03:07
                                                                                  // Spring Roo 2.0.0.RC1 [rev 28015e3] log opened at 2017-03-07 20:12:48
                                                                                  // Spring Roo 2.0.0.RC1 [rev 28015e3] log closed at 2017-03-08 01:34:17
                                                                                  // Spring Roo 2.0.0.RC1 [rev 28015e3] log opened at 2017-03-08 01:34:37
                                                                                  web mvc finder --entity ~.domain.Servicio 
                                                                                  // Spring Roo 2.0.0.RC1 [rev 28015e3] log closed at 2017-03-08 02:28:28
                                                                                  // Spring Roo 2.0.0.RC1 [rev 28015e3] log opened at 2017-03-08 02:28:44
                                                                                  web mvc finder --all
                                                                                  web mvc finder --all 
                                                                                  // Spring Roo 2.0.0.RC1 [rev 28015e3] log closed at 2017-03-08 02:29:31
                                                                                  // Spring Roo 2.0.0.RC1 [rev 28015e3] log opened at 2017-03-08 02:29:39
                                                                                  // Spring Roo 2.0.0.RC1 [rev 28015e3] log closed at 2017-03-08 02:29:54
                                                                                  // Spring Roo 2.0.0.RC1 [rev 28015e3] log opened at 2017-03-08 02:30:11
                                                                                  hint
                                                                                  help
                                                                                  web mvc finder --all 
                                                                                  web mvc finder --entity ~.domain.Cliente
                                                                                  web mvc finder --all 
                                                                                  web mvc finder --all --responseType THYMELEAF 
                                                                                  web mvc finder --entity ~.domain.Servicio --responseType THYMELEAF 
                                                                                  // Spring Roo 2.0.0.RC1 [rev 28015e3] log closed at 2017-03-08 03:13:33
                                                                                  // Spring Roo 2.0.0.RC1 [rev 28015e3] log opened at 2017-03-08 03:14:23
                                                                                  hint
                                                                                  hint finders
                                                                                  finder add --entity ~.domain.Servicio --name findByCategoria
                                                                                  finder add --entity ~.domain.Servicio --name queryByCategoria
                                                                                  finder add --entity ~.reference.Categoria --name findByNombre
                                                                                  security setup --provider SPRINGLETS_JPA 
                                                                                  entity jpa --class ~.domain.Administrador --extends ~.reference.Persona
                                                                                  web mvc controller --entity ~.domain.Administrador
                                                                                  service --entity ~.domain.Administrador 
                                                                                  repository jpa --entity ~.domain.Administrador 
                                                                                  service --entity ~.domain.Administrador 
                                                                                  web mvc controller --entity ~.domain.Administrador 
                                                                                  web mvc controller --entity ~.domain.Administrador --responseType THYMELEAF 
                                                                                  finder add --entity ~.reference.Persona --name findByUsername
                                                                                  // Spring Roo 2.0.0.RC1 [rev 28015e3] log closed at 2017-03-08 08:02:54
                                                                                  // Spring Roo 2.0.0.RC1 [rev 28015e3] log opened at 2017-03-08 21:06:10
                                                                                  // Spring Roo 2.0.0.RC1 [rev 28015e3] log closed at 2017-03-09 09:30:10
                                                                                  // Spring Roo 2.0.0.RC1 [rev 28015e3] log opened at 2017-03-09 10:08:32
                                                                                  // Spring Roo 2.0.0.RC1 [rev 28015e3] log closed at 2017-03-09 15:51:20
                                                                                  

                                                                                  Note: First i thought that spring security was the problem cause the user didn't had permission to list that entity, but when i gave the user permission the problem changed from an error 403 to the 500 that i have now. After that i got completely stuck. I tried generating again all the views but it got no effect.

                                                                                  Thanks

                                                                                  ANSWER

                                                                                  Answered 2017-Mar-14 at 07:28

                                                                                  After your last comment about the problems that you're having with the Spring Security configuration class and the errors that are appearing you with the converters registration, I know where is your problem.

                                                                                  Some weeks ago, I detected a problem in Spring Security and I created the following issue in their repository:

                                                                                  https://github.com/spring-projects/spring-security/issues/4202

                                                                                  Seems like if a @Configuration class extends the WebSecurityConfigurerAdapter abstract class (like in the code generated by Spring Roo), some component is trying to @Autowired a ConversionService instance before the formatters have been registered in the Spring context, so the addFormatters method doesn't include any formatters on it.

                                                                                  A simple work-around that will solve your problem and you'll be able to use Spring Security in your project is to @Override the setContentNegotiationStrategy method in the generated SecurityConfiguration class without include the @Autowired annotation.

                                                                                  The following example looks how to override this method correctly. (In this sample the code is commented)

                                                                                  https://github.com/jcagarcia/proofs/blob/master/spring-security-and-formatters/src/main/java/org/springframework/roo/petclinic/config/security/SecurityConfiguration.java#L54

                                                                                  If this solves your problem, will be great that you comment on the issue saying that you have the same problem.

                                                                                  Hope it helps and thanks for all the provided information!

                                                                                  Source https://stackoverflow.com/questions/42698006

                                                                                  QUESTION

                                                                                  How can get the object in thymeleaf select option?
                                                                                  Asked 2018-Jul-13 at 11:15

                                                                                  Here in autocomplete I get the Product name as expected.

                                                                                  I want to do some calculation based on the product selected. But in doCalculation function i'm getting id instead of 'price'. So calculation not working as expected.

                                                                                  Suppose if i change String idExpression = "#{price}"; then calculation works as expected but Order not saved. Since getting error as below

                                                                                  Failed to convert property value of type [java.lang.String] to required type [com.myapp.domain.Product] for property product; nested exception is 
                                                                                  org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [@javax.persistence.OneToOne 
                                                                                   @io.springlets.format.EntityFormat com.myapp.domain.Product] for value 2500; nested exception is java.lang.IllegalStateException: Parsers are not allowed to return null: io.springlets.format.EntityParser@2201ba1c
                                                                                  

                                                                                  So I want to get the price for calculation at the same time the save feature should not be broken. For now either 1st or 2nd is working for me.

                                                                                  ProductsCollectionThymeleafController.java

                                                                                  @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE, name = "select2", value = "/s2")
                                                                                  @ResponseBody
                                                                                  public ResponseEntity> select2(GlobalSearch search, Pageable pageable,
                                                                                          Locale locale) {
                                                                                      Page products = getProductService().findAll(search, pageable);
                                                                                      String idExpression = "#{id}";
                                                                                      Select2DataSupport select2Data =
                                                                                              new Select2DataWithConversion(products, idExpression, getConversionService());
                                                                                      return ResponseEntity.ok(select2Data);
                                                                                  }
                                                                                  

                                                                                  OrderCollectionThymeleafController.java

                                                                                  @PostMapping(name = "create")
                                                                                  public ModelAndView create(@Valid @ModelAttribute Order order, BindingResult result,
                                                                                          Model model) {
                                                                                      if (result.hasErrors()) {
                                                                                          populateForm(model);
                                                                                          return new ModelAndView("/order/create");
                                                                                      }
                                                                                  
                                                                                      Order newOrder = getOrderService().save(order);
                                                                                      UriComponents showURI = getItemLink().to(OrderItemThymeleafLinkFactory.SHOW)
                                                                                              .with("order", newOrder.getId()).toUri();
                                                                                      return new ModelAndView("redirect:" + showURI.toUriString());
                                                                                  }
                                                                                  

                                                                                  orderview.html

                                                                                  
                                                                                      
                                                                                          
                                                                                              Product
                                                                                              
                                                                                                  
                                                                                                  
                                                                                                      Product
                                                                                                  
                                                                                                  
                                                                                                  Error message.
                                                                                              
                                                                                          
                                                                                          
                                                                                      
                                                                                  
                                                                                  

                                                                                  Product.java

                                                                                  @RooJavaBean
                                                                                  @RooToString
                                                                                  @RooJpaEntity
                                                                                  @RooEquals(isJpaEntity = true)
                                                                                  @Entity
                                                                                  @EntityFormat
                                                                                  public class Product {
                                                                                  
                                                                                      @Id
                                                                                      @GeneratedValue(strategy = GenerationType.AUTO)
                                                                                      private Long id;
                                                                                  
                                                                                      private String productName;
                                                                                  
                                                                                      @Min(1L)
                                                                                      @NumberFormat
                                                                                      private Integer price;
                                                                                  
                                                                                      @OneToOne(fetch = FetchType.LAZY)
                                                                                      @EntityFormat
                                                                                      private Order order;
                                                                                  
                                                                                      public static final String ITERABLE_TO_ADD_CANT_BE_NULL_MESSAGE = "The given Iterable of items to add can't be null!";
                                                                                  
                                                                                      public static final String ITERABLE_TO_REMOVE_CANT_BE_NULL_MESSAGE = "The given Iterable of items to add can't be null!";
                                                                                  
                                                                                      public Long getId() {
                                                                                          return this.id;
                                                                                      }
                                                                                  
                                                                                      public void setId(Long id) {
                                                                                          this.id = id;
                                                                                      }
                                                                                  
                                                                                      public Integer getPrice() {
                                                                                          return this.price;
                                                                                      }
                                                                                  
                                                                                      public void setPrice(Integer price) {
                                                                                          this.price = price;
                                                                                      }
                                                                                  
                                                                                      public String getProductName() {
                                                                                          return this.productName;
                                                                                      }
                                                                                  
                                                                                      public void setProductName(String productName) {
                                                                                          this.productName = productName;
                                                                                      }
                                                                                  
                                                                                      public Order getOrder() {
                                                                                          return this.order;
                                                                                      }
                                                                                  
                                                                                      public void setOrder(Order order) {
                                                                                          this.order= order;
                                                                                      }
                                                                                  }
                                                                                  

                                                                                  Order.java

                                                                                  @RooJavaBean
                                                                                  @RooToString
                                                                                  @RooJpaEntity
                                                                                  @RooEquals(isJpaEntity = true)
                                                                                  @Entity
                                                                                  @EntityFormat
                                                                                  public class Order {
                                                                                  
                                                                                      @Id
                                                                                      @GeneratedValue(strategy = GenerationType.AUTO)
                                                                                      private Long id;
                                                                                  
                                                                                      @Version
                                                                                      private Integer version;
                                                                                  
                                                                                      @OneToOne(cascade = { javax.persistence.CascadeType.MERGE,
                                                                                          javax.persistence.CascadeType.PERSIST }, fetch = FetchType.LAZY, mappedBy = "order")
                                                                                      @RooJpaRelation(type = JpaRelationType.AGGREGATION)
                                                                                      @EntityFormat
                                                                                      private Product product;
                                                                                  
                                                                                      public static final String ITERABLE_TO_ADD_CANT_BE_NULL_MESSAGE = "The given Iterable of items to add can't be null!";
                                                                                  
                                                                                      public static final String ITERABLE_TO_REMOVE_CANT_BE_NULL_MESSAGE = "The given Iterable of items to add can't be null!";
                                                                                  
                                                                                      /**
                                                                                      * This `equals` implementation is specific for JPA entities and uses the
                                                                                      * entity identifier for it, following the article in
                                                                                      * https://vladmihalcea.com/2016/06/06/how-to-implement-equals-and-hashcode-using-the-jpa-entity-identifier/
                                                                                      *
                                                                                      * @param obj
                                                                                      * @return Boolean
                                                                                      */
                                                                                      public boolean equals(Object obj) {
                                                                                          if (this == obj) {
                                                                                              return true;
                                                                                          }
                                                                                          // instanceof is false if the instance is null
                                                                                          if (!(obj instanceof Order)) {
                                                                                              return false;
                                                                                          }
                                                                                          return getId() != null && Objects.equals(getId(), ((Order) obj).getId());
                                                                                      }
                                                                                  
                                                                                      /**
                                                                                      * This `hashCode` implementation is specific for JPA entities and uses a
                                                                                      * fixed `int` value to be able to identify the entity in collections after
                                                                                      * a new id is assigned to the entity, following the article in
                                                                                      * https://vladmihalcea.com/2016/06/06/how-to-implement-equals-and-hashcode-using-the-jpa-entity-identifier/
                                                                                      *
                                                                                      * @return Integer
                                                                                      */
                                                                                      public int hashCode() {
                                                                                          return 31;
                                                                                      }
                                                                                  
                                                                                      public Long getId() {
                                                                                          return this.id;
                                                                                      }
                                                                                  
                                                                                      public void setId(Long id) {
                                                                                          this.id = id;
                                                                                      }
                                                                                  
                                                                                      public Integer getVersion() {
                                                                                          return this.version;
                                                                                      }
                                                                                  
                                                                                      public void setVersion(Integer version) {
                                                                                          this.version = version;
                                                                                      }
                                                                                  
                                                                                      public Product getProduct() {
                                                                                          return this.product;
                                                                                      }
                                                                                  
                                                                                      public void setProduct(Product product) {
                                                                                          this.product = product;
                                                                                      }
                                                                                  
                                                                                      public void addToProduct(Product product) {
                                                                                          if (product == null) {
                                                                                              removeFromProduct();
                                                                                          } else {
                                                                                              this.product = product;
                                                                                              product.setOrder(this);
                                                                                          }
                                                                                      }
                                                                                  
                                                                                      public void removeFromProduct() {
                                                                                          if (this.product != null) {
                                                                                              product.setOrder(null);
                                                                                          }
                                                                                          this.product = null;
                                                                                      }
                                                                                  }
                                                                                  

                                                                                  ANSWER

                                                                                  Answered 2018-Jul-13 at 11:15

                                                                                  By default, the Select2DataWithConversion data type only returns the identifier that will be set as value attribute of the option element and the representation of the object (in your case the product name) as the text attribute of the option element.

                                                                                  That is the minimum info that the select2 component needs to be constructed.

                                                                                  https://select2.org/data-sources/formats

                                                                                  However, as you described in your answer, it's really common to need more info in your Select2 component. For that reason, we overloaded the constructor of Select2DataWithConversion including a boolean parameter to return the entire information of the object.

                                                                                  Check this overloaded constructor here:

                                                                                  https://github.com/DISID/springlets/blob/master/springlets-data/springlets-data-commons/src/main/java/io/springlets/data/web/select2/Select2DataWithConversion.java#L76

                                                                                  So, you just need to change your ProductsCollectionThymeleafController.java to use it like:

                                                                                  Select2DataSupport select2Data = new Select2DataWithConversion(products, idExpression, getConversionService(), true);
                                                                                  

                                                                                  Now that yor select2 component is going to receive extra information, you need to store it in a data-* attribute of your select2 option during the option creation. To do that use the templateSelection function that offers the select2 component.

                                                                                  https://select2.org/programmatic-control/retrieving-selections#using-a-jquery-selector

                                                                                  Now, your doCalculation should obtain the selected option and after that, the data-price attribute.

                                                                                     
                                                                                  

                                                                                  And that's all!

                                                                                  EDIT: I've just create the following project where you could find your desired behaviour: https://github.com/jcagarcia/proofs/tree/master/select2-with-extra-info Just check the necessary changes in the following commit: https://github.com/jcagarcia/proofs/commit/105c18f7ad0da4d1e2089fbf71d4f27ccdb60689

                                                                                  Hope it helps,

                                                                                  Source https://stackoverflow.com/questions/46628912

                                                                                  QUESTION

                                                                                  SpringRoo 2.0.RC1 - How can i use date Calenderfields in entityFormatExpression and got correct format
                                                                                  Asked 2017-Apr-05 at 05:15

                                                                                  date Calendar

                                                                                  When i use date Calender field in entityFormatExpression i got a

                                                                                  entity jpa --class ~.domain.Pet --sequenceName PET_SEQ --entityFormatExpression "#{name} (#{type}) birthDay: #{birthDay}"
                                                                                  field date --fieldName birthDay --type java.util.Calendar --notNull --dateTimeFormatPattern "dd.MM.yyyy"
                                                                                  

                                                                                  Log Warning

                                                                                  2017-03-22 10:43:55.738  WARN - QP: - 6424 --- [io-8082-exec-10] .w.s.m.s.DefaultHandlerExceptionRes
                                                                                  olver : Failed to write HTTP message: org.springframework.http.converter.HttpMessageNotWritableExcep
                                                                                  tion: Could not write content: Failed to convert from type [org.springframework.roo.petclinic.domain
                                                                                  .Pet] to type [java.lang.String] for value 'Pet {id='1', version='0', sendReminders='false', name='M
                                                                                  imi', weight='4.5', birthDay='java.util.GregorianCalendar[time=1490137200000,areFieldsSet=true,areAl
                                                                                  lFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Europe/Berlin",offset=3600000,dstSa
                                                                                  vings=3600000,useDaylight=true,transitions=143,lastRule=java.util.SimpleTimeZone[id=Europe/Berlin,of
                                                                                  fset=3600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,st
                                                                                  artDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTi
                                                                                  me=3600000,endTimeMode=2]],firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=1,YEAR=2017,MONTH=2,WEEK_OF
                                                                                  _YEAR=12,WEEK_OF_MONTH=4,DAY_OF_MONTH=22,DAY_OF_YEAR=81,DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=4,AM_PM=0
                                                                                  ,HOUR=0,HOUR_OF_DAY=0,MINUTE=0,SECOND=0,MILLISECOND=0,ZONE_OFFSET=3600000,DST_OFFSET=0]', ITERABLE_T
                                                                                  O_ADD_CANT_BE_NULL_MESSAGE='The given Iterable of items to add can't be null!', ITERABLE_TO_REMOVE_C
                                                                                  ANT_BE_NULL_MESSAGE='The given Iterable of items to add can't be null!'}org.springframework.roo.petc
                                                                                  linic.domain.Pet@1f'; nested exception is org.springframework.expression.spel.SpelEvaluationExceptio
                                                                                  n: EL1001E:(pos 0): Type conversion problem, cannot convert from @javax.validation.constraints.NotNu
                                                                                  ll @javax.persistence.Temporal @org.springframework.format.annotation.DateTimeFormat java.util.Grego
                                                                                  rianCalendar to java.lang.String (through reference chain: io.springlets.data.web.select2.Select2Dat
                                                                                  aWithConversion["results"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException
                                                                                  : Failed to convert from type [org.springframework.roo.petclinic.domain.Pet] to type [java.lang.Stri
                                                                                  ng] for value 'Pet {id='1', version='0', sendReminders='false', name='Mimi', weight='4.5', birthDay=
                                                                                  'java.util.GregorianCalendar[time=1490137200000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,
                                                                                  zone=sun.util.calendar.ZoneInfo[id="Europe/Berlin",offset=3600000,dstSavings=3600000,useDaylight=tru
                                                                                  e,transitions=143,lastRule=java.util.SimpleTimeZone[id=Europe/Berlin,offset=3600000,dstSavings=36000
                                                                                  00,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600
                                                                                  000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]],fi
                                                                                  rstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=1,YEAR=2017,MONTH=2,WEEK_OF_YEAR=12,WEEK_OF_MONTH=4,DAY_
                                                                                  OF_MONTH=22,DAY_OF_YEAR=81,DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=4,AM_PM=0,HOUR=0,HOUR_OF_DAY=0,MINUTE=
                                                                                  0,SECOND=0,MILLISECOND=0,ZONE_OFFSET=3600000,DST_OFFSET=0]', ITERABLE_TO_ADD_CANT_BE_NULL_MESSAGE='T
                                                                                  he given Iterable of items to add can't be null!', ITERABLE_TO_REMOVE_CANT_BE_NULL_MESSAGE='The give
                                                                                  n Iterable of items to add can't be null!'}org.springframework.roo.petclinic.domain.Pet@1f'; nested
                                                                                  exception is org.springframework.expression.spel.SpelEvaluationException: EL1001E:(pos 0): Type conv
                                                                                  ersion problem, cannot convert from @javax.validation.constraints.NotNull @javax.persistence.Tempora
                                                                                  l @org.springframework.format.annotation.DateTimeFormat java.util.GregorianCalendar to java.lang.Str
                                                                                  ing (through reference chain: io.springlets.data.web.select2.Select2DataWithConversion["results"])
                                                                                  2017-03-22 10:43:55.754  WARN - QP: - 6424 --- [io-8082-exec-10] .w.s.m.s.DefaultHandlerExceptionRes
                                                                                  olver : Resolved exception caused by Handler execution: org.springframework.http.converter.HttpMessa
                                                                                  geNotWritableException: Could not write content: Failed to convert from type [org.springframework.ro
                                                                                  o.petclinic.domain.Pet] to type [java.lang.String] for value 'Pet {id='1', version='0', sendReminder
                                                                                  s='false', name='Mimi', weight='4.5', birthDay='java.util.GregorianCalendar[time=1490137200000,areFi
                                                                                  eldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Europe/Berlin",of
                                                                                  fset=3600000,dstSavings=3600000,useDaylight=true,transitions=143,lastRule=java.util.SimpleTimeZone[i
                                                                                  d=Europe/Berlin,offset=3600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMont
                                                                                  h=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,en
                                                                                  dDayOfWeek=1,endTime=3600000,endTimeMode=2]],firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=1,YEAR=20
                                                                                  17,MONTH=2,WEEK_OF_YEAR=12,WEEK_OF_MONTH=4,DAY_OF_MONTH=22,DAY_OF_YEAR=81,DAY_OF_WEEK=4,DAY_OF_WEEK_
                                                                                  IN_MONTH=4,AM_PM=0,HOUR=0,HOUR_OF_DAY=0,MINUTE=0,SECOND=0,MILLISECOND=0,ZONE_OFFSET=3600000,DST_OFFS
                                                                                  ET=0]', ITERABLE_TO_ADD_CANT_BE_NULL_MESSAGE='The given Iterable of items to add can't be null!', IT
                                                                                  ERABLE_TO_REMOVE_CANT_BE_NULL_MESSAGE='The given Iterable of items to add can't be null!'}org.spring
                                                                                  framework.roo.petclinic.domain.Pet@1f'; nested exception is org.springframework.expression.spel.Spel
                                                                                  EvaluationException: EL1001E:(pos 0): Type conversion problem, cannot convert from @javax.validation
                                                                                  .constraints.NotNull @javax.persistence.Temporal @org.springframework.format.annotation.DateTimeForm
                                                                                  at java.util.GregorianCalendar to java.lang.String (through reference chain: io.springlets.data.web.
                                                                                  select2.Select2DataWithConversion["results"]); nested exception is com.fasterxml.jackson.databind.Js
                                                                                  onMappingException: Failed to convert from type [org.springframework.roo.petclinic.domain.Pet] to ty
                                                                                  pe [java.lang.String] for value 'Pet {id='1', version='0', sendReminders='false', name='Mimi', weigh
                                                                                  t='4.5', birthDay='java.util.GregorianCalendar[time=1490137200000,areFieldsSet=true,areAllFieldsSet=
                                                                                  true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Europe/Berlin",offset=3600000,dstSavings=36000
                                                                                  00,useDaylight=true,transitions=143,lastRule=java.util.SimpleTimeZone[id=Europe/Berlin,offset=360000
                                                                                  0,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWee
                                                                                  k=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,
                                                                                  endTimeMode=2]],firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=1,YEAR=2017,MONTH=2,WEEK_OF_YEAR=12,WE
                                                                                  EK_OF_MONTH=4,DAY_OF_MONTH=22,DAY_OF_YEAR=81,DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=4,AM_PM=0,HOUR=0,HOU
                                                                                  R_OF_DAY=0,MINUTE=0,SECOND=0,MILLISECOND=0,ZONE_OFFSET=3600000,DST_OFFSET=0]', ITERABLE_TO_ADD_CANT_
                                                                                  BE_NULL_MESSAGE='The given Iterable of items to add can't be null!', ITERABLE_TO_REMOVE_CANT_BE_NULL
                                                                                  _MESSAGE='The given Iterable of items to add can't be null!'}org.springframework.roo.petclinic.domai
                                                                                  n.Pet@1f'; nested exception is org.springframework.expression.spel.SpelEvaluationException: EL1001E:
                                                                                  (pos 0): Type conversion problem, cannot convert from @javax.validation.constraints.NotNull @javax.p
                                                                                  ersistence.Temporal @org.springframework.format.annotation.DateTimeFormat java.util.GregorianCalenda
                                                                                  r to java.lang.String (through reference chain: io.springlets.data.web.select2.Select2DataWithConver
                                                                                  sion["results"])
                                                                                  

                                                                                  When i create a Visit the Pet don't show in List.

                                                                                  date Date

                                                                                  When i use an date Date field and create a Visit the Pet shown in List but the format is not correct.

                                                                                  In Clinic Eaxmpel i have set a birthDay field to Pet and use it in entityFormatExpression

                                                                                  entity jpa --class ~.domain.Pet --sequenceName PET_SEQ --entityFormatExpression "#{name} (#{type}) birthDay: #{birthDay}"
                                                                                  
                                                                                  focus --class ~.domain.Pet
                                                                                  field date --fieldName birthDay --type java.util.Date --notNull --dateTimeFormatPattern "dd.MM.yyyy"
                                                                                  

                                                                                  I have set dateTimeFormatPattern "dd.MM.yyyy"

                                                                                  In create edit/ view i see

                                                                                  enter image description here

                                                                                  When i create a visit Object i see

                                                                                  enter image description here

                                                                                  This is not the format i used for this field.

                                                                                  ANSWER

                                                                                  Answered 2017-Mar-29 at 08:56

                                                                                  The conversion to String when the JSON data is sent to the select2 component is performed by the EntityExpression utilities which are registered in the ConversionService.

                                                                                  Those utilities use the SpEl support to parse the expression and convert the entity to a String. It seems the SpEl expression isn't using or doesn't have access to the ConversionService itself to convert to String the object properties included in the expression.

                                                                                  I've created an issue in the Springlets project to take a look at the problem.

                                                                                  Source https://stackoverflow.com/questions/42947604

                                                                                  QUESTION

                                                                                  Spring Roo 2.0.RC1 - Spring Security Provider Default and add Spring Security Configuration
                                                                                  Asked 2017-Mar-31 at 08:33

                                                                                  Another Problem.

                                                                                  I can not use Spring Security Provider Springlets_Jpa see (Spring Roo 2.0.RC1: use Mysql DB with springlets authentification)

                                                                                  Then is use the default Provider. I have default loginin popup with default user and password show in shell.

                                                                                  I want't to have a user and role table an use login view. I have added Entities User and Role with Roo.

                                                                                  I have no yet spring security configuration.

                                                                                  entity jpa --class ~.model.User --plural Users --table USER --sequenceName USER_ID_SEQ --identifierStrategy AUTO --identifierColumn USER_ID --versionField version --versionType java.lang.Long --versionColumn VERSION --entityFormatExpression "User: #{firstname} #{lastname} (#{username})"
                                                                                  entity jpa --class ~.model.Role --plural Roles --table ROLE --sequenceName ROLE_ID_SEQ --identifierStrategy AUTO --identifierColumn ROLE_ID --versionField version --versionType java.lang.Long --versionColumn VERSION --entityFormatExpression "#{rolename}"
                                                                                  
                                                                                  focus --class ~.model.User
                                                                                  field string --fieldName username --column USERNAME --notNull --unique --comment "Username des Nutzers" --regexp ^[a-zA-Z0-9_]{4,}$ 
                                                                                  field string --fieldName password --column PASSWORD --notNull --comment "Passwort des Nutzers" --regexp ^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9]{6,}$
                                                                                  field string --fieldName firstname --column FIRST_NAME --notNull --comment "Vorname des Nutzers"
                                                                                  field string --fieldName lastname --column LAST_NAME --notNull  --comment "Nachname des Nutzers"
                                                                                  field string --fieldName email --column EMAIL --notNull --unique --comment "Email des Nutzers" --regexp ^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$
                                                                                  focus --class ~.model.Role
                                                                                  field enum --fieldName rolename --column ROLENAME --type ~.model.restricted.RoleType --notNull --comment "Rollentyp"
                                                                                  field set --fieldName userlst --type ~.model.User --mappedBy role --joinColumnName ROLE_ID --permitReservedWords --comment "Liste der User mit diesem Typ"
                                                                                  

                                                                                  When i start webapp i acbb create Roles and User. I can select Roles in create User view.

                                                                                  Now i add spring security configuration class (very simple allow all without login)

                                                                                  import org.springframework.context.annotation.Configuration;
                                                                                  import org.springframework.security.config.annotation.web.builders.HttpSecurity;
                                                                                  import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
                                                                                  import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
                                                                                  
                                                                                  @Configuration
                                                                                  @EnableWebSecurity
                                                                                  public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
                                                                                  
                                                                                      @Override
                                                                                      protected void configure(HttpSecurity httpSecurity) throws Exception {
                                                                                          httpSecurity.authorizeRequests().antMatchers("/").permitAll();
                                                                                      }
                                                                                  
                                                                                  }
                                                                                  

                                                                                  When i now start the webapp and create User i can't select Role from List. I get WARN

                                                                                  2017-03-30 09:12:55.088  WARN 6644 --- [nio-8082-exec-7] .w.s.m.s.DefaultHandlerExceptionResolver :
                                                                                  Resolved exception caused by Handler execution: org.springframework.http.converter.HttpMessageNotWri
                                                                                  tableException: Could not write content: No converter found capable of converting from type [de.quin
                                                                                  tra.rechnungspruefung.model.Role] to type [java.lang.String] (through reference chain: io.springlets
                                                                                  .data.web.select2.Select2DataWithConversion["results"]); nested exception is com.fasterxml.jackson.d
                                                                                  atabind.JsonMappingException: No converter found capable of converting from type [de.quintra.rechnun
                                                                                  gspruefung.model.Role] to type [java.lang.String] (through reference chain: io.springlets.data.web.s
                                                                                  elect2.Select2DataWithConversion["results"])
                                                                                  

                                                                                  And now role show in List. What is wrong?

                                                                                  ANSWER

                                                                                  Answered 2017-Mar-31 at 07:35

                                                                                  Some weeks ago, I detected a problem in Spring Security and I created the following issue in their repository:

                                                                                  https://github.com/spring-projects/spring-security/issues/4202

                                                                                  Seems like if a @Configuration class extends the WebSecurityConfigurerAdapter abstract class (like in the code generated by Spring Roo), some component is trying to @Autowired a ConversionService instance before the formatters have been registered in the Spring context, so the addFormatters method doesn't include any formatters on it.

                                                                                  A simple work-around that will solve your problem and you'll be able to use Spring Security in your project is to @Override the setContentNegotiationStrategy method in the generated SecurityConfiguration class without include the @Autowired annotation.

                                                                                  The following example looks how to override this method correctly. (In this sample the code is commented)

                                                                                  https://github.com/jcagarcia/proofs/blob/master/spring-security-and-formatters/src/main/java/org/springframework/roo/petclinic/config/security/SecurityConfiguration.java#L54

                                                                                  If this solves your problem, will be great that you comment on the issue saying that you have the same problem.

                                                                                  Hope it helps,

                                                                                  Source https://stackoverflow.com/questions/43110991

                                                                                  QUESTION

                                                                                  What are the differences between spring security providers? (Spring Roo 2 M3)
                                                                                  Asked 2017-Feb-19 at 15:41

                                                                                  Well i'm building some personal project to learn spring roo 2. Now i'm struggling with spring security. There is little information about spring roo 2 in google and many relatively useful information on spring boot relating to spring roo.

                                                                                  with the command "security setup" you got the "--provider" option.

                                                                                  This is the description that the help gives you:

                                                                                  optional --provider: The Spring Security provider to install. Possible values are: DEFAULT (default Spring Security configuration provided by Spring Boot will be used), and SPRINGLETS_JPA (advanced Spring Security configuration will be included using Springlets JPA Authentication).; default: 'DEFAULT'

                                                                                  I couldn't find the difference between these two options, even on the spring roo M3 reference documentation. Even searching for "Springlets JPA Authentication" gives no information about it.

                                                                                  Anyone has any clue about this?

                                                                                  Thanks

                                                                                  ANSWER

                                                                                  Answered 2017-Feb-19 at 15:41

                                                                                  These are the main differences between this two providers:

                                                                                  • DEFAULT: Is the default Spring Security auto-configuration provided by Spring Boot when you include the spring-boot-starter-security in your project classpath. This is the default option because Spring Roo always tries to generate applications that use the auto-configuration provided by Spring Boot.

                                                                                    • Selecting this provided the following changes will be applied to your project:
                                                                                      • spring-boot-starter-security dependency will be included to your pom.xml file
                                                                                    • If you want to know more information about this configuration you should check the spring boot reference guide
                                                                                  • SPRINGLETS_JPA: If you select this provider, the default Spring Security auto-configuration provided by Spring Boot will be used. In addition, this provider will include the Springlets library to your classpath that provides you some extra starters to auto-configure advanced Spring Security properties. Also, configures the security authentication to use and user from the database instead of the default in-memory authentication provided by Spring Boot auto-configuration. You will be able to manage these configuration using the application.properties file and including the properties springlets.security.auth.in-memory.enabled and springlets.security.auth.in-memory.erase-credentials.

                                                                                    • Selecting this provided the following changes will be applied to your project:
                                                                                      • springlets-boot-starter-authentication dependency will be included to your pom.xml file
                                                                                      • security.enable-csrf=true property will be included to enable CSRF. Know more about CSRF and Spring Security here
                                                                                    • To know more about the Springlets Security project check the Springlets project page

                                                                                  Hope it helps,

                                                                                  Source https://stackoverflow.com/questions/42324952

                                                                                  Community Discussions, Code Snippets contain sources that include Stack Exchange Network

                                                                                  Vulnerabilities

                                                                                  No vulnerabilities reported

                                                                                  Install springlets

                                                                                  The Springlets libraries are released in the Maven central repository, so to use them in a Java project you just have to add them as dependencies if you use a build tool that supports it, like maven or graddle.

                                                                                  Support

                                                                                  If you have any trouble using any of the Springlets modules:.
                                                                                  Find more information at:
                                                                                  Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
                                                                                  Find more libraries
                                                                                  Explore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits​
                                                                                  Save this library and start creating your kit
                                                                                  CLONE
                                                                                • HTTPS

                                                                                  https://github.com/DISID/springlets.git

                                                                                • CLI

                                                                                  gh repo clone DISID/springlets

                                                                                • sshUrl

                                                                                  git@github.com:DISID/springlets.git

                                                                                • Share this Page

                                                                                  share link

                                                                                  Consider Popular Object-Relational Mapping Libraries

                                                                                  Try Top Libraries by DISID

                                                                                  gvnix-samples

                                                                                  by DISIDJavaScript

                                                                                  fiebdc3-parser

                                                                                  by DISIDJava

                                                                                  disid-slides

                                                                                  by DISIDCSS

                                                                                  disid-proof-ldap

                                                                                  by DISIDCSS

                                                                                  disid-blog

                                                                                  by DISIDCSS

                                                                                  Compare Object-Relational Mapping Libraries with Highest Support

                                                                                  Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
                                                                                  Find more libraries
                                                                                  Explore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits​
                                                                                  Save this library and start creating your kit