Importei um projeto e estou tentando persistir para tentar conexão mas estou com erro. Creio eu que tem algo haver com log mas não conheço muito.
Erro
log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: /logs/pedido-venda.log (No such file or directory)
at java.base/java.io.FileOutputStream.open0(Native Method)
at java.base/java.io.FileOutputStream.open(FileOutputStream.java:293)
at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:235)
at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:155)
at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)
at org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFileAppender.java:223)
at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:295)
at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:176)
at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:191)
at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:523)
at org.apache.log4j.xml.DOMConfigurator.parseRoot(DOMConfigurator.java:492)
at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:1006)
at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:872)
at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:778)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:526)
at org.apache.log4j.LogManager.<clinit>(LogManager.java:127)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
at org.jboss.logging.LoggerProviders.tryLog4j(LoggerProviders.java:128)
at org.jboss.logging.LoggerProviders.findProvider(LoggerProviders.java:90)
at org.jboss.logging.LoggerProviders.find(LoggerProviders.java:32)
at org.jboss.logging.LoggerProviders.<clinit>(LoggerProviders.java:29)
at org.jboss.logging.Logger.getLogger(Logger.java:2465)
at org.jboss.logging.Logger.getLogger(Logger.java:2490)
at org.hibernate.jpa.HibernatePersistenceProvider.<clinit>(HibernatePersistenceProvider.java:38)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:789)
at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:729)
at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1403)
at javax.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver.getPersistenceProviders(PersistenceProviderResolverHolder.java:111)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:76)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
at TesteCliente.main(TesteCliente.java:13)
log4j:ERROR Either File or DatePattern options are not set for appender [arquivo].
Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named PedidoPU
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:85)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
at TesteCliente.main(TesteCliente.java:13)
Classe que estou tentando persisitr.
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import com.algaworks.pedidovenda.model.Cliente;
import com.algaworks.pedidovenda.model.Endereco;
import com.algaworks.pedidovenda.model.TipoPessoa;
public class TesteCliente {
public static void main(String[] args) {
EntityManagerFactory factory = Persistence.createEntityManagerFactory("PedidoPU");
EntityManager manager = factory.createEntityManager();
EntityTransaction trx = manager.getTransaction();
trx.begin();
Cliente cliente = new Cliente();
cliente.setNome("João das Couves");
cliente.setEmail("joao@dascouves.com");
cliente.setDocumentoReceitaFederal("123.123.123-12");
cliente.setTipo(TipoPessoa.FISICA);
Endereco endereco = new Endereco();
endereco.setLogradouro("Rua das Aboboras Vermelhas");
endereco.setNumero("111");
endereco.setCidade("Uberlândia");
endereco.setUf("MG");
endereco.setCep("38400-000");
endereco.setCliente(cliente);
cliente.getEnderecos().add(endereco);
manager.persist(cliente);
trx.commit();
}
}