I'm trying to make a restfull endpoint using Jersey to an existing application.  When I try to get a list of data (Mails) from my database I get the following error:  java.lang.NullPointerException     product.security.restcontroller.MailController.allMails(MailController.java:40) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:498)     com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)     com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185)     com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)     com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)     com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)     com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)     com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)     com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)     com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542)     com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473)     com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419)     com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)     com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409)     com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558)     com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)   This is my rest controller:  package product.security.restcontroller;  import java.util.List;  import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType;  import product.security.model.Mail; import product.security.service.entityservice.MailService;  @Path("/mails") public class MailController {  private MailService mailService; private List&lt;Mail&gt; allMails;   @GET @Path("/all") public List&lt;Mail&gt; allMails() throws Exception {     allMails = mailService.findAll();     return allMails;     } }   And this is my service function  @Override     public List&lt;Mail&gt; findAll() throws Exception {         Query query = em.createQuery("SELECT e FROM Mail AS e");         return (List&lt;Mail&gt;) query.getResultList();     }   Mail service  &lt; bean id="mailService"     class="product.security.service.entityservice.MailServiceImpl"&gt; &lt;/bean&gt;   Please note that the application is already running using struts, and the service above works as expected  Update:   Seems like I have a problem with my services :  When I called mailService.findAll()  inside my controller,using Jeresey, I dont go to findAll() function, and it throws NullPointerException.  The same way, I tried to call findAll() function directly using Jeresy like below :   @GET @Path("/all")  public List&lt;Mail&gt; findAll() throws Exception {         Query query = em.createQuery("SELECT e FROM Mail AS e");         return (List&lt;Mail&gt;) query.getResultList();     }   Which did not work eather, and I got a NULL pointer Exception at the line which contains em instance. Knowing that Entity Manager is also managed by using services..  I have already separated xml file which manage the services beans, but it seems like Jeresy cannot see it somehow
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 there a NumPy function to return the first index of something in an array? I know there is a method for a Python list to return the first index of something:  &gt;&gt;&gt; l = [1, 2, 3] &gt;&gt;&gt; l.index(2) 1   Is there something like that for NumPy arrays? combining results of two select statements Where do the bipolar jets of black holes come from? We know the optimum angle for greatest horizontal displacement when launching an object with projectile motion is 45 degrees.  How to solve the angle when it is real long distance around the earth where we cannot assume that gravity is constant but is given by $F=\frac {-GMm}{r^2}$. I use differetial equation to solve it and obtain 45 degrees.   First, for the vertical distance $y$, change $v=u-gt$ to $y'=u-y''t$. Then solve it to obtain a function $y(t)$. When $y'(t)=0$ we have the time for maximum vertical distance. Then insert the value to horizontal equation.   Can anyone guide me through this problem because I am not confident with my working How can I edit this trigger to only fire once? The trigger creates a related record when a checkbox is updated. The problem is it is creating a new related record everytime the record is edited. I want to edit the trigger to only create the related record once. (When the criteria is first met). The code is below  Trigger copyEquipmentonsite on Unit_Placements_Sales__c(after insert, after update) {      List&lt;Services__c&gt; sub=new List&lt;Services__c&gt;();      for(Unit_Placements_Sales__c u : Trigger.new) {           if(u.Service_Month_is_Next_Month__c == TRUE) {                 Services__c s = new Services__c();                 s.Equipment_Onsite__c=u.ID;                 s.Equipment_Type__c=u.Equipment__c;                 s.Machine_Specific_Notes__c=u.Machine_Specific_Notes__c;                    s.Product__c=u.The_Product__c;                   s.Dell_Tag_Number__c=u.Dell_Tag_Number__c;                 s.Serial_Number__c=u.Serial_Number__c;                  s.XD_Number__c=u.XD_Number__c;                 sub.add(s);           }           if(sub.size()&gt;0)           insert sub;      } } Javascript mechanism to autoscroll to the bottom of a growing page? If $\vec{a},\vec{b},\vec{c},\vec{d}$are unit vectors, $(\vec{a}\times\vec{b}).(\vec{c}\times\vec{d})=1$ and $\vec{a}.\vec{c}=\frac{1}{2}$,then If $\vec{a},\vec{b},\vec{c},\vec{d}$are unit vectors such that $(\vec{a}\times\vec{b}).(\vec{c}\times\vec{d})=1$ and $\vec{a}.\vec{c}=\frac{1}{2}$,then $(A)\vec{a},\vec{b},\vec{c}$ are non-coplanar $(B)\vec{a},\vec{b},\vec{d}$ are non-coplanar $(C)\vec{b},\vec{d}$ are non-parallel. $(D)\vec{a},\vec{d}$ are parallel and $\vec{b}$ and $\vec{c}$ are parallel.    My Attempt: $(\vec{a}\times\vec{b}).(\vec{c}\times\vec{d})=1$ $(\vec{a}.\vec{c})(\vec{b}.\vec{d})-(\vec{a}.\vec{d})(\vec{b}.\vec{c})=1$ $\frac{1}{2}(\vec{b}.\vec{d})-(\vec{a}.\vec{d})(\vec{b}.\vec{c})=1$    Book's Solution which i did not understand: $(\vec{a}\times\vec{b}).(\vec{c}\times\vec{d})=1$ is possible only when $|\vec{a}\times\vec{b}|=|\vec{c}\times\vec{d}|=0$ and $(\vec{a}\times\vec{b})$ is parallel to $(\vec{c}\times\vec{d})$ And the correct option given is $(C)$.  I could not solve this problem after some efforts.Please help me.Thanks. Is there any software package to solve the linear regression with the objective of minimizing the L-infinity norm. I'm exploring the effects of removing the intercept in a logistic regression model.  Assume a model:  $$logit(Y = 1) = \beta_1 x + \beta_2z + 0$$  with $x$ and $z$ being categorical variables with 2 levels each and no intercept.  I understood that having no intercept with categorical predictors produce coefficients that compare the $P(Y = 1)$ in each level of the two predictor against a null case where $P(Y=1) = 0.5$ or $logit(Y=1) = 0$.  I noticed a phenomenon that can understand. Using glm() function in R if you change the order of the variable in the right hand part of the formula, the coefficients change too. But even more oddly, the coefficient of the first variable is always the same.  Here's an R demo:  y &lt;- as.factor(sample(rep(1:2), 30, T)) x &lt;- as.factor(sample(rep(1:2), 30, T)) z &lt;- as.factor(sample(rep(1:2), 30, T))  coef(glm(y ~ x + z - 1, binomial) #        x1         x2         z2  #-0.1764783  0.3260739 -0.1335192  coef(glm(y ~ z + x - 1, binomial)) #        z1         z2         x2  #-0.1764783 -0.3099976  0.5025523    As you can see the first predictors have the same coefficient while the other are different in the two models.  Here is what I expected and instead behave differently than what I though:   Since every level of the two predictors is compared to the same null case, I expected to have the same coefficients in the two models, independently from the order in which I use them. I expected to see the coefficients of every level of every predictor, instead the coefficient for the 1 level of the second predictor is not shown. I therefore assume that only the first variable is compared against the null case, while the second is compared against a reference level; but what is this level? Is it $P(Y = 1 | X = 1 \cap Z = 1)$? Reproducing one of the models WITH the intercept we get:  coef(glm(y ~ x + z - 1, binomial) #        x1         x2         z2  #-0.1764783  0.3260739 -0.1335192  coef(glm(y ~ x + z, binomial)) #(Intercept)         x2          z2  #-0.1764783   0.5025523  -0.1335192    As expected x1 become the intercept, and x2 is likely relative to x1. z1 is missing also in this case and z2 is the same as in the model without intercept.  Thus should I assume that the comparison against the null case $P(Y = 1) = 0.5$ is made only for the first variable in a formula, while the other are compared against the usual intercept? Is this behavior normal? What about the fact that the first coefficient has the same value whichever the order of the predictors in the formula? What if I want to compare all level of each predictor against the null case and have a coefficient for all levels? Or it's theoretically impossible for some reason I don't get? This may be a silly question, but I ask it still. If I have declared a shebang  #!/bin/bash    in the beginning of my_shell_script.sh, so do I always have to invoke this script using bash  [my@comp]$bash my_shell_script.sh   or can I use e.g.  [my@comp]$sh my_shell_script.sh   and my script determines the running shell using the shebang? Is it the same happening with ksh shell? I'm using AIX. How to pick the title of a remote webpage I noticed that Dolores Umbridge was born during the first Wizarding War, so it's very likely she wasn't a Death Eater then (but she is pretty evil -- who knows?).  After that Voldemort was not around in a way that could affect many people, and most wouldn't know he was planning to rise again.  During that time, and up through Voldemort's return (in Goblet of Fire), did Umbridge have any connection with the Death Eaters or with Voldemort?  Was she doing what she did on her own, or was it because of an association with Voldemort or his allies? Date Difference in php on days? What are the basic rules and idioms for operator overloading? How to calculate Area Under the Curve (AUC), or the c-statistic, by hand Can you use Skyrim Legendary Edition mods on the normal edition? I just figured out I had Skyrim in my Steam games. It's the 32-bit non-Legendary Edition Skyrim without any DLCs. Can I still use Legendary Edition mods on it? How do I test for a mob, with a given name, in a certain location? I want to testfor a sheep, by the name of Lamb, in a certain location using coordinates.  I have already tried this:  testfor @e[x=999,y=80,z=-1034,type=Sheep,name=Lamb]   But it doesn't work. I have also tried:  testfor @e[x=999,y=80,z=-1034,type=Sheep]   But it says it found a sheep whether or not there is actually a sheep in that location. I've been having an argument with a colleague about this sentence, could you please let me know which one of us is correct:     There are no shortage of applications for our product in this   space.   She is convinced that are should be replaced by is, and I think it should stand as it is. Thanks for your help! Reproducible LaTeX builds - compile to a file which always hashes to the same value When I ssh into my Ubuntu 18.04 box I get the motd  1 update could not be installed automatically   Which goes on to tell me to check the unattended-upgrades log.  The log shows no problems. How can I clear this bogus message?