title: HttpErrorResponse : internal server error
body: <p>i am new with angular 6 .
  i have developed a post service with spring boot and when i test it via postman ,it works perfectly but when i test it with web browser it gave me this error :</p>
  
  <p>HttpErrorResponse {headers: HttpHeaders, status: 500, statusText: "OK", url: "<a href="http://localhost:8080/api/test/ordermiss" rel="nofollow noreferrer">http://localhost:8080/api/test/ordermiss</a>", ok: false, …}error: {timestamp: "2019-07-10T13:35:09.083+0000", message: null, details: "uri=/api/test/ordermiss"}details: "uri=/api/test/ordermiss"message: nulltimestamp: "2019-07-10T13:35:09.083+0000"<strong>proto</strong>: Objectheaders: HttpHeaderslazyInit: ƒ ()lazyUpdate: nullnormalizedNames: Map(0) {}<strong>proto</strong>: Objectmessage: "Http failure response for <a href="http://localhost:8080/api/test/ordermiss" rel="nofollow noreferrer">http://localhost:8080/api/test/ordermiss</a>: 500 OK"name: "HttpErrorResponse"ok: falsestatus: 500statusText: "OK"url: "<a href="http://localhost:8080/api/test/ordermiss" rel="nofollow noreferrer">http://localhost:8080/api/test/ordermiss</a>"<strong>proto</strong>: HttpResponseBaseconstructor: ƒ HttpErrorResponse(init)<strong>proto</strong>: Object</p>
  
  <p>and when i take a look to the spring console it gave this warning :</p>
  
  <p>2019-07-11 13:36:01.796  WARN 14404 --- [nio-8080-exec-4] .m.m.a.ExceptionHandlerExceptionResolver : Resolved [java.lang.NullPointerException]</p>
  
  <p>i worked with the same method with another object but i didn't get this error so please could you help me </p>
  
  <p>this the service :</p>
  
  <pre><code>                constructor(private http: HttpClient) { }
  
             SaveOM(Om: Object): Observable&lt;Object&gt; {
           return this.http.post(`${this.baseUrl}`, Om);
             }
  </code></pre>
  
  <p>and this is the .ts :</p>
  
  <pre><code>    save() {
        this.omService.SaveOM(this.ordermission)
        .subscribe(data =&gt; console.log(data), error =&gt; console.log(error));
      this.ordermission = new Ordermission();
        }
  
       onSubmit() {
         this.submitted = true;
            this.save();
         }
  </code></pre>
  
  <p>the class angular:</p>
  
  <pre><code>           export class Ordermission {
            id:number;
          mat:string;
           depart:string;
           dest:string;
        // etat:string;enum class
         // type:string;enum class
          // localisation:string;enum class
           datedeb:Date;
          datefin:Date;
           distance:number;
           couttranp:number;
           coutheberg:number;
         total:number;
          }
  </code></pre>
  
  <p>the controller: </p>
  
  <pre><code>              @CrossOrigin(origins = "*", maxAge = 3600)
               @RestController
              @RequestMapping("/api/test")
                @PreAuthorize("hasRole('USER') or hasRole('ADMIN')")
            public class OrdermissionController {
  
    @Autowired private OrdermissionRepository ordermissionrep;
  
    @Autowired private OrderMissService orderMissService;
  
  
    @PostMapping("/ordermiss")
  // @ExceptionHandler(RuntimeException.class)
      public Ordermission createOM(@Valid @RequestBody Ordermission OM) {
          return orderMissService.saveOM(OM);
  
      }
  </code></pre>
  
  <p>the service :</p>
  
  <pre><code>                 @Service
                  public class OrderMissServiceImpl implementsOrderMissService {
                   Double var;
                   Double tot;
                   long cal;
                  long cout;
  
    @Autowired private OrdermissionRepository ordermissionrep;
  
  
  @Override
  public Ordermission saveOM(Ordermission om) {
          if(om.getDepart().equals(Local.tunis) &amp;&amp; om.getDest().equals(Local.sousse) || om.getDepart().equals(Local.sousse) &amp;&amp; om.getDest().equals(Local.tunis)) {
          var =(double) 143;
          om.setDistance(var);
      }
      if(om.getDepart().equals(Local.tunis) &amp;&amp; om.getDest().equals(Local.tabarka) || om.getDepart().equals(Local.tabarka) &amp;&amp; om.getDest().equals(Local.tunis)) {
          var =(double) 175;
          om.setDistance(var);
      }
  
  
      if(om.getDepart().equals(Local.tunis) &amp;&amp; om.getDest().equals(Local.zaghouan) || om.getDepart().equals(Local.zaghouan) &amp;&amp; om.getDest().equals(Local.tunis)) {
          var =(double) 57;
          om.setDistance(var);
      }
      if(om.getDepart().equals(Local.tunis) &amp;&amp; om.getDest().equals(Local.zarsis) || om.getDepart().equals(Local.zarsis) &amp;&amp; om.getDest().equals(Local.tunis)) {
          var =(double) 544;
          om.setDistance(var);
      }
  
        if(om.getType().equals(Typetransport.perso)) {
            cal=(long) (om.getDistance()*2*0.08);
            om.setCouttranp(cal);
        }
  
        if(om.getType().equals(Typetransport.pubic)) {
            cal=(long) (om.getDistance()*2*0.375);
            om.setCouttranp(cal);
        }
  
       if(om.getEtat().equals(Etat.cadre)) {
           cout=(DaysBetween(om)+1)*25;
           om.setCoutheberg(cout);
       }
       if(om.getEtat().equals(Etat.non_cadre)) {
           cout=(DaysBetween(om)+1)*20;
           om.setCoutheberg(cout);
       }
       else if (om.getCoutheberg() != null &amp;&amp; om.getCouttranp()!=null) {
          tot = (double) (om.getCoutheberg()+om.getCouttranp());
          om.setTotal(tot);
      }
      return  ordermissionrep.save(om);
  </code></pre>
  
  <p>}</p>
  
  <p>The entity :</p>
  
  <pre><code>      @Entity
      @Table(name = "ordermission")
     public class Ordermission {
  
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  private Long id;
  
  private String mat;
  
  @Enumerated(EnumType.STRING)
  private Typetransport type;
  
  @Enumerated(EnumType.STRING)
  private Etat etat;
  
  @Enumerated(EnumType.STRING)
  private Local depart;
  
  @Enumerated(EnumType.STRING)
  private Local dest;
  @Temporal(TemporalType.DATE)
  private Date datedeb;
  @Temporal(TemporalType.DATE)
  private Date datefin;
  
  private Double distance;
  
  private Long couttranp;
  private Long coutheberg;
  
       // @Formula("couttranp + coutheberg")
         private Double total;  
  </code></pre>