Marco Marco - 7 months ago 221
Java Question

newbie's first java EE application, javax.ejb.EJBException

i'm coding my first java EE application using JPA, EJB and JSP.
until now I haven't used other than the Tomcat server and JSP pages to program some simple web application. Because I'm writing a very large project, I decided to develop a Java Enterprise Application with EJB and JPA for model (using automatic code generation for persistence) and Payara Server. I know using automated code generation isn't a good practice but i'm quadriplegic and i need something that write for me...
Unfortunately, the first operation with EJB return an error and I can't go on.

i had "javax.ejb.EJBException" running the BrandCrudController servlet.

this is server log:

Launching GlassFish on Felix platform
apr 16, 2016 8:38:12 PM com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner createBundleProvisioner
INFORMAZIONI: Create bundle provisioner class = class com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner.
Registered com.sun.enterprise.glassfish.bootstrap.osgi.EmbeddedOSGiGlassFishRuntime@4a529154 in service registry.
Cannot find the resource bundle for the name com.sun.logging.enterprise.system.container.ejb for class org.glassfish.kernel.javaee.MEJBService using org.glassfish.main.core.javaee-kernel [134]
#!## LogManagerService.postConstruct : rootFolder=D:\Servers\payara41\glassfish
#!## LogManagerService.postConstruct : templateDir=D:\Servers\payara41\glassfish\lib\templates
#!## LogManagerService.postConstruct : src=D:\Servers\payara41\glassfish\lib\templates\logging.properties
#!## LogManagerService.postConstruct : dest=D:\Servers\payara41\glassfish\domains\MyWheelDomain\config\logging.properties
Informazioni: Running Payara Version: Payara Server 4.1.1.161.1 #badassfish (build 63)
Informazioni: Server log file is using Formatter class: com.sun.enterprise.server.logging.ODLLogFormatter
Informazioni: Registered fish.payara.ha.hazelcast.store.HazelcastBackingStoreFactoryProxy for persistence-type = hazelcast in BackingStoreFactoryRegistry
Informazioni: Registered Hazelcast BackingStoreFactory with persistence-type = hazelcast
Informazioni: Registered org.glassfish.ha.store.adapter.cache.ShoalBackingStoreProxy for persistence-type = replicated in BackingStoreFactoryRegistry
Informazioni: Realm [admin-realm] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
Informazioni: Realm [file] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
Informazioni: Realm [certificate] of classtype [com.sun.enterprise.security.auth.realm.certificate.CertificateRealm] successfully created.
Informazioni: Authorization Service has successfully initialized.
Informazioni: Grizzly Framework 2.3.23 started in: 19ms - bound to [/0.0.0.0:8080]
Informazioni: Grizzly Framework 2.3.23 started in: 1ms - bound to [/0.0.0.0:8181]
Informazioni: Grizzly Framework 2.3.23 started in: 1ms - bound to [/0.0.0.0:4848]
Informazioni: Grizzly Framework 2.3.23 started in: 1ms - bound to [/0.0.0.0:3700]
Informazioni: Java security manager is disabled.
Informazioni: Entering Security Startup Service.
Informazioni: Loading policy provider com.sun.enterprise.security.provider.PolicyWrapper.
Informazioni: Security Service(s) started successfully.
Informazioni: Created HTTP listener http-listener-1 on host/port 0.0.0.0:8080
Informazioni: Created HTTP listener http-listener-2 on host/port 0.0.0.0:8181
Informazioni: Created HTTP listener admin-listener on host/port 0.0.0.0:4848
Informazioni: Created virtual server server
Informazioni: Created virtual server __asadmin
Informazioni: Setting JAAS app name glassfish-web
Informazioni: Virtual server server loaded default web module
Informazioni: HV000001: Hibernate Validator 5.1.2.Final
Informazioni: Initializing Mojarra 2.2.12 ( 20150720-0848 https://svn.java.net/svn/mojarra~svn/tags/2.2.12@14885) for context '/JsfJpaCrud'
Informazioni: Loading application [JsfJpaCrud] at [/JsfJpaCrud]
Informazioni: Loading application JsfJpaCrud done in 4.803 ms
Informazioni: Payara Server 4.1.1.161.1 #badassfish (63) startup time : Felix (2.474ms), startup services(5.178ms), total(7.652ms)
Informazioni: Cleaning JarFileFactory Cache to prevent jar FD leaks
Informazioni: Grizzly Framework 2.3.23 started in: 1ms - bound to [/0.0.0.0:7676]
Informazioni: Created HTTP listener http-listener-1 on host/port 0.0.0.0:8080
Informazioni: Grizzly Framework 2.3.23 started in: 1ms - bound to [/0.0.0.0:8080]
Informazioni: Created HTTP listener http-listener-2 on host/port 0.0.0.0:8181
Informazioni: Grizzly Framework 2.3.23 started in: 2ms - bound to [/0.0.0.0:8181]
Informazioni: JMXStartupService has started JMXConnector on JMXService URL service:jmx:rmi://XPS15:8686/jndi/rmi://XPS15:8686/jmxrmi
Grave: Cannot find the resource bundle for the name com.sun.logging.enterprise.resource.corba for class org.glassfish.enterprise.iiop.impl.GlassFishORBManager using org.glassfish.main.orb.iiop [222]
Informazioni: Listening to REST requests at context: /management/domain.
Informazioni: Registered com.sun.enterprise.glassfish.bootstrap.osgi.EmbeddedOSGiGlassFishImpl@2a63e7df as OSGi service registration: org.apache.felix.framework.ServiceRegistrationImpl@313b452d.
Informazioni: D:\Servers\payara41\glassfish\domains\MyWheelDomain\autodeploy\bundles does not exist, please create it.
Informazioni: Initializing Mojarra 2.2.12 ( 20150720-0848 https://svn.java.net/svn/mojarra~svn/tags/2.2.12@14885) for context ''
Informazioni: Loading application [__admingui] at [/]
Informazioni: Loading application __admingui done in 1.838 ms
Informazioni: model.entities.MultimediaType actually got transformed
Informazioni: model.entities.Feature actually got transformed
Informazioni: model.entities.FeatureType actually got transformed
Informazioni: model.entities.Brand actually got transformed
Informazioni: model.entities.Multimedia actually got transformed
Informazioni: model.entities.UserType actually got transformed
Informazioni: model.entities.Orthopedy actually got transformed
Informazioni: model.entities.User actually got transformed
Informazioni: model.entities.Permissions actually got transformed
Informazioni: model.entities.FrameType actually got transformed
Informazioni: model.entities.Material actually got transformed
Informazioni: model.entities.Comment actually got transformed
Informazioni: model.entities.WcFeatures actually got transformed
Informazioni: model.entities.Wheelchair actually got transformed
Informazioni: model.entities.WcFeaturesPK actually got transformed
Informazioni: EclipseLink, version: Eclipse Persistence Services - 2.6.2.qualifier
Informazioni: /file:/D:/OneDrive/Documenti/NetBeansProjects/MyWheelEE/dist/gfdeploy/MyWheelEE/MyWheelEE-ejb_jar/_MyWheelEE-ejbPU login successful
Informazioni: Portable JNDI names for EJB FrameTypeFacade: [java:global/MyWheelEE/MyWheelEE-ejb/FrameTypeFacade!model.session.localInterfaces.FrameTypeFacadeLocal, java:global/MyWheelEE/MyWheelEE-ejb/FrameTypeFacade]
Informazioni: Portable JNDI names for EJB FeatureTypeFacade: [java:global/MyWheelEE/MyWheelEE-ejb/FeatureTypeFacade, java:global/MyWheelEE/MyWheelEE-ejb/FeatureTypeFacade!model.session.localInterfaces.FeatureTypeFacadeLocal]
Informazioni: Portable JNDI names for EJB UserTypeFacade: [java:global/MyWheelEE/MyWheelEE-ejb/UserTypeFacade, java:global/MyWheelEE/MyWheelEE-ejb/UserTypeFacade!model.session.localInterfaces.UserTypeFacadeLocal]
Informazioni: Portable JNDI names for EJB BrandFacade: [java:global/MyWheelEE/MyWheelEE-ejb/BrandFacade!model.session.localInterfaces.BrandFacadeLocal, java:global/MyWheelEE/MyWheelEE-ejb/BrandFacade]
Informazioni: Portable JNDI names for EJB MultimediaFacade: [java:global/MyWheelEE/MyWheelEE-ejb/MultimediaFacade, java:global/MyWheelEE/MyWheelEE-ejb/MultimediaFacade!model.session.localInterfaces.MultimediaFacadeLocal]
Informazioni: Portable JNDI names for EJB PermissionsFacade: [java:global/MyWheelEE/MyWheelEE-ejb/PermissionsFacade!model.session.localInterfaces.PermissionsFacadeLocal, java:global/MyWheelEE/MyWheelEE-ejb/PermissionsFacade]
Informazioni: Portable JNDI names for EJB CommentFacade: [java:global/MyWheelEE/MyWheelEE-ejb/CommentFacade!model.session.localInterfaces.CommentFacadeLocal, java:global/MyWheelEE/MyWheelEE-ejb/CommentFacade]
Informazioni: Portable JNDI names for EJB WcFeaturesFacade: [java:global/MyWheelEE/MyWheelEE-ejb/WcFeaturesFacade, java:global/MyWheelEE/MyWheelEE-ejb/WcFeaturesFacade!model.session.localInterfaces.WcFeaturesFacadeLocal]
Informazioni: Portable JNDI names for EJB OrthopedyFacade: [java:global/MyWheelEE/MyWheelEE-ejb/OrthopedyFacade!model.session.localInterfaces.OrthopedyFacadeLocal, java:global/MyWheelEE/MyWheelEE-ejb/OrthopedyFacade]
Informazioni: Portable JNDI names for EJB UserFacade: [java:global/MyWheelEE/MyWheelEE-ejb/UserFacade, java:global/MyWheelEE/MyWheelEE-ejb/UserFacade!model.session.localInterfaces.UserFacadeLocal]
Informazioni: Portable JNDI names for EJB WheelchairFacade: [java:global/MyWheelEE/MyWheelEE-ejb/WheelchairFacade, java:global/MyWheelEE/MyWheelEE-ejb/WheelchairFacade!model.session.localInterfaces.WheelchairFacadeLocal]
Informazioni: Portable JNDI names for EJB MaterialFacade: [java:global/MyWheelEE/MyWheelEE-ejb/MaterialFacade, java:global/MyWheelEE/MyWheelEE-ejb/MaterialFacade!model.session.localInterfaces.MaterialFacadeLocal]
Informazioni: Portable JNDI names for EJB MultimediaTypeFacade: [java:global/MyWheelEE/MyWheelEE-ejb/MultimediaTypeFacade!model.session.localInterfaces.MultimediaTypeFacadeLocal, java:global/MyWheelEE/MyWheelEE-ejb/MultimediaTypeFacade]
Informazioni: Portable JNDI names for EJB FeatureFacade: [java:global/MyWheelEE/MyWheelEE-ejb/FeatureFacade, java:global/MyWheelEE/MyWheelEE-ejb/FeatureFacade!model.session.localInterfaces.FeatureFacadeLocal]
Informazioni: WELD-000900: 2.2.16 (Final)
Informazioni: WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
Informazioni: Loading application [MyWheelEE#MyWheelEE-war.war] at [MyWheelEE-war]
Informazioni: MyWheelEE was successfully deployed in 3.153 milliseconds.
Avvertenza: Context path from ServletContext: /MyWheelEE-war differs from path from bundle: MyWheelEE-war
Avvertenza: A system exception occurred during an invocation on EJB BrandFacade, method: public void model.session.BrandFacade.create(model.entities.Brand)
Avvertenza: javax.ejb.EJBException
at com.sun.ejb.containers.EJBContainerTransactionManager.processSystemException(EJBContainerTransactionManager.java:750)
at com.sun.ejb.containers.EJBContainerTransactionManager.completeNewTx(EJBContainerTransactionManager.java:700)
at com.sun.ejb.containers.EJBContainerTransactionManager.postInvokeTx(EJBContainerTransactionManager.java:505)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4566)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2074)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2044)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:220)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
at com.sun.proxy.$Proxy235.create(Unknown Source)
at controller.BrandCrudController.processRequest(BrandCrudController.java:40)
at controller.BrandCrudController.doGet(BrandCrudController.java:69)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: NamedQuery of name: findByName not found.
at org.eclipse.persistence.internal.jpa.QueryImpl.getDatabaseQueryInternal(QueryImpl.java:355)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createNamedQuery(EntityManagerImpl.java:1135)
at com.sun.enterprise.container.common.impl.EntityManagerWrapper.createNamedQuery(EntityManagerWrapper.java:522)
at model.session.BrandFacade.getBrandByName(BrandFacade.java:41)
at model.session.BrandFacade.create(BrandFacade.java:52)
at model.session.BrandFacade.create(BrandFacade.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1081)
at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1153)
at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4786)
at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:656)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:608)
at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:64)
at org.jboss.weld.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:52)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:608)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:140)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:369)
at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:4758)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4746)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212)
... 34 more


this is the BrandCrudController... calling .create method generate error:

package controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model.entities.Brand;
import model.exceptions.DuplicateException;
import model.session.localInterfaces.BrandFacadeLocal;

public class BrandCrudController extends HttpServlet {

@EJB
private BrandFacadeLocal brandFacade;

/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
* methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

response.setContentType("text/html;charset=UTF-8");


try {
brandFacade.create("name");
} catch (DuplicateException ex) {
Logger.getLogger(BrandCrudController.class.getName()).log(Level.SEVERE, null, ex);
} //*/


try (PrintWriter out = response.getWriter()) {
/* TODO output your page here. You may use following sample code. */
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet NewServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>brand creato </h1>");
out.println("</body>");
out.println("</html>");
}
}

// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP <code>GET</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}

/**
* Handles the HTTP <code>POST</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}

/**
* Returns a short description of the servlet.
*
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>

}


this is BrandFacade.java

package model.session;

import model.session.localInterfaces.BrandFacadeLocal;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import model.entities.Brand;
import model.exceptions.DuplicateException;


@Stateless
public class BrandFacade extends AbstractFacade<Brand> implements BrandFacadeLocal {

@PersistenceContext(unitName = "MyWheelEE-ejbPU")
private EntityManager em;

@Override
protected EntityManager getEntityManager() {
return em;
}

public BrandFacade() {
super(Brand.class);
}

@Override
public Brand getBrandByName(String name) {
Brand b = null;
try {
b = (Brand) em.createNamedQuery("findByName")
.setParameter("name", name)
.getSingleResult();
} catch (NoResultException e) {
return null;
}
return b;
}

@Override
public void create(String name) throws DuplicateException {
if (getBrandByName(name)!= null)
throw new DuplicateException("this name already exists");
Brand b =new Brand(0, name);
em.persist(b);
}

@Override
public void create(Brand brand) {
try {
create(brand.getName());
} catch (DuplicateException ex) {
Logger.getLogger(BrandFacade.class.getName()).log(Level.SEVERE, null, ex);
}
}


}


and this is Brand.java entity

package model.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
*
* @author Marco Bellaiuto
*/
@Entity
@Table(name = "brand")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Brand.findAll", query = "SELECT b FROM Brand b"),
@NamedQuery(name = "Brand.findByOid", query = "SELECT b FROM Brand b WHERE b.oid = :oid"),
@NamedQuery(name = "Brand.findByName", query = "SELECT b FROM Brand b WHERE b.name = :name")})
public class Brand implements Serializable {

private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "oid")
private Integer oid;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 15)
@Column(name = "name")
private String name;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "brandOid")
private List<Wheelchair> wheelchairList;

public Brand() {
}

public Brand(Integer oid) {
this.oid = oid;
}

public Brand(Integer oid, String name) {
this.oid = oid;
this.name = name;
}

public Integer getOid() {
return oid;
}

public void setOid(Integer oid) {
this.oid = oid;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

@XmlTransient
public List<Wheelchair> getWheelchairList() {
return wheelchairList;
}

public void setWheelchairList(List<Wheelchair> wheelchairList) {
this.wheelchairList = wheelchairList;
}

@Override
public int hashCode() {
int hash = 0;
hash += (oid != null ? oid.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 Brand)) {
return false;
}
Brand other = (Brand) object;
if ((this.oid == null && other.oid != null) || (this.oid != null && !this.oid.equals(other.oid))) {
return false;
}
return true;
}

@Override
public String toString() {
return "model.entities.Brand[ oid=" + oid + " ]";
}

}

Answer

Your error is here, in your stack trace:

Caused by: java.lang.IllegalArgumentException: NamedQuery of name: findByName not found.

You have a named query "Brand.findByName" but your code is calling "findByName" which doesn't exist. Your facade should call Brand.findByName