'findAll() function at backend causes net::INCOMPLET_CHUNKED_ENCODING error at frontend
I'm developing an angular project that communicates with a spring-boot backend. here are the codes at the backend
public class Article extends Audit<String> implements Serializable{
@Id
@Column(insertable = true, updatable = true)
private String codArt;
private String libArt;
private String libCou;
private boolean achetable;
private boolean numSerie;
private boolean stockable;
private boolean perissable;
private boolean consommable;
private boolean vendable;
private boolean productible;
@ManyToOne(targetEntity = Famille.class,fetch = FetchType.EAGER)
@JoinColumn(name = "famille", nullable = false)
private Famille familleArt;
@ManyToOne(targetEntity = Unite.class,fetch = FetchType.EAGER)
@JoinColumn(name = "unite", nullable = false)
private Unite unite;
private double prix;
@OneToMany(cascade = {CascadeType.REMOVE}, mappedBy = "article")
List<Stocker> stks;
public Article() {
// TODO Auto-generated constructor stub
}
public Article(String codArt, String libArt, String libCou, boolean achetable, boolean numSerie,
boolean stockable, boolean perissable, boolean consommable, boolean venArt, boolean prod, Famille familleArt,
Unite unite) {
super();
this.codArt = codArt;
this.libArt = libArt;
this.libCou = libCou;
this.achetable = achetable;
this.numSerie = numSerie;
this.stockable = stockable;
this.perissable = perissable;
this.consommable = consommable;
this.vendable = venArt;
this.familleArt = familleArt;
this.productible= prod;
this.unite = unite;
}
}
Repository
@Repository
public interface ArticleRepo extends JpaRepository<Article, String>{
@Query(value = "SELECT * FROM article WHERE achetable", nativeQuery = true)
public List<Article> articlesAchetables();
@Query(value="SELECT * FROM article WHERE achetable AND famille IN "
+ "(SELECT familles_cod_fam FROM familles_autorisees WHERE magasin_cod_mag like :mg)", nativeQuery = true)
public List<Article> articlesAchetablesParMagasin(String mg);
}
Service
public class ArticleService {
@Autowired
private ArticleRepo repo;
public List<Article> list(){
return repo.findAll();
}
public List<Article> listAchetable(){
return repo.articlesAchetables();
}
public List<Article> listAchetablesParMagasin(String mg){
return repo.articlesAchetablesParMagasin(mg);
}
}
Controler
import java.util.List;
import sih.stoc.entities.Article;
@RestController
@CrossOrigin
@RequestMapping(path = "basestock/")
public class StocBaseController {
@Autowired
private ArticleService articleService;
// ---ControllerArticle
@GetMapping(path = "article/list")
public List<Article> listarticle() {
return this.articleService.list();
}
@GetMapping("article/achetable/list")
public List<Article> listArticlesAchetable(){
return this.articleService.listAchetable();
}
@GetMapping("magasin/{mg}/article/achetable/list")
public List<Article> listeArticlesAchetablesParMagasin(@PathVariable(name = "mg", required = true) String mg){
return articleService.listAchetablesParMagasin(mg);
}
}
Here are codesat front end
service
@Injectable({
providedIn: 'root'
})
export class SMagasin {
hot!: string;
constructor(public us: Tools, public http: HttpClient) { }
listAchetable() {
if (this.us.jtoken == null) {
this.us.loadToken();
}
return this.http.get<Article[]>(this.us.hote + 'basestock/article/achetable/list', { headers: new HttpHeaders({ 'Authorization': this.us.jtoken }) });
}
listAchetableParMag(mg: String) {
if (this.us.jtoken == null) {
this.us.loadToken();
}
return this.http.get<Article[]>(this.us.hote + 'basestock/magasin/' + mg + '/article/achetable/list', { headers: new HttpHeaders({ 'Authorization': this.us.jtoken }) });
}
}
ArticleComponent.ts
export class ArticleComponent implements OnInit {
familles: Famille[] = [];
unites: Unite[] = [];
uni = new Unite('', '');
tabUni: DataTables.Settings = {};
dtUni: Subject<any> = new Subject<any>();
art: Article = new Article('', '', '', false, false, false, false, false, false, false, new Famille('', ''), new Unite('', ''));
articles: Article[] = [];
tabArt: DataTables.Settings = {};
dtArt: Subject<any> = new Subject<any>();
constructor(public tr: ToastrService, public us: Tools, public mg: SMagasin, public mod: NgbModal, public sanit: DomSanitizer) {
this.mg.listUnit().subscribe(data => {
this.unites = data;
this.dtUni.next;
setTimeout(() => {
$('#tUni').DataTable({
pagingType: 'full_numbers',
pageLength: 5,
processing: true,
search: true,
searching: true,
lengthMenu: [5, 10, 25],
language: {
lengthMenu: 'Affichage de _MENU_ lignes par page',
zeroRecords: 'Aucune ligne trouvée - Desolé',
info: 'Affichage de la page _PAGE_ sur _PAGES_',
infoEmpty: 'Pas de ligne trouvée',
infoFiltered: '(Filtré à partie de _MAX_ lignes)',
search: 'Rechercher',
loadingRecords: 'Chargement en cours...',
paginate: {
first: 'Début',
last: 'Fin',
next: 'Suivant',
previous: 'Précédent'
}
}
});
}, 1);
}, error => console.error(error));
this.mg.listArt().subscribe(data => {
this.articles = data;
this.dtArt.next; }
});
}, 1);
}, error => console.error(error));
}
on request to load articles, browser throws error
> net::IMCOMPLET_CHUNKED_ENCODING 200.
and the backend sends a lot of lines like this
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:728) ~[jackson-databind-2.12.5.jar:2.12.5] at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770) ~[jackson-databind-2.12.5.jar:2.12.5] at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178) ~[jackson-databind-2.12.5.jar:2.12.5] at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:728) ~[jackson-databind-2.12.5.jar:2.12.5]......
Can someone explain to me what is going on, please? However, there are other loads that pass without problem
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
