Filling an object through another object

Asked

Viewed 57 times

0

I’m trying to fill parameters of one object through another. When debugging the code it stops at that part.

First line is 72.

The variable pNumer takes the value correctly from JSP. But I believe the problem is getting to the Address Object and setting the value there.

inserir a descrição da imagem aqui

Follow the "Nullpointerexception error log".

inserir a descrição da imagem aqui

Code:

//ENDERECO
supervisor.getEndereco().setNumero(pNumero);
supervisor.getEndereco().setComplemento(pComplemento);
supervisor.getEndereco().setCep(pCEP);
es.criar(supervisor.getEndereco());

CONSOLE:

java.lang.NullPointerException
at command.CriarSupervisor.executar(CriarSupervisor.java:72)
at controller.ServletController.doExecute(ServletController.java:42)
at controller.ServletController.doPost(ServletController.java:56)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at filter.LogFilter.doFilter(LogFilter.java:55)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at filter.ConnectionFilter.doFilter(ConnectionFilter.java:47)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
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)
  • 2

    Can you add the code? Unfortunately not everyone can see images by network restrictions.

  • All right, buddy, I’ve edited the question.

  • What do you have in this es.create(supervisor.getEndereco());? or better in es.create()?

  • @Marcondes it creates the address in the database and returns the created id.

  • es = Address that calls the Address (create). But the problem is that it is not filling the values in the address.

1 answer

1

got!

Before setting the values in other objects I stopped them, because it was null.

supervisor.setEndereco(new Endereco());

Browser other questions tagged

You are not signed in. Login or sign up in order to post.