I get mentioned error when I click to add To Cart button which takes place in my .xhtml file as follow;  &lt;h:commandButton value="Add to CART" action="#{product.addToCart()}"&gt;           &lt;f:ajax execute="@form" render=":cartSize" /&gt; &lt;/h:commandButton&gt;   And there here is my bean for addToCart button  package WEB;  import ejb.operations; import entities.Products; import java.io.IOException; import java.io.Serializable; import javax.ejb.EJB; import javax.inject.Named; import javax.enterprise.context.RequestScoped; import javax.faces.bean.ManagedProperty; import javax.faces.context.FacesContext;  /**  *  * @author fet  */ @Named(value = "product") @RequestScoped  public class product  implements Serializable {      @EJB     private operations operations;      @ManagedProperty(value="#(cart)")     cart myCart;      public cart getMyCart() {         return myCart;     }      public void setMyCart(cart myCart) {         this.myCart = myCart;     }       public product() {     }       public String getQuery() {          return FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("query");       }      public void checkIfQueryExists() throws IOException{      if(operations.checkIfQueryExists(getQuery())==0){        FacesContext.getCurrentInstance().getExternalContext().redirect("error.xhtml");      }   }       public Products getProduct(){          return operations.returnProduct(getQuery());       }       public void addToCart(){           String query = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("query");          myCart.add(operations.returnProduct(query));     } }   Fınally my EJB is;  package ejb;  import entities.Products; import java.util.List; import javax.ejb.Stateless; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext;   /**  *  * @author fet  */ @Stateless public class operations {      @PersistenceContext(unitName = "registerPU")     private EntityManager em;       public List&lt;Products&gt; retrieveProducts() {          return  em.createQuery("SELECT p FROM Products p").getResultList();     }       public int checkIfQueryExists(String query){         List&lt;Products&gt; products= em.createQuery("SELECT p FROM Products p WHERE p.productName = :productName").setParameter("productName", query).getResultList();          return products.size();                   }      public Products returnProduct(String query){          Products product = (Products)em.createQuery("SELECT p FROM Products p WHERE p.productName = :productName").setParameter("productName", query).getSingleResult();          return product;     } }   I dont know why ı am facing with this. do you have any ideas? Thanks!!
What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them?  What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?
Is a passport needed when flying within Mexico as a U.S permanent resident? Reducibility of polynomials modulo p How does a half-life work? Carbon-14 has a half-life of 5,730 years.  That means that after 5,730 years, half of that sample decays.  After another 5,730 years, a quarter of the original sample decays (and the cycle goes on and on, and one could use virtually any radioactive isotope).  Why is this so?  Logically, shouldn't it take 2,865 years for the quarter to decay, rather than 5,730? Prove from first princibles $\frac{x^2-4}{x-4} \rightarrow -5$ as $x \rightarrow 3$ How can the petrification from the Flesh to Stone spell be removed? Why is saltatory conduction in myelinated axons faster than continuous conduction in unmyelinated axons? How does spacing apart sodium and potassium channels allow the action potential to travel faster down the axon? This is the reason always cited for saltatory conduction and myelination, but my mental model of conduction tells me that the density of ion gates along the axon should not affect the speed of the AP.   To illustrate, consider a myelinated axon. A wave of Na$^+$ from action potential site 1, a node of Ranvier, rushes into and quickly diffuses down the axon. (It travels in both directions, but backwards is still in the refractory period.) It diffuses through the myelinated region, its concentration always diminishing. Before it attenuates too much, however, it happens upon node of Ranvier 2, where it triggers another action potential. A new wave of Na$^+$ rushes in and the cycle repeats. This should be plain so far.  Now imagine that there is actually a node of Ranvier halfway between node 1 and 2, called node 1.5. The wave of Na$^+$, on its way to node 2, happens to trigger an action potential at node 1.5, from which a wave of Na$^+$ pours in and either boosts the original wave or replaces it by taking its momentum. Now the reinforced wave proceeds to node 2 and triggers it just as soon as, perhaps even sooner than, if node 1.5 had not existed. Repeatedly insert nodes at higher densities until the situation is simply lack of myelination, and we conclude that unmyelinated axons can transmit an action-potential-triggering wave of Na+ as fast as or faster than a myelinated one.  In short, my point of confusion is this: I cannot see how a higher density of gated channels can possibly slow down the wavefront of Na+ that triggers action potentials. If anything, the additional influxes of Na+ should speed up the all-important wavefront, assuming that new waves really "either boost the original wave or replace it by taking its momentum", and also assuming that the wavefront of Na$^+$ is really all-important for signal transmission, and also assuming that the mere presence of (voltage?) gated ion channels in the membrane does not significantly retard the wavefront.  But the usual explanation for why saltatory conduction is faster than continuous conduction (a fact I hope is empirically and unambiguously established) relies on the putative slowing effect of ion channels on the signal fore. Please explain this effect in more detail, if it is not a misconception. In "The Matrix Revolutions" How Does Neo Stop the Machine Weapons in the Real World? How to make itemize/enumerate/description environment robust to missing \item elements? Is there any way to make LaTeX tolerate empty itemize/enumerate (i.e. no \item)?  Specifically, I would welcome any package/elegant hack that would gracefully "cancel" a list if no elements are found (instead of firing up a Latex Error).  Before jumping to the obvious answer (which I expect would be something along the lines of "don't use itemize if you don't have items to put in" ;)) please consider my use-case:   I want to format remotely stored elements (say, bibliographic items), which I can only access as an XML file.  &lt;elems&gt;   &lt;bibelem&gt;&lt;title&gt;Cool result 1&lt;/title&gt;&lt;author&gt;joe&lt;/author&gt;&lt;/bibelem&gt;   &lt;bibelem&gt;&lt;title&gt;Cool result 2&lt;/title&gt;&lt;author&gt;jim&lt;/author&gt;&lt;/bibelem&gt; &lt;/elems&gt;  I have a python script that downloads/parses the XML and outputs its content in a file bib.tex as a list of Latex macros-decorated data  \BibElem{Cool result 1}{joe} \BibElem{Cool result 2}{jim}  Now, I want to grant the end-user complete control over the styling of her/his produced document, so the intended usage within Latex is something like  \documentclass{article} \begin{document}   \newcommand{\BibElem}[2]{\item {\em #1} by {#2}}   \begin{itemize}     \input{bib.tex}   \end{itemize} \end{document}    The rationale behind this design choice is that the user should be restricted as little as possible in her/his styling choices. For instance, the user may either want to display the bibelems within a list as shown in the example, or may prefer a fancy-formatted tabular. On the other hand, the user should design the latex document once, and should be able to run it regardless of the amount of data produced by the source.  Therefore, the python script cannot make any assumption regarding the context in which its latex product will be included, and it should be up to the user to deal with empty bibliographies, i.e. with empty lists. How could one possibly do that?  Update: Werner proposed a nice solution that redefines the list environment to make Latex oblivious of the fact he is currently in a list. However, this only seems to work if the empty list is the last list in the document, as revealed by the following mwa:    \documentclass{article} \makeatletter \newenvironment{myitemize}   {\itemize}   {\@newlistfalse\enditemize} \makeatother \begin{document}   % Empty Itemize   \begin{myitemize}   \end{myitemize}   % Next non-nested itemize environment (can be itemize/enumerate/description)    \begin{myitemize}     \item Arghh!   \end{myitemize} \end{document} How long can cooked food be safely stored at room/warm temperature? How do I customize the context menu in Nautilus? How can I show that "A center of a free group that is non-cyclic is trivial" ? Vandermonde identity corollary $\sum_{v=0}^{n}\frac{(2n)!}{(v!)^2(n-v)!^2}={2n \choose n}^2$ I am trying to prove this identity:  $$\sum_{v=0}^{n}\frac{(2n)!}{(v!)^2(n-v)!^2}={2n \choose n}^2$$ I think this identity (corollary of Vandermonde identity): $${n\choose 0}^2+{n\choose 1}^2+{n\choose 2}^2+\cdots+{n\choose n}^2={2n \choose n}$$ is applicable for solving it. Please give me some hints. thank you I am planning on doing a fresh install of Ubuntu and want to know what is the correct way to install ATI Catalyst Video Driver?      There are multiple valid answers for this question spanning over several versions of Ubuntu. For your convenience an index of each below: Is there any lower or upper limit on the energy of a photon? i.e. does the mathematical framework we currently use to study photons blow up when a photon surpasses a certain upper limit of energy? (or the same on the opposite side?)  My thoughts: If I let the energy of a photon tend to infinity, its wavelength would be tending to zero, and since it is thought that we cannot really distinguish things when they are on the scale of a Planck Length, would the photon have its maximum energy when its wavelength is equal to the Planck length? (Feel free to correct me, I feel I might not be.) and for the opposite end of the spectrum a photon with the least energy would have zero wavelength, implying no photon, which is a trivial case. Not sure how to make tables, but:  For a binary operation $*$, and set $\{e,a,b,c\}$, in the Cayley table, $a*a$ can be filled with either the identity or an element different from both $e$ and $a$. If in the table the place for $a*a$ is filled with $e$, then the rest of the table can be filled out in two different ways.  What are the two different ways?  Thanks I was writing test classes for my apex Rest Service that I had built for an Ipad app.  I noted some very interesting things while experimenting. Before doing anything, I just did a google search and found an interesting blog post by Jeff.    @RestResource(urlMapping='/v.9/member/*/results/*')  global with sharing class MemberRestSvc {  @HttpGet  global static ReturnClass doGet() {  String[] uriKeys = RestContext.request.requestURI.split('/'); // get the member name from the uri String memberName = uriKeys.get(uriKeys.size()-3);  // do awesome programming stuff here &amp; catch any exceptions try {    List&lt;Contact&gt; contacts = [Select Id From Contact where member_name__c = :memberName];   return new ReturnClass('true', 'Query executed successfully.', contacts);  } catch (Exception e) {   return new ReturnClass('false', e.getMessage(), null); }   }   global class ReturnClass {  global String success; global String message; global List&lt;Contact&gt; records;    global ReturnClass(String success, String message, List&lt;Contact&gt; records) {   this.success = success;   this.message = message;   this.records = records;  }  }  }   And here is the test class  @isTest private class Test_MemberRestSvc {  static { // setup test data   }  static testMethod void testDoGet() {  RestRequest req = new RestRequest();  RestResponse res = new RestResponse();  req.requestURI = 'https://cs9.salesforce.com/services/apexrest/v.9/member/me/results/today';   req.httpMethod = 'GET'; RestContext.request = req; RestContext.response = res;  MemberRestSvc.ReturnClass results = MemberRestSvc.doGet();  System.assertEquals('true', results.success); System.assertEquals(10, results.records.size()); System.assertEquals('Query executed successfully.', results.message);  }  }   I just commented a few lines and ran and it. I still achieved enough test coverage so my question is why do I need to simply instantiate the Rest request and response objects since I am directly calling the class?    @isTest   private class Test_MemberRestSvc {    static {     // setup test data     }  static testMethod void testDoGet() {  /*RestRequest req = new RestRequest();  RestResponse res = new RestResponse();  req.requestURI =    'https://cs9.salesforce.com/services/apexrest/v.9/member/me/results/today';   req.httpMethod = 'GET'; RestContext.request = req; RestContext.response = res; */Commented the code meant for REST apex intialization and merely calling the method!!  MemberRestSvc.ReturnClass results = MemberRestSvc.doGet();  System.assertEquals('true', results.success); System.assertEquals(10, results.records.size()); System.assertEquals('Query executed successfully.', results.message);  }  }   Can someone explain this behavior? Also what are the best practices for writing Test classes for apex Rest services? How to Disable new terms (free tagging) with Taxonomies? I have a "term reference" field, in a form that uses an auto-complete widget. I want to limit user input to terms in the vocabulary only, and output a message when a user tries to enter a non existing term.  I found the  module. However this does not work with forms that contain a field collection or a field group.  There is also a contributed patch . But I was wondering whether there was a simpler/cleaner solution like a module or maybe I missed an already existing way of doing it with latest drupal and taxonomy versions. Update from 14.04 to 16.04 failed with GPG error What properties do natural isomorphisms between functors preserve? If $F,G: C \rightarrow D$ are functors between regular categories and $F \Rightarrow G$ is a natural isomorphism, is it true that if $F$ is faithful {resp. full) then $G$ is full?  I believe this is true but would like some confirmation.  What about if $F$ is essentially surjective?  Is it necessarily true that $G$ is essentially surjective?  Thanks. What is a "Nested Quantifier" and why is it causing my regex to fail? I have this regex I built and tested in regex buddy.  "_ [ 0-9]{10}+ {1}+[ 0-9]{10}+ {2}+[ 0-9]{6}+ {2}[ 0-9]{2}"   When I use this in .Net C#   I receive the exception  "parsing \"_ [ 0-9]{10}+ +[ 0-9]{10}+  +[ 0-9]{6}+  [ 0-9]{2}\" - Nested quantifier +."   What does this error mean? Apparently .net doesn't like the expression.  Here is the regex buddy so u can understand my intention with the regex...  _ [ 0-9]{10}+ {1}+[ 0-9]{10}+ {2}+[ 0-9]{6}+ {2}[ 0-9]{2}  Match the characters "_ " literally «_ » Match a single character present in the list below «[ 0-9]{10}+»    Exactly 10 times «{10}+»    The character " " « »    A character in the range between "0" and "9" «0-9» Match the character " " literally « {1}+»    Exactly 1 times «{1}+» Match a single character present in the list below «[ 0-9]{10}+»    Exactly 10 times «{10}+»    The character " " « »    A character in the range between "0" and "9" «0-9» Match the character " " literally « {2}+»    Exactly 2 times «{2}+» Match a single character present in the list below «[ 0-9]{6}+»    Exactly 6 times «{6}+»    The character " " « »    A character in the range between "0" and "9" «0-9» Match the character " " literally « {2}»    Exactly 2 times «{2}» Match a single character present in the list below «[ 0-9]{2}»    Exactly 2 times «{2}»    The character " " « »    A character in the range between "0" and "9" «0-9»   In short...  What is a Nested quantifier?