Hello guys,

I'm working on a small web application and have encountered some problems i can't seem to handle.
When executing a query on my database I receive a NullPointException error.

It seems my queries I have made are not working properly.
It is a java ee web application using glassfish server(javadb) and primefaces.

Below is my code:
In my bean class:

public Competitie findByCompetitieId(long id) 
     {
        return em.find(Competitie.class, id);
     }
 
     public Competitie findCompetitieByNaam(String naam) 
    {
        TypedQuery<Competitie> c = em.createNamedQuery("ByCompetitieNaam", Competitie.class);
        c.setParameter("naam", naam);
        return c.getSingleResult();
    }

NamedQueries in my entity class
@NamedQueries({
    @NamedQuery(name = "AllCompetities", query = "SELECT c FROM Competitie c"),
    @NamedQuery(name = "ByCompetitieId", query = "SELECT c FROM Competitie c WHERE c.competitieId = :competitieId"),
    @NamedQuery(name = "ByCompetitieNaam", query = "SELECT c FROM Competitie c WHERE c.naam = :naam")})

this is wat I do in my controller
public void setCompetitieId(long competitieId) 
    {
        this.competitieId = competitieId;
        Competitie c = cm.findByCompetitieId(competitieId);
        ploeg.setCompetitieId(c);
    }

I have encountered the problem when using a submitted value from a dropdown wich i use then to search the record, there it gives me the following error:
javax.faces.component.UpdateModelException: javax.el.ELException: /Ploeg/NieuwePloeg.xhtml @16,106 value="#{ploegController.competitieId}": java.lang.NullPointerException
	at javax.faces.component.UIInput.updateModel(UIInput.java:853)
	at javax.faces.component.UIInput.processUpdates(UIInput.java:735)
	at javax.faces.component.UIForm.processUpdates(UIForm.java:281)
	at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1242)
	at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1242)
	at javax.faces.component.UIViewRoot.processUpdates(UIViewRoot.java:1231)
	at com.sun.faces.lifecycle.UpdateModelValuesPhase.execute(UpdateModelValuesPhase.java:78)
	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
	at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
	at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
	at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
	at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
	at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
	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: javax.el.ELException: /Ploeg/NieuwePloeg.xhtml @16,106 value="#{ploegController.competitieId}": java.lang.NullPointerException
	at com.sun.faces.facelets.el.TagValueExpression.setValue(TagValueExpression.java:139)
	at javax.faces.component.UIInput.updateModel(UIInput.java:818)
	... 33 more
Caused by: java.lang.NullPointerException
	at controller.PloegController.setCompetitieId(PloegController.java:54)
	at controller.PloegController$Proxy$_$$_WeldClientProxy.setCompetitieId(PloegController$Proxy$_$$_WeldClientProxy.java)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at javax.el.BeanELResolver.setValue(BeanELResolver.java:442)
	at com.sun.faces.el.DemuxCompositeELResolver._setValue(DemuxCompositeELResolver.java:255)
	at com.sun.faces.el.DemuxCompositeELResolver.setValue(DemuxCompositeELResolver.java:281)
	at com.sun.el.parser.AstValue.setValue(AstValue.java:217)
	at com.sun.el.ValueExpressionImpl.setValue(ValueExpressionImpl.java:291)
	at org.jboss.weld.el.WeldValueExpression.setValue(WeldValueExpression.java:64)
	at com.sun.faces.facelets.el.TagValueExpression.setValue(TagValueExpression.java:131)
	... 34 more

I hope someone can help me here, I think it will be something stupid, but I'm out of thoughts at the moment.
If I need to give more code or something, please ask