Errors and solutions

[Resolved] “org.springframework.web.HttpMediaTypeNotSupportedException” angular 5

Errors and solutions
Hi All, Recently I came across this "org.springframework.web.HttpMediaTypeNotSupportedException" error while trying to hit my spring boot rest web services application from angular 5.   I am posting my experience because to help someone quickly. I almost cross checked all the places many times, but I could not find the below miss which I found at last and also do remember this error says that "HttpMediaTypeNotSupportedException", so this error can happen due to incorrect media type/media type is not set or some spelling issue.   In my case, Error: "org.springframework.web.HttpMediaTypeNotSupportedException" Resolution: I just missed s in the header in the return this.http.post line, it should be headers, but I just mentioned s and wrote as as header. Before Fix

Understanding & Resolving “Too many connections” Exception

Errors and solutions
Understanding & Resolving "Too many connections" Exception:   Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Data source rejected establishment of connection, message from server: "Too many connections" Issue Fix: Close the open connections properly, because too many open connection error indicates too many connections are opened but not closed. Existing Code which has the issue:   In the below code, finally block still has the code snippet to close the too many connections exception. But I did very badly, closing the connection by opening it newly in finally block instead of the one used inside the try block. [java] public List<CouponDBPojo> getCouponzForPublish(int start, int rowLimit) { // int start = 10; // int r...

[Solved] ReferenceError: KeyboardEvent is not defined

Errors and solutions
[Solved] ReferenceError: KeyboardEvent is not defined This error happens due to lot of reasons. In my case I was getting this error while making my angular site to angular universal site for server side rendering and better SEO. But when I was trying to convert to angular universal I got this "ReferenceError: KeyboardEvent is not defined " issue. In my case it was because of ngx-bootstrap component. In particular I used rating component from ngx-bootstrap and exactly in that module I got this error. I just commented out those things and ran npm run start and it works fine. And I came across a below link which actually suggests to built angular universal with ngx-bootstrap using webpack, details are at the below link, https://github.com/ranavc32/SimpleMDE-angular-univer

[Solved] ERROR Error: No value accessor for form control with unspecified name attribute

Errors and solutions
[Solved] ERROR Error: No value accessor for form control with unspecified name attribute   This issue will occur due to lot of reasons, here I am writing my case to help someone, Issue: This issue happened with angular 4 cli + angular material 2 for me. I used mat-radio-button, mat-checkbox in my template page. But I missed to import the radio module and FormsModule in my app module. Solutions: Import all the respective modules in your module page [In this case MatCheckboxModule and MatRadioModule]. Ensure you have already imported FormsModule as well. Issue code: import { MatButtonModule, MatCheckboxModule, MatCardModule, MatInputModule } from '@angular/material'; imports: [BrowserModule,BrowserAnimationsModule,MatButtonModule,MatCheckboxModule,FormsModule,HttpMod...

[Solved] Cannot read property ‘getSourceFile’ of null

Errors and solutions
[Solved] Cannot read property 'getSourceFile' of null:   This error occurs due to lot of things, I just explained what happened in my case below, hope it helps some people. I generated a component named "store component" in two different places using the below comments by mistake, ng g c store one is under layout folder and other one is under layout/homepage folder. When I first generated ng g c store under layout/homepage it imported store component in layout.module. When I generated under layout second time, layout.module is not updated as the component name is same. Now actually I don't want the store component under layout/homepage/store, so when I deleted and changed the references paths to layout/store, I got this error. Solution: I removed store component a...

[Solved] your global angular cli version is greater than your local version

Errors and solutions
[Solved] your global angular cli version is greater than your local version Root cause: If you have developed your angular-cli project in some version, say 1.0.3 in some machine and you are trying to build/compile in the other system which is having higher angular-cli version, say 1.4.2 then you will get this warning message "your global angular cli version is greater than your local version".   But it is recommended to resolve this by installing npm with the below command to resolve this warning. Run the below command in your project where you ran ng serve: npm install --save-dev @angular/cli@latest   After running the above command run again ng serve now you will not get "your global angular cli version is greater than you local version" warning message, and also...

[Solved] node sass could not find a binding for your current environment windows 64-bit with node.js 6.x

Errors and solutions
[Solved] node sass could not find a binding for your current environment windows 64-bit with node.js 6.x Root cause: This issue will happen if you have moved your angular cli project from 32bit to 64bit environment. Ensure you are rebuilding the node-sass to resolve this issue.   Command to rebuild: npm rebuild node-sass   Issue Screenshot:     Fixing using rebuild command:     Now the issue resolved and ng serve compiles successfully:     Thanks for reading!

[Resolved] java.util.LinkedHashMap cannot be cast to org.json.simple.JSONObject

Errors and solutions
[Resolved] java.util.LinkedHashMap cannot be cast to org.json.simple.JSONObject This issue may happen for various use cases, I have explianed my usecase with the explanation below, hope it helps someone. My JSON string / JSON response sample is: [plain] {"itemName":"Amazon","id":1} [/plain]   Issue code: [java] for(int i=0;i<selectedStoresJsonArray.size();i++){ JSONObject jsonObj = (JSONObject) selectedStoresJsonArray.get(i); if(null!=jsonObj.get("itemName") && !jsonObj.get("itemName").toString().isEmpty()){ tempSelectedStores.add(jsonObj.get("itemName").toString()); } } [/java]   Here JSONObject is not knowing the type of the response received while deserializing, so it is throwing this exception. Because by default json deserialize ...

[Resolved] Illegal attempt to dereference path source [null.categoryList] of basic type

Errors and solutions, Hibernate
[Resolved] Illegal attempt to dereference path source [null.categoryList] of basic type This issue may happen for various use cases, I have explianed my usecase with the explantion, hope it helps someone.   Issue code: [java] Expression catInExp = couponRoot.get("categoryList").get("categoryName"); Predicate categoryInPredicate = catInExp.in(tempCategoryNamesSelected); allPredicates.add(categoryInPredicate); [/java]   Code Fixed: [java] Expression catInExp = couponRoot.join("categoryList").get("categoryName"); Predicate categoryInPredicate = catInExp.in(tempCategoryNamesSelected); allPredicates.add(categoryInPredicate); [/java]   My Coupon Model: [java] @Entity public class Coupon implements Serializable{ @ManyToMany private Set cate...