Spring Data error: At least one JPA metamodel must be present

It says At least one JPA metamodel must be present! in the stacktrace but I have a User model as you can see:

@Table(catalog = "profiles", name = "users")
public class User extends BaseEntity {

    @GeneratedValue(generator = "UUID")
            name = "UUID",
            strategy = "org.hibernate.id.UUIDGenerator"
    @Column(name = "uid", unique = true, updatable = false, nullable = false, length = 36)
    private UUID uid;


How can I fix this error which is upcoming on startup?

  .   ____          _            __ _ _
 /\ / ___'_ __ _ _(_)_ __  __ _    
( ( )___ | '_ | '_| | '_ / _` |    
 \/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |___, | / / / /
 :: Spring Boot ::        (v1.5.9.RELEASE)

2017-12-18 19:59:43.073  INFO 12360 --- [           main] ThePluginUsingTheLibrary                 : Starting ThePluginUsingTheLibrary on DESKTOP-E2R1T7J with PID 12360 (C:UsersRobinIdeaProjectsMyPvPCore3.0targettest-classes started by Robin in C:UsersRobinIdeaProjectsMyPvPCore3.0)
2017-12-18 19:59:43.076  INFO 12360 --- [           main] ThePluginUsingTheLibrary                 : No active profile set, falling back to default profiles: default
2017-12-18 19:59:43.142  INFO 12360 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@436a4e4b: startup date [Mon Dec 18 19:59:43 CET 2017]; root of context hierarchy
2017-12-18 19:59:43.752  WARN 12360 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: At least one JPA metamodel must be present!
2017-12-18 19:59:43.757  INFO 12360 --- [           main] utoConfigurationReportLoggingInitializer : 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-12-18 19:59:43.762 ERROR 12360 --- [           main] o.s.boot.SpringApplication               : Application startup failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: At least one JPA metamodel must be present!
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:742) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
    at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
    at eu.mypvp.core.Core.init(Core.java:37) [classes/:na]
    at ThePluginUsingTheLibrary.main(ThePluginUsingTheLibrary.java:20) [test-classes/:na]
Caused by: java.lang.IllegalArgumentException: At least one JPA metamodel must be present!
    at org.springframework.util.Assert.notEmpty(Assert.java:277) ~[spring-core-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.data.jpa.mapping.JpaMetamodelMappingContext.<init>(JpaMetamodelMappingContext.java:54) ~[spring-data-jpa-2.0.2.RELEASE.jar:2.0.2.RELEASE]
    at org.springframework.data.jpa.repository.config.JpaMetamodelMappingContextFactoryBean.createInstance(JpaMetamodelMappingContextFactoryBean.java:88) ~[spring-data-jpa-2.0.2.RELEASE.jar:2.0.2.RELEASE]
    at org.springframework.data.jpa.repository.config.JpaMetamodelMappingContextFactoryBean.createInstance(JpaMetamodelMappingContextFactoryBean.java:43) ~[spring-data-jpa-2.0.2.RELEASE.jar:2.0.2.RELEASE]
    at org.springframework.beans.factory.config.AbstractFactoryBean.afterPropertiesSet(AbstractFactoryBean.java:134) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    ... 15 common frames omitted

See the whole project source codefor more overview if you need: https://gitlab.com/roboflax/Spring-Data-In-Library

Thanks for your help!

Usage of Spring Security in console Java Application

I’m building a simple console application which uses nice stack of frameworks(Hibernate, Spring), but found myself struggling with auth/reg issues. Usually for web projects I would use Spring Security framework, restrict some URL add configure login page which is completely processed by the framework automatically. But my console application contains 2 issues:

  1. Storing encoded passwords in a database
  2. Using User Service to configure Spring to work with my database

1st problem can be solved using some password encoder and specifying it in a spring-security configuration file like this

<beans:bean class="myconsoleapp.util.PasswordUtil" id="passwordEncoder" factory-method="getPasswordEncoder"/> 

and later specify encoder in authentication manager

        <authentication-provider user-service-ref="userService">
            <password-encoder ref="passwordEncoder"/>

2nd problem seems to be more complex. In my service class I’ve implemented UserDetailsService spring security interface and have overridden loadUserByUsername method like this

public class UserServiceImpl implements UserService, UserDetailsService {
public AuthorizedUser loadUserByUsername(String email) throws UsernameNotFoundException {
        User user = repository.getByEmail(email.toLowerCase());
        return new AuthorizedUser(user);

And my AuthorizedUser class has a constructor like this

public class AuthorizedUser extends org.springframework.security.core.userdetails.User {
private User user;
public AuthorizedUser(User user) {
        super(user.getEmail(), user.getPassword(), user.isEnabled(), true, true, true, user.getRoles());
        this.user= user;

Finally we’re close to the question.. How can I use all that stuff providing email and password input from the console?? I see it like that:

System.out.println("Enter email:");
String userEmail = inputStream.readLine();
System.out.println("Enter your password");
String userPasspord = inputStream.readLine();
userService.//<-What method should I use here?

Jaxb and JPA: class Embeddable Could not determine type for java.util.List

When executing my class “LoteRpsV3Vo.java” I get the following error:

Caused by: org.hibernate.MappingException: Could not determine type for: java.util.List, at table: LoteRps, for columns: [org.hibernate.mapping.Column(rps)]

I’ve been trying to solve this problem for 2 weeks. I could simply remove the “public static class ListRps” and migrate its “rps” attribute to the “LoteRpsV3Vo.java” class that works, however it does not apply to me.
Another time, I overwritten an identical relationship and it worked, I do not know why it does not work here.

Can you help me ? Below are my classes.

package nfse.vo;

import java.io.Serializable;
import java.math.BigInteger;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.CascadeType;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Embeddable;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;

 * @author Administrador
@XmlType(name = "tcLoteRps", propOrder={

public class LoteRpsV3Vo implements Serializable
    private String id;
    private BigInteger numeroLote;
    private String cnpj;
    private String inscricaoMunicipal;
    private Integer quantidadeRps;
    private LoteRpsV3Vo.ListaRps listaRps;
    private LocalDateTime dataRecebimento;
    private String protocolo;
    private byte situacao;
    private MensagemRetornoV3Vo mensagemRetorno;
    public LoteRpsV3Vo() {
    public String toString() {
        return "LoteRpsV3Vo{" + "id=" + id + ", numeroLote=" + numeroLote + ", cnpj=" + cnpj + ", inscricaoMunicipal=" + inscricaoMunicipal + ", quantidadeRps=" + quantidadeRps + ", listaRps=" + listaRps + ", dataRecebimento=" + dataRecebimento + ", protocolo=" + protocolo + ", situacao=" + situacao + ", mensagemRetorno=" + mensagemRetorno + '}';
    public int hashCode() {
        int hash = 5;
        hash = 29 * hash + Objects.hashCode(this.id);
        return hash;
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        if (obj == null) {
            return false;
        if (getClass() != obj.getClass()) {
            return false;
        final LoteRpsV3Vo other = (LoteRpsV3Vo) obj;
        if (!Objects.equals(this.id, other.id)) {
            return false;
        return true;
    // getters e setters
    @Column(nullable = false, length = 255, unique = true)
    @XmlAttribute(name = "Id")
    public String getId() {
        return id;
    public void setId(String id) {
        this.id = id;
    @Column(nullable = false, length = 15, unique = true)
    @XmlElement(name = "NumeroLote", required = true)
    @XmlSchemaType(name = "nonNegativeInteger")
    public BigInteger getNumeroLote() {
        return numeroLote;
    public void setNumeroLote(BigInteger numeroLote) {
        this.numeroLote = numeroLote;
    @Column(nullable = false, length = 14)
    @XmlElement(name = "Cnpj", required = true)
    public String getCnpj() {
        return cnpj;
    public void setCnpj(String cnpj) {
        this.cnpj = cnpj;
    @Column(nullable = false, length = 15)
    @XmlElement(name = "InscricaoMunicipal", required = true)
    public String getInscricaoMunicipal() {
        return inscricaoMunicipal;
    public void setInscricaoMunicipal(String inscricaoMunicipal) {
        this.inscricaoMunicipal = inscricaoMunicipal;

    @Column(nullable = false, length = 4)
    @XmlElement(name = "QuantidadeRps")
    public Integer getQuantidadeRps() {
        return quantidadeRps;
    public void setQuantidadeRps(Integer quantidadeRps) {
        this.quantidadeRps = quantidadeRps;
    @XmlElement(name = "ListaRps", required = true)
    @AssociationOverride(name = "listaRps.rps",
            joinColumns = @JoinColumn(name = "loteRpsId")
    public ListaRps getListaRps() {
        return listaRps;
    public void setListaRps(ListaRps listaRps) {
        this.listaRps = listaRps;
    public LocalDateTime getDataRecebimento() {
        return dataRecebimento;
    public void setDataRecebimento(LocalDateTime dataRecebimento) {
        this.dataRecebimento = dataRecebimento;
    public String getProtocolo() {
        return protocolo;
    public void setProtocolo(String protocolo) {
        this.protocolo = protocolo;
    public byte getSituacao() {
        return situacao;
    public void setSituacao(byte situacao) {
        this.situacao = situacao;
    @OneToOne(mappedBy = "loteRps", cascade = CascadeType.PERSIST, fetch = FetchType.LAZY, orphanRemoval = true)
    public MensagemRetornoV3Vo getMensagemRetorno() {
        return mensagemRetorno;

    public void setMensagemRetorno(MensagemRetornoV3Vo mensagemRetorno) {
        this.mensagemRetorno = mensagemRetorno;

    @XmlType(name = "", propOrder = {
    public static class ListaRps
        @XmlElement(name = "Rps", required = true)
        @OneToMany(cascade = CascadeType.PERSIST)
        @JoinColumn(name = "loteRpsId")
        protected List<RpsV3Vo> rps;
        public List<RpsV3Vo> getRps() {
            if (rps == null)
                rps = new ArrayList<>();
            return rps;

Call method for the above class

public EnvioLREV3Vo criarNFSETeste() throws DatatypeConfigurationException
    BaseDao dao = new LoteRpsDao();       
    // crio o lote
    LoteRpsV3Vo loteRps = new LoteRpsV3Vo();
    loteRps.setNumeroLote(new BigInteger("002457"));
    // crio o rps
    RpsV3Vo rps = new RpsV3Vo();       
    // crio InfRps
    InfRpsV3Vo infRps = new InfRpsV3Vo();
    // crio IdentificacaoRps
    IdentificacaoRpsV3Vo identificacaoRps = new IdentificacaoRpsV3Vo();
    identificacaoRps.setNumero(new BigInteger("002457"));
    byte t = 1;
    byte no = 1;
    byte ret = 6;
    byte osn = 1;
    byte ic = 2;
    byte s = 1;
    // crio DadosServico
    DadosServicoV3Vo servico = new DadosServicoV3Vo();
    // crio Valores
    ValoresV3Vo valores = new ValoresV3Vo();
    valores.setValorServicos(new BigDecimal("70.00"));
    valores.setValorDeducoes(new BigDecimal("0.00"));
    valores.setValorPis(new BigDecimal("0.00"));
    valores.setValorCofins(new BigDecimal("0.00"));
    valores.setValorInss(new BigDecimal("0.00"));
    valores.setValorIr(new BigDecimal("0.00"));
    valores.setValorCsll(new BigDecimal("0.00"));
    byte ir = 2;
    valores.setValorIss(new BigDecimal("0.00"));
    valores.setBaseCalculo(new BigDecimal("70.00"));
    valores.setAliquota(new BigDecimal("0.0423"));
    valores.setValorLiquidoNfse(new BigDecimal("70.00"));
    valores.setDescontoCondicionado(new BigDecimal("0.00"));
    servico.setDiscriminacao("Comissao IATA R$ 50,00");
    // crio IdentificacaoPrestador
    IdentificacaoPrestadorV3Vo identificacaoPrestador = new IdentificacaoPrestadorV3Vo();
    // cria DadosTomador
    DadosTomadorV3Vo tomador = new DadosTomadorV3Vo();
    // add uma IdentificacaoTomador para DadosTomador
    IdentificacaoTomadorV3Vo identificacaoTomador = new IdentificacaoTomadorV3Vo();
    // add CpfCnpj em IdentificacaoTomador
    CpfCnpjV3Vo cpfCnpj = new CpfCnpjV3Vo();
    tomador.setRazaoSocial("ALJA HOTELARIA E SERVIçOS LTDA - EPP");
    // cria Endereco para o Tomador
    EnderecoV3Vo tendereco = new EnderecoV3Vo();
    tendereco.setEndereco("Avenida 1");
    // cria Contato para o Tomador
    ContatoV3Vo tcontato = new ContatoV3Vo();
    RpsV3Vo mRps = (RpsV3Vo) dao.insert(rps);
    LoteRpsV3Vo.ListaRps listaRps =new  LoteRpsV3Vo.ListaRps();
    LoteRpsV3Vo mLoteRps = (LoteRpsV3Vo) dao.insert(loteRps);
    // crio o envio
    EnvioLREV3Vo envio = new EnvioLREV3Vo();
    return envio;

Método insert

public Object insert (Object obj)
    this.em = getEntityManager();
    EntityTransaction et = this.em.getTransaction();
    try {
        return obj;
    } catch(Throwable e) {
    } finally {
    throw new UnsupportedOperationException("Not supported yet.");

Thank you all !

Check if array is single or multidimensional

I’m writing a class for my class that I’m going to be using as a helper class. However, I don’t know if it’s possible or not to check if any given array is single or multidimensional. What I currently have:

public class Grid {
    private Object[] board;

    public Grid( Object[] b ) {
        this.board = b;
    public Grid( Object[][] b ) {
        this.board = b;

but obviously that wouldn’t work for any given array. Would I have to just make separate methods for the type of array? (Keep in mind we won’t be using more than two-dimension arrays (at least yet)

Would it be best if I did this? (for example):

public Object getValue( Object[] b, int index ) throws ArrayIndexOutOfBoundsException {
    if ( index >= b.length ) {
        throw new ArrayIndexOutOfBoundsException( "Index too high" );
    return b[ index ];

public Object getValue( Object[][] b, int index1, int index2 ) throws ArrayIndexOutOfBoundsException {
    if ( index1 >= b.length ) {
        throw new ArrayIndexOutOfBoundsException( "Index1 too high" );
    } else if ( index2 >= b[ 0 ].length ) {
        throw new ArrayIndexOutOfBoundsException( "Index2 too high" );
    return b[ index1 ][ index2 ];

So, in essence, I’m wondering if it’s possible to make the above example easier by simply being able to check if an array is multidimensional or not, and use that as a basis of my methods.

HttpRetryException when executing ant deploy task – Tomcat 9

I have set up an Apache Tomcat 9 Server on my local windows machine. As my next goal I wanted to deploy a .war file to the tomcat server automatically using ANT.

I have followed along this guide which uses the tomcat manager: http://tomcat.apache.org/tomcat-9.0-doc/manager-howto.html#Executing_Manager_Commands_With_Ant

The reload and undeploy tasks are already working. However whenever I try to do the deploy task I get the following error:


java.net.HttpRetryException: cannot retry due to server authentication, in streaming mode

Excerpt of my build.xml:

<property name="url"      value="http://localhost:8080/manager/text"/>
<property name="username" value="xxxx"/>
<property name="password" value="xxxx"/>
<property name="path" value="myproject"/>
<target name="deploy" description="Install web application">
    <deploy url="${url}" username="${username}"
<target name="reload" description="Reload web application" depends="compile">
        <reload  url="${url}" username="${username}" password="${password}" path="/${path}"/>

<target name="undeploy" description="Remove web application">
    <undeploy url="${url}" username="${username}" password="${password}" path="/${path}"/>

What could be the issue here? I’m doing everything in eclipse.

Combing xml and java configuration for spring/hibernate datasource as AWS RDS

Trying to connect my spring/hibernate project which is running locally on my machine to my aws rds.I am trying to modify my previous setup which was a h2 local database datasource. Unsure how to combine the xml and java config to import the bean into the java config?

My dataconfig.xml

<beans xmlns="http://www.springframework.org/schema/beans"

<aws-context:context-region region="eu-west-1a"/>
    <aws-context:simple-credentials access-key="
   my key" secret-key="my key" />
        password="my password">


@EnableJpaRepositories(basePackages = "haughton.icecreamapi.dao")
public class DataConfig {
private Environment env;

public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();

    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();


    return factory;

private Properties getHibernateProperties() {
    Properties properties = new Properties();
    properties.put("hibernate.dialect", env.getProperty("hibernate.dialect"));
    properties.put("hibernate.format_sql", env.getProperty("hibernate.format_sql"));
    properties.put("hibernate.show_sql", env.getProperty("hibernate.show_sql"));
    //removed to keep db consistent
    properties.put("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto"));
    return properties;

public DataSource dataSource() {
    BasicDataSource ds = new BasicDataSource();

    // Driver class name

    // Set URL

    // Set username & password

    return ds;


Converting a view from JavaFX to HTML

I wrote a Java desktop application using JavaFX with xml files. Is it possible to “port” it leaving all the code unchanged, just using html files instead (for the web application version)? I would like to keep @FXML tags as they are, for example.

Is it possible to read a mock element from an html or text file and feed it to selenium?

I’m looking for a way to unit-test methods for my e2e tests. Thus I need a way to feed mock web elements to selenium. I first looked at IWebElement interface, but it’s huge and it seems like it would be cumbersome. I can try to cast some object into IWebElement. Other idea is deserializing a json file.

But I wonder, can I make a text file with html elements and point selenium to look into it? Can I do without having to serve it?

I’m using c#, but I guess java solution would work as well.

How do I take a picture on Android app, and save photo to gallery in internal storage? (Not SD Card)

I have my app so I have the ability to open the camera and take a picture, the app then shows me a preview of the photo just taken, and when I press ‘OK’, it is gone. I want to be able to save the image I have taken to my internal storage on my phone, (and possibly have a function so I can access my gallery and preview it later on). I have searched everywhere but all the help I am getting is to store it on an SD card, whereas I want to use my phones built in storage. Thank you

My code so far:

Button butCamera;
ImageView imageView;

protected void onCreate(Bundle savedInstanceState) {

    butCamera = (Button) findViewById(R.id.butCamera);
    imageView = (ImageView) findViewById(R.id.imageView);

    butCamera.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            Intent intent = new Intent (MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(intent, 0);


public void onActivityResult(int requestCode, int resultCode, Intent data){
    super.onActivityResult(requestCode, resultCode, data);
    Bitmap bitmap = (Bitmap)data.getExtras().get("data");