I'm experimenting with OpenXava files stereotype and embedded class and finding a strange error. First of all, if I create a record and attach a bunch of files to it before saving it for the first time, everything works. If I, however, first create a record (Temple), leave everything in the embedded record (Library) blank, save (saves successfully, it says), then go back to edit it, I get the following message: "Impossible to execute Add files action: Member library.documents not found in model Temple"
I have not been able to find anything useful via google on this.
Is this something I'm doing wrong or an error in OpenXava library.
I'm using: OpenXava version 5.1.1
Tomcat that comes with it: Apache Tomcat Version 7.0.50
Oracle 11g
Here's my Temple and the inner Library class:
package org.openxava.zen.model;
import javax.persistence.*;
import org.openxava.annotations.*;
#Entity
public class Temple
{
#Id #Column(length=3) #GeneratedValue #ReadOnly
private int id;
#Version
private Integer version;
#Column(length=50)
private String name;
#Stereotype("IMAGES_GALLERY")
private String photos;
#Column
private String address;
#Embedded
private Library library;
#Embeddable
public static class Library
{
#Stereotype("FILES")
#Column(length=32)
private String documents;
public Admittance getAdmittance() {
return admittance;
}
public void setAdmittance(Admittance admittance) {
this.admittance = admittance;
}
#Column
private Admittance admittance;
public enum Admittance {MEMBERS_ONLY, COMMUNITY, EVERYONE};
public String getDocuments()
{
return documents;
}
public void setDocuments(String documents)
{
this.documents = documents;
}
}
public Library getLibrary() {
return library;
}
public void setLibrary(Library library) {
this.library = library;
}
public Integer getVersion() {
return version;
}
public void setVersion(Integer version) {
this.version = version;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhotos() {
return photos;
}
public void setPhotos(String photos) {
this.photos = photos;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
Full stacktrace:
Dec 01, 2014 4:09:46 PM org.directwebremoting.util.CommonsLoggingOutput info
INFO: Exec: Module.request()
Dec 01, 2014 4:09:46 PM org.openxava.model.impl.MapFacadeBean validate
WARNING: WARNING!: Member library.documents of Temple not validated: Type unkown (property, reference, collection)
Dec 01, 2014 4:09:46 PM org.openxava.controller.ModuleManager manageRegularException
SEVERE: Member library.documents not found in model Temple
org.openxava.util.XavaException: Member library.documents not found in model Temple
at org.openxava.model.impl.MapFacadeBean.convertSubmapsInObject(MapFacadeBean.java:1675)
at org.openxava.model.impl.MapFacadeBean.setValues(MapFacadeBean.java:1337)
at org.openxava.model.impl.MapFacadeBean.setValues(MapFacadeBean.java:198)
at org.openxava.model.MapFacade.setValues(MapFacade.java:635)
at org.openxava.actions.AddFileToFilesetAction.execute(AddFileToFilesetAction.java:27)
at org.openxava.controller.ModuleManager.executeAction(ModuleManager.java:493)
at org.openxava.controller.ModuleManager.executeAction(ModuleManager.java:401)
at org.openxava.controller.ModuleManager.execute(ModuleManager.java:358)
at org.apache.jsp.xava.execute_jsp._jspService(execute_jsp.java:196)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:605)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:544)
at org.openxava.web.servlets.Servlets.getURIAsStream(Servlets.java:66)
at org.openxava.web.dwr.Module.getURIAsStream(Module.java:205)
at org.openxava.web.dwr.Module.request(Module.java:64)
at sun.reflect.GeneratedMethodAccessor41.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.directwebremoting.impl.ExecuteAjaxFilter.doFilter(ExecuteAjaxFilter.java:34)
at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:428)
at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:431)
at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:283)
at org.directwebremoting.servlet.PlainCallHandler.handle(PlainCallHandler.java:52)
at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:101)
at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:146)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:409)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1044)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
This issue is addressed in OpenXava forums:
https://sourceforge.net/p/openxava/discussion/419690/thread/fde016f3/
Related
For some reason, the following code is not working, and I do not understand why. My current, and quite hand-wavy, belief from fussing around with several slight variations is that because the bean is being created before there is an ExternalContext its causing the exception. However, the ExternalContext should exist at this point, or so I believe.
I have a few ideas for work arounds, such as a MessageProvider class instantiated in LoginBean and sent to the MessagesBean for later use, but I would much prefer to have a session bean as close to the format below instead of having it act as a wrapper. An explanation of why this fails, as well as a correction if possible would be greatly appreciated.
Below is the two classes that are of main concern:
LoginBean
#Named( value = "loginBean")
#RequestScoped
public class LoginBean {
private static final Logger LOG = Logger.getLogger(LoginBean.class.getName());
#Inject
private MessagesBean messagesBean;
#Inject
private LoginFormBean loginFormBean;
#Inject
private PersonBean personBean;
#Inject
private PersonFacade personFacade;
#NotNull
private String username;
#NotNull
private String password;
public LoginBean() {
}
/**
* Get the value of username
*
* #return the value of username
*/
public String getUsername() {
return username;
}
/**
* Set the value of username
*
* #param username new value of username
*/
public void setUsername(String username) {
this.username = username;
}
/**
* Get the value of password
*
* #return the value of password
*/
public String getPassword() {
return password;
}
/**
* Set the value of password
*
* #param password new value of password
*/
public void setPassword(String password) {
this.password = password;
}
public String login() {
Person person = personFacade.find(username);
if(person != null && person.getPasswordHash().equals(password)) {
personBean.setPerson(person);
return "success";
}
else {
messagesBean.setMessage(
loginFormBean.getUsernameInput().getClientId(),
"login.failed");
return "failure";
}
}
public String logout() {
return null;
}
}
MessagesBean
#Named(value = "messagesBean")
#SessionScoped
public class MessagesBean implements Serializable {
private static final long serialVersionUID = 1L;
private FacesContext facesContext;
private Locale locale;
private ResourceBundle messageBundle;
/**
* Creates a new instance of MessagesBean
*/
public MessagesBean() {
}
#PostConstruct
private void init()
{
facesContext = FacesContext.getCurrentInstance();
locale = facesContext.getExternalContext().getRequestLocale();
messageBundle =
ResourceBundle.getBundle(
facesContext.getApplication().getMessageBundle(),
locale);
}
public void setMessage(String clientId, String messageKey)
{
FacesMessage facesMessage =
new FacesMessage(messageBundle.getString(messageKey));
facesContext.addMessage(clientId, facesMessage);
}
}
Below is a stack trace of the error that occurs with the above classes:
javax.faces.el.EvaluationException: org.jboss.weld.exceptions.WeldException: WELD-000049: Unable to invoke private void com.healthdataviews.healthdataviewstrial.support.MessagesBean.init() on com.healthdataviews.healthdataviewstrial.support.MessagesBean#1126aa67
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:101)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)
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: org.jboss.weld.exceptions.WeldException: WELD-000049: Unable to invoke private void com.healthdataviews.healthdataviewstrial.support.MessagesBean.init() on com.healthdataviews.healthdataviewstrial.support.MessagesBean#1126aa67
at org.jboss.weld.injection.producer.DefaultLifecycleCallbackInvoker.invokeMethods(DefaultLifecycleCallbackInvoker.java:100)
at org.jboss.weld.injection.producer.DefaultLifecycleCallbackInvoker.postConstruct(DefaultLifecycleCallbackInvoker.java:81)
at org.jboss.weld.injection.producer.BasicInjectionTarget.postConstruct(BasicInjectionTarget.java:126)
at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:162)
at org.jboss.weld.util.bean.IsolatedForwardingBean.create(IsolatedForwardingBean.java:45)
at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:96)
at org.jboss.weld.context.PassivatingContextWrapper$AbstractPassivatingContextWrapper.get(PassivatingContextWrapper.java:76)
at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:101)
at org.jboss.weld.bean.ContextualInstanceStrategy$CachingContextualInstanceStrategy.get(ContextualInstanceStrategy.java:178)
at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:99)
at org.jboss.weld.bean.proxy.ProxyMethodHandler.getInstance(ProxyMethodHandler.java:125)
at com.healthdataviews.healthdataviewstrial.support.MessagesBean$Proxy$_$$_WeldClientProxy.setMessage(Unknown Source)
at com.healthdataviews.healthdataviewstrial.controller.ejb.LoginBean.login(LoginBean.java:100)
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:497)
at com.sun.el.parser.AstValue.invoke(AstValue.java:289)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
... 36 more
Update
I discovered exactly where the error was occurring. When I call getMessageBundle, I am getting a NullPointerException which is causing ResourceBundle.getBundle() to search for a null bundle which is causing it to crash on #PostConstruct init(). New question: How do I link my Messages.properties to the getMessageBundle() call, or should I just translate it to getResourceBundle("bundle")?
Update
I got it working by setting the <message-bundle> in my faces-config.xml. Is there any way to include it without loading in each .xhtml file other than declaring it a <resource-bundle> as well?
Kindly check not equal to null Statement for messageBundle in #Postconstruct Method.
i.e.,
if(messageBundle != null)
messageBundle = ResourceBundle.getBundle(
facesContext.getApplication().getMessageBundle(),
locale);
This question already has answers here:
javax.el.PropertyNotFoundException: Property 'foo' not found on type com.example.Bean
(6 answers)
Closed 6 years ago.
My problem is the following. I've a list which i s well created, but I can't manage to display it on my web page.
Here is the pojo :
package trainforjava.domain;
public class Question {
public int id;
public String askedQuestion;
public String proposal;
public Question() {
super();
}
public Question(int id, String askedQuestion, String proposal) {
super();
this.id = id;
this.askedQuestion = askedQuestion;
this.proposal = proposal;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public void setAskedQuestion(String askedQuestion) {
this.askedQuestion = askedQuestion;
}
public String getAskedQuestion() {
return askedQuestion;
}
public void setQuestion(String askedQuestion) {
this.askedQuestion = askedQuestion;
}
public String getProposal() {
return proposal;
}
public void setProposal(String proposal) {
this.proposal = proposal;
}
#Override
public String toString() {
return "Question [id=" + id + ", askedQuestion=" + askedQuestion + "]";
}
}
Here is the managed bean :
package trainforjava.domain;
import java.util.List;
import java.util.Map;
import javax.faces.bean.ManagedBean;
import trainforjava.util.QuestionCreator;
#ManagedBean
public class QuestionBean {
public List<String> proposals;
public List<Question> questions;
public QuestionCreator creator = new QuestionCreator();
public QuestionBean() {
System.out.println("beforecreate");
questions = creator.createQuestions();
System.out.println(questions);
// proposals = creator.createProposals(0);
}
public List<String> getProposals() {
return proposals;
}
public void setProposals(List<String> proposals) {
this.proposals = proposals;
}
public List<Question> getQuestions() {
return questions;
}
public void setQuestions(List<Question> questions) {
this.questions = questions;
}
}
Here is the pojo creating from a properties file :
package trainforjava.util;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.springframework.stereotype.Component;
import trainforjava.domain.Question;
public class QuestionCreator {
List<Question> questions =new ArrayList<Question>();
List<String> proposals = new ArrayList<String>();
public List<Question> createQuestions() {
final Properties properties = new Properties();
InputStream input = null;
System.out.println("createQuestions");
try {
input = getClass().getResourceAsStream("/questions.properties");
// load a properties file
properties.load(input);
// get the property value and print it out
for (int i = 0; i < properties.size(); i++) {
Question question = new Question();
StringBuilder sb = new StringBuilder();
sb.append("question-").append(i);
String askedQuestion = properties.getProperty(sb.toString());
question.setAskedQuestion(askedQuestion);
question.setId(i);
questions.add(question);
}
} catch (final IOException ex) {
ex.printStackTrace();
} finally {
if (input != null) {
try {
input.close();
} catch (final IOException e) {
e.printStackTrace();
}
}
}
return questions;
}
public List<String> createProposals(int key) {
final Properties properties = new Properties();
InputStream input = null;
System.out.println("createProposals");
try {
input = getClass().getResourceAsStream("/proposals.properties");
// load a properties file
properties.load(input);
for(int i =0 ; i < proposals.size(); i++){
int idQuestion = key;
System.out.println("createProposals id" + idQuestion);
StringBuilder sb = new StringBuilder();
sb.append("proposal-").append(idQuestion).append("-").append(i);
String proposal = properties.getProperty(sb.toString());
proposals.add(proposal);
System.out.println(proposals);
}
} catch (final IOException ex) {
ex.printStackTrace();
} finally {
if (input != null) {
try {
input.close();
} catch (final IOException e) {
e.printStackTrace();
}
}
}
return proposals;
}
}
The console print me the list created, which name is "questions", but also print me a stacktrace :
beforecreate
createQuestions
[Question [id=0, askedQuestion=Quelle interface est implémentée par la Classe ArrayList ?], Question [id=1, askedQuestion=Quelle interface est implémentée par la Classe HashMap ?], Question [id=2, askedQuestion=Quelle interface est implémentée par la Classe Vector ?]]
août 23, 2016 2:29:19 AM com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException
GRAVE: Error Rendering View[/index.xhtml]
javax.el.ELException: /index.xhtml: Property 'askQuestion' not found on type trainforjava.domain.Question
at com.sun.faces.facelets.compiler.TextInstruction.write(TextInstruction.java:88)
at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:302)
at com.sun.faces.renderkit.html_basic.TableRenderer.renderRow(TableRenderer.java:385)
at com.sun.faces.renderkit.html_basic.TableRenderer.encodeChildren(TableRenderer.java:161)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:890)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:890)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:458)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:134)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:521)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1096)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:674)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
août 23, 2016 2:29:19 AM com.sun.faces.context.ExceptionHandlerImpl log
1100: JSF1073 : javax.el.ELException intercepté durant le traitement de RENDER_RESPONSE 6 : UIComponent-ClientId=, Message=/index.xhtml: Property 'askQuestion' not found on type trainforjava.domain.Question
août 23, 2016 2:29:19 AM com.sun.faces.context.ExceptionHandlerImpl log
1100: /index.xhtml: Property 'askQuestion' not found on type trainforjava.domain.Question
javax.el.ELException: /index.xhtml: Property 'askQuestion' not found on type trainforjava.domain.Question
at com.sun.faces.facelets.compiler.TextInstruction.write(TextInstruction.java:88)
at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:302)
at com.sun.faces.renderkit.html_basic.TableRenderer.renderRow(TableRenderer.java:385)
at com.sun.faces.renderkit.html_basic.TableRenderer.encodeChildren(TableRenderer.java:161)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:890)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:890)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:458)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:134)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:521)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1096)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:674)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
And then, the index.xhtml which is supposed to display this list :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Test</title>
</h:head>
<h:body>
Question :
<h:form>
<h:dataTable value="#{questionBean.questions}" var="question">
<h:column>
#{question.askQuestion}
</h:column>
</h:dataTable>
</h:form>
</h:body>
</html>
Can someone help me please ?
The property name is actually askedQuestion, and not askQuestion.
I got the following error when deploying to Glassfish on Netbeans. This is the first time I am trying to CDI. I have read all the post on this issue up to no help.
Log:
Info: visiting unvisited references
Info: visiting unvisited references
Info: visiting unvisited references
Info: visiting unvisited references
Info: Enity.Test.Employee actually got transformed
Info: EclipseLink, version: Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd
Info: file:/C:/Users/Bala/Documents/NetBeansProjects/TestAppl/dist/gfdeploy/TestAppl/TestAppl-ejb_jar/_TestAppl-ejbPU login successful
Info: Portable JNDI names for EJB EmployeeEJB: [java:global/TestAppl/TestAppl-ejb/EmployeeEJB, java:global/TestAppl/TestAppl-ejb/EmployeeEJB!SessionlessEmployee.EmployeeEJB]
WARN: WELD-000411: Observer method [BackedAnnotatedMethod] public org.glassfish.jms.injection.JMSCDIExtension.processAnnotatedType(#Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using #WithAnnotations or a generic type with bounds.
WARN: WELD-000411: Observer method [BackedAnnotatedMethod] org.glassfish.sse.impl.ServerSentEventCdiExtension.processAnnotatedType(#Observes ProcessAnnotatedType<Object>, BeanManager) receives events for all annotated types. Consider restricting events using #WithAnnotations or a generic type with bounds.
WARN: WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.gf.cdi.internal.CdiComponentProvider.processAnnotatedType(#Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using #WithAnnotations or a generic type with bounds.
WARN: WELD-000411: Observer method [BackedAnnotatedMethod] public org.glassfish.jms.injection.JMSCDIExtension.processAnnotatedType(#Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using #WithAnnotations or a generic type with bounds.
WARN: WELD-000411: Observer method [BackedAnnotatedMethod] org.glassfish.sse.impl.ServerSentEventCdiExtension.processAnnotatedType(#Observes ProcessAnnotatedType<Object>, BeanManager) receives events for all annotated types. Consider restricting events using #WithAnnotations or a generic type with bounds.
WARN: WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.gf.cdi.internal.CdiComponentProvider.processAnnotatedType(#Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using #WithAnnotations or a generic type with bounds.
Severe: Exception during lifecycle processing
org.glassfish.deployment.common.DeploymentException: CDI deployment failure:WELD-001408: Unsatisfied dependencies for type Employee with qualifiers #Default
at injection point [BackedAnnotatedField] #Inject private Managedbean.Testapp.employeeController.employee
at Managedbean.Testapp.employeeController.employee(employeeController.java:0)
at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:234)
at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:328)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:496)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:356)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:356)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:189)
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:201)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
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:284)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
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:565)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type Employee with qualifiers #Default
at injection point [BackedAnnotatedField] #Inject private Managedbean.Testapp.employeeController.employee
at Managedbean.Testapp.employeeController.employee(employeeController.java:0)
at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:370)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:291)
at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:134)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:165)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:529)
at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:515)
at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:490)
at org.jboss.weld.bootstrap.WeldStartup.validateBeans(WeldStartup.java:419)
at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:90)
at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:225)
... 41 more
Severe: Exception while loading the app
Severe: Undeployment failed for context /TestAppl-war
Info: file:/C:/Users/Bala/Documents/NetBeansProjects/TestAppl/dist/gfdeploy/TestAppl/TestAppl-ejb_jar/_TestAppl-ejbPU logout successful
Severe: Exception while loading the app : CDI deployment failure:WELD-001408: Unsatisfied dependencies for type Employee with qualifiers #Default
at injection point [BackedAnnotatedField] #Inject private Managedbean.Testapp.employeeController.employee
at Managedbean.Testapp.employeeController.employee(employeeController.java:0)
org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type Employee with qualifiers #Default
at injection point [BackedAnnotatedField] #Inject private Managedbean.Testapp.employeeController.employee
at Managedbean.Testapp.employeeController.employee(employeeController.java:0)
at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:370)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:291)
at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:134)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:165)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:529)
at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:515)
at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:490)
at org.jboss.weld.bootstrap.WeldStartup.validateBeans(WeldStartup.java:419)
at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:90)
at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:225)
at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:328)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:496)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:356)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:356)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:189)
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:201)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
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:284)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
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:565)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
at java.lang.Thread.run(Thread.java:745)
My program code:
TestAppl-war
Index.xhtml
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<h:form>
<h:panelGrid columns="2" >
<h:outputLabel value="First Name : "/>
<h:inputText value="#{employeeController.employee.firstname}" />
<h:outputLabel value="Last Name : "/>
<h:inputText value="#{employeeController.employee.lastName}"/>
<h:outputLabel value="Date of Birth : "/>
<h:inputText value="#{employeeController.employee.dob}">
<f:convertDateTime pattern="dd/mm/yyyy"/>
</h:inputText>
<h:outputLabel value="Phone : "/>
<h:inputText value="#{employeeController.employee.phone}"/>
<h:outputLabel value="Email : "/>
<h:inputText value="#{employeeController.employee.email}"/>
</h:panelGrid>
<h:commandButton value="Add New Employee"
action="#{employeeController.addNewEmployee()}"/>
</h:form>
</h:body>
</html>
employeeController.java
package Managedbean.Testapp;
import Enity.Test.Employee;
import SessionlessEmployee.EmployeeEJB;
import java.io.Serializable;
import java.util.Date;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
/**
*
* #author Bala
*/
#Named(value = "employeeController")
#RequestScoped
public class employeeController implements Serializable {
private Employee employee = new Employee();
#Inject private EmployeeEJB employeeEJB;
/**
* Creates a new instance of employeeController
*/
private static final long serialVersionUID = 1L;
private String firstname;
private String middlename;
private String lastname;
private Date dob;
private String phone;
private String email;
public employeeController() {
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public void setMiddlename(String middlename) {
this.middlename = middlename;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public void setDob(Date dob) {
this.dob = dob;
}
public void setPhone(String phone) {
this.phone = phone;
}
public void setEmail(String email) {
this.email = email;
}
public void addNewEmployee() {
employee = employeeEJB.addNew(employee);
}
}
EmployeeEJB
package SessionlessEmployee;
import Enity.Test.Employee;
import java.util.List;
import javax.ejb.Stateless;
import javax.ejb.LocalBean;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
#Stateless
#LocalBean
public class EmployeeEJB {
#PersistenceContext(unitName = "TestAppl-ejbPU")
private EntityManager entityManager;
public List<Employee> findEmployees(){
TypedQuery<Employee> query = entityManager.createNamedQuery("findAllEmployees", Employee.class);
return query.getResultList();
}
public Employee addNew(Employee employee) {
entityManager.persist(employee);
return employee;
}
}
Employee
package Enity.Test;
import java.io.Serializable;
import java.util.Date;
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.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
#Entity
#Table(name = "EMPLOYEE")
#XmlRootElement
#NamedQueries({
#NamedQuery(name = "Employee.findAll", query = "SELECT e FROM Employee e"),
#NamedQuery(name = "Employee.findById", query = "SELECT e FROM Employee e WHERE e.id = :id"),
#NamedQuery(name = "Employee.findByFirstname", query = "SELECT e FROM Employee e WHERE e.firstname = :firstname"),
#NamedQuery(name = "Employee.findByMiddlename", query = "SELECT e FROM Employee e WHERE e.middlename = :middlename"),
#NamedQuery(name = "Employee.findByLastname", query = "SELECT e FROM Employee e WHERE e.lastname = :lastname"),
#NamedQuery(name = "Employee.findByDob", query = "SELECT e FROM Employee e WHERE e.dob = :dob"),
#NamedQuery(name = "Employee.findByPhone", query = "SELECT e FROM Employee e WHERE e.phone = :phone"),
#NamedQuery(name = "Employee.findByEmail", query = "SELECT e FROM Employee e WHERE e.email = :email")})
public class Employee implements Serializable {
private static final long serialVersionUID = 1L;
#Id
#Basic(optional = false)
#NotNull
#Column(name = "ID")
private Integer id;
#Size(max = 100)
#Column(name = "FIRSTNAME")
private String firstname;
#Basic(optional = false)
#NotNull
#Size(min = 1, max = 100)
#Column(name = "MIDDLENAME")
private String middlename;
#Size(max = 100)
#Column(name = "LASTNAME")
private String lastname;
#Column(name = "DOB")
#Temporal(TemporalType.DATE)
private Date dob;
// #Pattern(regexp="^\\(?(\\d{3})\\)?[- ]?(\\d{3})[- ]?(\\d{4})$", message="Invalid phone/fax format, should be as xxx-xxx-xxxx")//if the field contains phone or fax number consider using this annotation to enforce field validation
#Size(max = 10)
#Column(name = "PHONE")
private String phone;
// #Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*#(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
#Size(max = 100)
#Column(name = "EMAIL")
private String email;
public Employee() {
}
public Employee(Integer id) {
this.id = id;
}
public Employee(Integer id, String middlename) {
this.id = id;
this.middlename = middlename;
}
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 getMiddlename() {
return middlename;
}
public void setMiddlename(String middlename) {
this.middlename = middlename;
}
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public Date getDob() {
return dob;
}
public void setDob(Date dob) {
this.dob = dob;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
#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 Employee)) {
return false;
}
Employee other = (Employee) 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 "Enity.Test.Employee[ id=" + id + " ]";
}
}
Table
create table "Database".EMPLOYEE
(
ID INTEGER not null primary key,
FIRSTNAME VARCHAR(100),
MIDDLENAME VARCHAR(100) not null,
LASTNAME VARCHAR(100),
DOB DATE,
PHONE VARCHAR(10),
EMAIL VARCHAR(100)
)
beans.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
bean-discovery-mode="all">
</beans>
This is auto generated source when I deploy
Employee_.java
package Enity.Test;
import java.util.Date;
import javax.annotation.Generated;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.StaticMetamodel;
#Generated(value="EclipseLink-2.5.2.v20140319-rNA", date="2015-04-06T09:18:49")
#StaticMetamodel(Employee.class)
public class Employee_ {
public static volatile SingularAttribute<Employee, Integer> id;
public static volatile SingularAttribute<Employee, String> phone;
public static volatile SingularAttribute<Employee, String> middlename;
public static volatile SingularAttribute<Employee, String> email;
public static volatile SingularAttribute<Employee, Date> dob;
public static volatile SingularAttribute<Employee, String> lastname;
public static volatile SingularAttribute<Employee, String> firstname;
}
Any ideas?
This line of code in EmployeeController is causing the exception to be thrown
private #Inject Employee employee = new Employee();. You are trying to inject Employee but this isn't a bean which CDI can inject. If you drop the #Inject annotation it should resolve the problem.
As a side note private #Inject EmployeeEJB employeeEJB; should be annotated with #EJB rather than #Inject
I re factor and move JSF managed bean from one package to another package in Netbeans JSF application. Intermittently I get an error stating that the moved bean is not found in the previous location. I clean and build several times. Still the issue persists. I restarted the GlassFish and even the computer. I find in project including the generate sources, but I could not locate any reference to that Bean. I add the current location to the faces-config.xml, still no result.
The Previous Package is com.divudi.bean
New Package is com.divudi.bean.lab
The Error Message is
SEVERE: Exception while loading the app : com/divudi/bean/CollectingCentreController
java.lang.NoClassDefFoundError: com/divudi/bean/CollectingCentreController
at java.lang.Class.getDeclaringClass(Native Method)
at java.lang.Class.getEnclosingClass(Class.java:1107)
at java.lang.Class.getSimpleBinaryName(Class.java:1242)
at java.lang.Class.isMemberClass(Class.java:1232)
at org.jboss.weld.util.reflection.Reflections.isNonStaticInnerClass(Reflections.java:139)
at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:78)
at org.jboss.weld.bootstrap.BeanDeployer.addClasses(BeanDeployer.java:123)
at org.jboss.weld.bootstrap.BeanDeployment.createBeans(BeanDeployment.java:184)
at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:350)
at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:179)
at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:128)
at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:277)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:460)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.ClassNotFoundException: com.divudi.bean.CollectingCentreController
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1509)
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1359)
... 41 more
The Bean is (Before Adding to faces-config.xml, where annotation is used)
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.divudi.bean.lab;
import com.divudi.bean.SessionController;
import com.divudi.bean.UtilityController;
import com.divudi.data.InstitutionType;
import com.divudi.entity.Institution;
import com.divudi.facade.InstitutionFacade;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.TimeZone;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
/**
*
* #author www.divudi.com
*/
#ManagedBean
public class CollectingCentreController {
/**
* Creates a new instance of CollectingCentreController
*/
public CollectingCentreController() {
}
private static final long serialVersionUID = 1L;
#ManagedProperty(value = "#{sessionController}")
SessionController sessionController;
#EJB
private InstitutionFacade ejbFacade;
List<Institution> selectedItems;
private Institution current;
private List<Institution> items = null;
String selectText = "";
public List<Institution> getSelectedItems() {
selectedItems = getFacade().findBySQL("select c from Institution c where c.retired=false and i.institutionType = com.divudi.data.InstitutionType.CollectingCentre and upper(c.name) like '%" + getSelectText().toUpperCase() + "%' order by c.name");
return selectedItems;
}
public void prepareAdd() {
current = new Institution();
current.setInstitutionType(InstitutionType.CollectingCentre);
}
public void setSelectedItems(List<Institution> selectedItems) {
this.selectedItems = selectedItems;
}
public String getSelectText() {
return selectText;
}
private void recreateModel() {
items = null;
}
public void saveSelected() {
if (getCurrent().getId() != null && getCurrent().getId() > 0) {
getFacade().edit(current);
UtilityController.addSuccessMessage("savedOldSuccessfully");
} else {
current.setCreatedAt(Calendar.getInstance(TimeZone.getTimeZone("IST")).getTime());
current.setCreater(sessionController.getLoggedUser());
getFacade().create(current);
UtilityController.addSuccessMessage("savedNewSuccessfully");
}
recreateModel();
getItems();
}
public void setSelectText(String selectText) {
this.selectText = selectText;
}
public InstitutionFacade getEjbFacade() {
return ejbFacade;
}
public void setEjbFacade(InstitutionFacade ejbFacade) {
this.ejbFacade = ejbFacade;
}
public SessionController getSessionController() {
return sessionController;
}
public void setSessionController(SessionController sessionController) {
this.sessionController = sessionController;
}
public Institution getCurrent() {
if (current == null) {
current = new Institution();
current.setInstitutionType(InstitutionType.CollectingCentre);
}
return current;
}
public void setCurrent(Institution current) {
this.current = current;
}
public void delete() {
if (current != null) {
current.setRetired(true);
current.setRetiredAt(Calendar.getInstance(TimeZone.getTimeZone("IST")).getTime());
current.setRetirer(sessionController.getLoggedUser());
getFacade().edit(current);
UtilityController.addSuccessMessage("DeleteSuccessfull");
} else {
UtilityController.addSuccessMessage("NothingToDelete");
}
recreateModel();
getItems();
current = null;
getCurrent();
}
private InstitutionFacade getFacade() {
return ejbFacade;
}
public List<Institution> getItems() {
// items = getFacade().findAll("name", true);
String sql = "SELECT i FROM Institution i where i.retired=false and i.institutionType = com.divudi.data.InstitutionType.CollectingCentre order by i.name";
items = getEjbFacade().findBySQL(sql);
if (items == null) {
items = new ArrayList<Institution>();
}
return items;
}
}
I am using openxava 4.7.1 with MySQL. I have made all the right configurations and defined my pojos like this one for example
package com.iserve.ticketmanager;
import java.util.*;
import javax.persistence.*;
import org.openxava.annotations.*;
#Entity
public class Party {
#Id
#Required
#Column(name = "id", nullable = true)
private Integer id;
#Column(name = "name", length = 45, nullable = true)
private String name;
#Column(name = "manager", nullable = true)
private Integer manager;
#Stereotype("IMAGE")
#Column(name = "logo", nullable = true)
private String logo;
#Column(name = "active", length = 0, nullable = true)
private Boolean active;
#OneToMany
private Set<Payment> payment;
#OneToMany
private Set<User> user;
#OneToMany
private Set<Ticketsale> ticketsale;
#OneToMany
private Set<Vendorcontract> vendorcontract;
#OneToMany
private Set<Inventory> inventory;
#OneToMany
private Set<Ticketredeem> ticketredeem;
#OneToMany
private Set<Ticket> ticket;
#OneToMany
private Set<Shipment> shipment;
#OneToMany
private Set<Ticketbatch> ticketbatch;
#OneToMany
private Set<Route> route;
#OneToMany
private Set<Vehicle> vehicle;
#OneToMany
private Set<Ticketdenomination> ticketdenomination;
#OneToMany
private Set<Vendororder> vendororder;
public void setId(Integer aValue) {
id = aValue;
}
public Integer getId() {
return id;
}
public void setName(String aValue) {
name = aValue;
}
public String getName() {
return name;
}
public void setManager(Integer aValue) {
manager = aValue;
}
public Integer getManager() {
return manager;
}
public void setLogo(String aValue) {
logo = aValue;
}
public String getLogo() {
return logo;
}
public void setActive(Boolean aValue) {
active = aValue;
}
public Boolean getActive() {
return active;
}
public void setPayment(Set<Payment> aValue) {
payment = aValue;
}
public Set<Payment> getPayment() {
return payment;
}
public void setUser(Set<User> aValue) {
user = aValue;
}
public Set<User> getUser() {
return user;
}
public void setTicketsale(Set<Ticketsale> aValue) {
ticketsale = aValue;
}
public Set<Ticketsale> getTicketsale() {
return ticketsale;
}
public void setVendorcontract(Set<Vendorcontract> aValue) {
vendorcontract = aValue;
}
public Set<Vendorcontract> getVendorcontract() {
return vendorcontract;
}
public void setInventory(Set<Inventory> aValue) {
inventory = aValue;
}
public Set<Inventory> getInventory() {
return inventory;
}
public void setTicketredeem(Set<Ticketredeem> aValue) {
ticketredeem = aValue;
}
public Set<Ticketredeem> getTicketredeem() {
return ticketredeem;
}
public void setTicket(Set<Ticket> aValue) {
ticket = aValue;
}
public Set<Ticket> getTicket() {
return ticket;
}
public void setShipment(Set<Shipment> aValue) {
shipment = aValue;
}
public Set<Shipment> getShipment() {
return shipment;
}
public void setTicketbatch(Set<Ticketbatch> aValue) {
ticketbatch = aValue;
}
public Set<Ticketbatch> getTicketbatch() {
return ticketbatch;
}
public void setRoute(Set<Route> aValue) {
route = aValue;
}
public Set<Route> getRoute() {
return route;
}
public void setVehicle(Set<Vehicle> aValue) {
vehicle = aValue;
}
public Set<Vehicle> getVehicle() {
return vehicle;
}
public void setTicketdenomination(Set<Ticketdenomination> aValue) {
ticketdenomination = aValue;
}
public Set<Ticketdenomination> getTicketdenomination() {
return ticketdenomination;
}
public void setVendororder(Set<Vendororder> aValue) {
vendororder = aValue;
}
public Set<Vendororder> getVendororder() {
return vendororder;
}
}
I start the application by starting tomcat in the openxava distribution. When I try to access any module, i get error similar to this in all cases -
un 04, 2013 7:40:36 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet module threw exception
org.openxava.util.XavaException: Seems that party is not an EJB3 Entity nor transient model class
at org.openxava.annotations.parse.AnnotatedClassParser.getClassNameFor(AnnotatedClassParser.java:2415)
at org.openxava.annotations.parse.AnnotatedClassParser.parse(AnnotatedClassParser.java:66)
at org.openxava.component.ComponentParser.parseAnnotatedClass(ComponentParser.java:47)
at org.openxava.component.ComponentParser.parse(ComponentParser.java:36)
at org.openxava.component.MetaComponent.get(MetaComponent.java:60)
at org.openxava.component.MetaComponent.exists(MetaComponent.java:75)
at org.openxava.application.meta.MetaApplication.existsModel(MetaApplication.java:151)
at org.openxava.application.meta.MetaApplication.getMetaModule(MetaApplication.java:140)
at org.openxava.controller.ModuleManager.getMetaModule(ModuleManager.java:1058)
at org.openxava.controller.ModuleManager.setupModuleControllers(ModuleManager.java:244)
at org.openxava.controller.ModuleManager.setModuleName(ModuleManager.java:1031)
at org.apache.jsp.xava.module_jsp._jspService(module_jsp.java:166)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at org.openxava.web.servlets.ModuleServlet.doGet(ModuleServlet.java:24)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Thread.java:722)
What could be going on?
I suspect you're using lowercase for the first letter of the entity in the URL. Try the URL in this way:
http://localhost:8080/YourApplication/modules/Party
YourApplication and Party cases must be the correct ones.