Я новичок в вопросах JPA, EJB и REST и хотел сделать несколько простых приложений crud. Когда я использую EntityManagerFactory, я получаю сущности из Derby, но проблема начинается, когда я хочу использовать транзакции для сохраняющихся объектов. Когда я пытаюсь ввести EntityManager, я получаю исключение NullPointerException. Я видел несколько тем в stackOverflow с аналогичными проблемами, но, видимо, я не могу решить свою проблему.EntityManages NullPointerException, eclipselink + tomee + Jersey + Derby
Я просто хочу запустить это приложение и сосредоточиться на концепции сохранения и не потратил еще несколько дней, пытаясь его настроить. Кроме того, я не знаю, почему я не могу предоставить DataSource в WEB-INF/resources.xml (WARNING - Failed to register in JMX: javax.naming.NameNotFoundException: Name "Resource/Crud/localDB" not found.
)
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="MyPersistenceUnit" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>localDB</jta-data-source>
<class>com.kuba.crud.model.Customer</class>
<properties>
<property name="javax.persistence.jdbc.user" value="testUser"/>
<property name="javax.persistence.jdbc.password" value="password"/>
<property name="javax.persistence.target-database." value="Derby"/>
<property name="javax.persistence.jdbc.url" value="jdbc:derby://localhost:1527/testDB;create=true"/>
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/>
</properties>
</persistence-unit>
</persistence>
объект Customer
package com.kuba.crud.model;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
@Entity
@Table(name = "CUSTOMERS")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Customer.findAll", query = "SELECT c FROM Customer c"),
@NamedQuery(name = "Customer.findById", query = "SELECT c FROM Customer c WHERE c.id = :id"),
@NamedQuery(name = "Customer.findByFirstname", query = "SELECT c FROM Customer c WHERE c.firstname = :firstname"),
@NamedQuery(name = "Customer.findByLastname", query = "SELECT c FROM Customer c WHERE c.lastname = :lastname"),
@NamedQuery(name = "Customer.findByAge", query = "SELECT c FROM Customer c WHERE c.age = :age")})
public class Customer implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@NotNull
@Column(name = "ID")
private Integer id;
@Size(max = 20)
@Column(name = "FIRSTNAME")
private String firstname;
@Size(max = 20)
@Column(name = "LASTNAME")
private String lastname;
@Column(name = "AGE")
private Integer age;
public Customer() {
}
public Customer(Integer id) {
this.id = id;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Customer)) {
return false;
}
Customer other = (Customer) object;
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "com.kuba.crud.model.Customer[ id=" + id + " first name="+firstname+" last name="+lastname+" age="+age+" ]";
}
}
CustomerResource класс
package com.kuba.crud.resources;
import com.kuba.crud.model.Customer;
import com.kuba.crud.service.CustomerService;
import java.util.List;
import javax.ejb.EJB;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("/customers")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public class CustomerResource {
@EJB(lookup = "CustomerService")
private CustomerService customerService;
public CustomerResource() {
}
@GET
public List<Customer> getCustomers() {
System.out.println("Is CustomerService emptyy? "+(customerService==null));
return customerService.getAllCustomers();
}
@GET
@Path("/{id}")
public Customer getCustomer(@PathParam("id") int id){
return customerService.getCustomer(id);
}
@POST
public void addCustomer(Customer customer){
customerService.addProfile(customer);
}
}
CustomerService класс
package com.kuba.crud.service;
import com.kuba.crud.model.Customer;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateful;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
@Stateful
public class CustomerService {
// EntityManagerFactory entityManagerFactory;
@PersistenceContext(unitName = "MyPersistenceUnit")
private EntityManager em;
public CustomerService(){
// entityManagerFactory = Persistence.createEntityManagerFactory("MyPersistenceUnit");
// em = entityManagerFactory.createEntityManager();
}
public List<Customer> getAllCustomers() {
List<Customer> customers = new ArrayList<>();
System.out.println("Is empty? "+(em==null));
Query query = em.createNamedQuery("Customer.findAll", Customer.class);
customers = query.getResultList();
return customers;
}
public Customer getCustomer(int id){
return em.find(Customer.class, id);
}
public void addProfile(Customer customer) {
em.persist(customer);
System.out.println("CustomerService: "+customer);
}
}
Tomee при запуске:
Using CATALINA_HOME: "C:\apache-tomee-plume-7.0.1"
Using CATALINA_TMPDIR: "C:\apache-tomee-plume-7.0.1\temp"
Using JRE_HOME: "C:\Program Files\Java\jdk1.8.0_102"
Using CLASSPATH: "C:\apache-tomee-plume-7.0.1\bin\bootstrap.jar;C:\apache-tomee-plume-7.0.1\bin\tomcat-juli.jar"
INFO - Default JPA Provider changed to org.eclipse.persistence.jpa.PersistenceProvider
INFO - Server version: Apache Tomcat (TomEE)/8.5.3 (7.0.1)
INFO - Server built: Jun 9 2016 11:16:29 UTC
INFO - Server number: 8.5.3.0
INFO - OS Name: Windows 8.1
INFO - OS Version: 6.3
INFO - Architecture: amd64
INFO - Java Home: C:\Program Files\Java\jdk1.8.0_102\jre
INFO - JVM Version: 1.8.0_102-b14
INFO - JVM Vendor: Oracle Corporation
INFO - CATALINA_BASE: C:\apache-tomee-plume-7.0.1
INFO - CATALINA_HOME: C:\apache-tomee-plume-7.0.1
INFO - Command line argument: -javaagent:C:\apache-tomee-plume-7.0.1\lib\openejb-javaagent.jar
INFO - Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
INFO - Command line argument: -Djava.util.logging.config.file=C:\apache-tomee-plume-7.0.1\conf\logging.properties
INFO - Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
INFO - Command line argument: -Dcatalina.base=C:\apache-tomee-plume-7.0.1
INFO - Command line argument: -Dcatalina.home=C:\apache-tomee-plume-7.0.1
INFO - Command line argument: -Djava.io.tmpdir=C:\apache-tomee-plume-7.0.1\temp
INFO - The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.8.0_102\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\idmu\common;C:\Program Files\Lenovo\Fingerprint Manager Pro\;C:\Program Files (x86)\Calibre2\;C:\Program Files\MATLAB\MATLAB Production Server\R2015a\runtime\win64;C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin;C:\Program Files\MATLAB\MATLAB Production Server\R2015a\polyspace\bin;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\apache-maven-3.3.9\bin;C:\Program Files\db-derby-10.12.1.1-bin\bin;C:\Java\tomcat-native-1.2.8-win32-src;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;.
INFO - Initializing ProtocolHandler ["http-nio-8080"]
INFO - Using a shared selector for servlet write/read
INFO - Initializing ProtocolHandler ["ajp-nio-8009"]
INFO - Using a shared selector for servlet write/read
INFO - Using 'openejb.jdbc.datasource-creator=org.apache.tomee.jdbc.TomEEDataSourceCreator'
INFO - ********************************************************************************
INFO - OpenEJB http://tomee.apache.org/
INFO - Startup: Wed Sep 07 13:11:16 CEST 2016
INFO - Copyright 1999-2016 (C) Apache OpenEJB Project, All Rights Reserved.
INFO - Version: 7.0.1
INFO - Build date: 20160623
INFO - Build time: 12:04
INFO - ********************************************************************************
INFO - openejb.home = C:\apache-tomee-plume-7.0.1
INFO - openejb.base = C:\apache-tomee-plume-7.0.1
INFO - Created new singletonService [email protected]
INFO - Succeeded in installing singleton service
INFO - TomEE configuration file is 'C:\apache-tomee-plume-7.0.1\conf\tomee.xml'
INFO - Configuring Service(id=Tomcat Security Service, type=SecurityService, provider-id=Tomcat Security Service)
INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
INFO - Using 'openejb.deployments.classpath=false'
INFO - Creating TransactionManager(id=Default Transaction Manager)
INFO - Creating SecurityService(id=Tomcat Security Service)
INFO - Creating ServerService(id=cxf)
INFO - Creating ServerService(id=cxf-rs)
INFO - ** Bound Services **
INFO - NAME IP PORT
INFO - -------
INFO - Ready!
INFO - Initialization processed in 2332 ms
INFO - Importing a Tomcat Resource with id 'UserDatabase' of type 'org.apache.catalina.UserDatabase'.
INFO - Creating Resource(id=UserDatabase)
INFO - Starting service Catalina
INFO - Starting Servlet Engine: Apache Tomcat (TomEE)/8.5.3 (7.0.1)
INFO - Deploying configuration descriptor C:\apache-tomee-plume-7.0.1\conf\Catalina\localhost\Crud.xml
INFO - ------------------------- localhost -> /Crud
INFO - Configuring enterprise application: C:\Users\T440s\Documents\NetBeansProjects\Crud\target\Crud
INFO - Auto-deploying ejb CustomerService: EjbDeployment(deployment-id=CustomerService)
INFO - Configuring Service(id=Crud/localDB, type=Resource, provider-id=Default JDBC Database)
INFO - Creating Resource(id=Crud/localDB)
INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
INFO - Auto-creating a container for bean Crud.Comp911887475: Container(type=MANAGED, id=Default Managed Container)
INFO - Creating Container(id=Default Managed Container)
INFO - Using directory C:\apache-tomee-plume-7.0.1\temp for stateful session passivation
INFO - Auto-linking resource-ref 'openejb/Resource/Crud/localDB' in bean Crud.Comp911887475 to Resource(id=Crud/localDB)
INFO - Auto-linking resource-ref 'openejb/Resource/localDB' in bean Crud.Comp911887475 to Resource(id=Crud/localDB)
INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
INFO - Auto-creating a container for bean CustomerService: Container(type=STATEFUL, id=Default Stateful Container)
INFO - Creating Container(id=Default Stateful Container)
INFO - Using directory C:\apache-tomee-plume-7.0.1\temp for stateful session passivation
INFO - Auto-linking resource-ref 'openejb/Resource/Crud/localDB' in bean CustomerService to Resource(id=Crud/localDB)
INFO - Auto-linking resource-ref 'openejb/Resource/localDB' in bean CustomerService to Resource(id=Crud/localDB)
INFO - Configuring PersistenceUnit(name=MyPersistenceUnit, provider=org.eclipse.persistence.jpa.PersistenceProvider)
INFO - Auto-creating a Resource with id 'Crud/localDBNonJta' of type 'DataSource for 'MyPersistenceUnit'.
INFO - Configuring Service(id=Crud/localDBNonJta, type=Resource, provider-id=Crud/localDB)
INFO - Creating Resource(id=Crud/localDBNonJta)
INFO - Adjusting PersistenceUnit MyPersistenceUnit <jta-data-source> to Resource ID 'Crud/localDB' from 'localDB'
INFO - Adjusting PersistenceUnit MyPersistenceUnit <non-jta-data-source> to Resource ID 'Crud/localDBNonJta' from 'null'
INFO - Enterprise application "C:\Users\T440s\Documents\NetBeansProjects\Crud\target\Crud" loaded.
INFO - Assembling app: C:\Users\T440s\Documents\NetBeansProjects\Crud\target\Crud
INFO - PersistenceUnit(name=MyPersistenceUnit, provider=org.eclipse.persistence.jpa.PersistenceProvider) - provider time 1391ms
INFO - Jndi(name=CustomerServiceLocalBean) --> Ejb(deployment-id=CustomerService)
INFO - Jndi(name=global/Crud/CustomerService!com.kuba.crud.service.CustomerService) --> Ejb(deployment-id=CustomerService)
INFO - Jndi(name=global/Crud/CustomerService) --> Ejb(deployment-id=CustomerService)
INFO - Existing thread singleton service in SystemInstance(): [email protected]
INFO - OpenWebBeans Container is starting...
INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
INFO - Adding OpenWebBeansPlugin : [OpenWebBeansJsfPlugin]
INFO - Using annotated mode for file:/C:/Users/T440s/Documents/NetBeansProjects/Crud/target/Crud/WEB-INF/classes/ looking all classes to find CDI beans, maybe think to add a beans.xml if not there or add the jar to exclusions.list
INFO - All injection points were validated successfully.
INFO - OpenWebBeans Container has started, it took 344 ms.
INFO - Created Ejb(deployment-id=CustomerService, ejb-name=CustomerService, container=Default Stateful Container)
INFO - Started Ejb(deployment-id=CustomerService, ejb-name=CustomerService, container=Default Stateful Container)
INFO - using context file C:\Users\T440s\Documents\NetBeansProjects\Crud\target\Crud\META-INF\context.xml
INFO - Deployed Application(path=C:\Users\T440s\Documents\NetBeansProjects\Crud\target\Crud)
INFO - At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
INFO - Using readers:
INFO - [email protected]
INFO - [email protected]
INFO - [email protected]
INFO - [email protected]
INFO - [email protected]
INFO - org[email protected]1645bc65
INFO - o[email protected]26b1fe87
INFO - [email protected]
INFO - [email protected]
INFO - [email protected]
INFO - Using writers:
INFO - [email protected]
INFO - [email protected]
INFO - [email protected]
INFO - [email protected]
INFO - [email protected]
INFO - [email protected]
INFO - [email protected]
INFO - org[email protected]1645bc65
INFO - o[email protected]26b1fe87
INFO - [email protected]
INFO - [email protected]
INFO - Using exception mappers:
INFO - [email protected]
INFO - [email protected]
INFO - [email protected]b6
INFO - REST Application: http://localhost:8080/Crud/ -> [email protected]
INFO - Service URI: http://localhost:8080/Crud/customers -> Pojo com.kuba.crud.resources.CustomerResource
INFO - GET http://localhost:8080/Crud/customers/ -> List<Customer> getCustomers()
INFO - GET http://localhost:8080/Crud/customers/{id} -> Customer getCustomer(int)
INFO - POST http://localhost:8080/Crud/customers/ -> void addCustomer(Customer)
INFO - Deployment of configuration descriptor C:\apache-tomee-plume-7.0.1\conf\Catalina\localhost\Crud.xml has finished in 5,938 ms
INFO - Deploying web application directory C:\apache-tomee-plume-7.0.1\webapps\docs
INFO - ------------------------- localhost -> /docs
INFO - Configuring enterprise application: C:\apache-tomee-plume-7.0.1\webapps\docs
INFO - Enterprise application "C:\apache-tomee-plume-7.0.1\webapps\docs" loaded.
INFO - Assembling app: C:\apache-tomee-plume-7.0.1\webapps\docs
INFO - Deployed Application(path=C:\apache-tomee-plume-7.0.1\webapps\docs)
INFO - At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
INFO - Deployment of web application directory C:\apache-tomee-plume-7.0.1\webapps\docs has finished in 187 ms
INFO - Deploying web application directory C:\apache-tomee-plume-7.0.1\webapps\host-manager
INFO - ------------------------- localhost -> /host-manager
INFO - Configuring enterprise application: C:\apache-tomee-plume-7.0.1\webapps\host-manager
INFO - Enterprise application "C:\apache-tomee-plume-7.0.1\webapps\host-manager" loaded.
INFO - Assembling app: C:\apache-tomee-plume-7.0.1\webapps\host-manager
INFO - using context file C:\apache-tomee-plume-7.0.1\webapps\host-manager\META-INF\context.xml
INFO - Deployed Application(path=C:\apache-tomee-plume-7.0.1\webapps\host-manager)
INFO - At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
INFO - Deployment of web application directory C:\apache-tomee-plume-7.0.1\webapps\host-manager has finished in 203 ms
INFO - Deploying web application directory C:\apache-tomee-plume-7.0.1\webapps\manager
INFO - ------------------------- localhost -> /manager
INFO - Configuring enterprise application: C:\apache-tomee-plume-7.0.1\webapps\manager
INFO - Enterprise application "C:\apache-tomee-plume-7.0.1\webapps\manager" loaded.
INFO - Assembling app: C:\apache-tomee-plume-7.0.1\webapps\manager
INFO - using context file C:\apache-tomee-plume-7.0.1\webapps\manager\META-INF\context.xml
INFO - Deployed Application(path=C:\apache-tomee-plume-7.0.1\webapps\manager)
INFO - At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
INFO - Deployment of web application directory C:\apache-tomee-plume-7.0.1\webapps\manager has finished in 172 ms
INFO - Deploying web application directory C:\apache-tomee-plume-7.0.1\webapps\ROOT
INFO - ------------------------- localhost ->/
INFO - Configuring enterprise application: C:\apache-tomee-plume-7.0.1\webapps\ROOT
INFO - Enterprise application "C:\apache-tomee-plume-7.0.1\webapps\ROOT" loaded.
INFO - Assembling app: C:\apache-tomee-plume-7.0.1\webapps\ROOT
INFO - Deployed Application(path=C:\apache-tomee-plume-7.0.1\webapps\ROOT)
INFO - At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
INFO - Deployment of web application directory C:\apache-tomee-plume-7.0.1\webapps\ROOT has finished in 156 ms
INFO - Starting ProtocolHandler [http-nio-8080]
INFO - Starting ProtocolHandler [ajp-nio-8009]
INFO - Server startup in 6750 ms
стека Ошибка:
07-Sep-2016 13:17:05.337 SEVERE [http-nio-8080-exec-7] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [Jersey Web Application] in context with path [/Crud] threw exception [java.lang.NullPointerException] with root cause
java.lang.NullPointerException
at com.kuba.crud.resources.CustomerResource.getCustomers(CustomerResource.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:205)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.tomee.webservices.CXFJAXRSFilter.doFilter(CXFJAXRSFilter.java:83)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.openejb.server.httpd.EEFilter.doFilter(EEFilter.java:65)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)
at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1110)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1425)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Вы читали [ информация в] (http://tomee.apache.org/common-datasource-configurations.html) о том, как правильно настроить источник данных? – ujulu
Да, я прочитал это. Я использую org.apache.derby.jdbc.ClientDriver вместо EmbeddedDriver. Я запускаю Derby внутри Netbeans. –
CustomerService кажется прекрасным, но CustomerResource отображается в журналах «Pojo com.kuba.crud.resources.CustomerResource». Я не совсем понимаю, что генерирует оператор, но у pojos обычно нет свойств, инъецированных контейнером. – Chris