Some Trials & a lot of Errors
I tried a bunch of framework and other language and I usually feel overwhelm when its time to do something real with what I've learned. So that why I created this site, to write my progress and help some noob like me that stumble into the sames problems.
Browse: Home / java

java

How to remove array element in mongodb in java?

By Chris on June 17, 2021

In the previous post, we discuss own we change from using mongorepository to using directly mongodb method to access and modify directly the object in db.In this posts we look at code that was deleting with mongorepository and change it to use directly mongodb method with MongoTemplate. Using MongoTemplate is faster and less likely to […]

Posted in java, mongodb, prog, tips | Tagged java, mongodb, MongoRepository, MongoTemplate | Leave a response

How to update an entry in an array in mongodb with java MongoTemplate?

By Chris on June 10, 2021

We had at work a piece of code that was using mongorepository and updating the arrays of the object on a collection instead of using mongodb method directly.The way it was coded had a big issues with concurrency and we were losing update because of it.The problem we had with the way it was updating […]

Posted in java, mongodb, prog, tips | Tagged java, mongodb, MongoRepository, MongoTemplate | Leave a response

Assert an Exception is Thrown in JUnit 4 and 5

By Chris on May 19, 2021

This is old news, but having work with big bank and insurance companies they tend to stick with the old version of java and they’re underlying libraries, I’ve finally been expose to new ways of testing exception with junit. I use to test exception by adding an expected right after the @Test annotation.@Test(expected = NullpointerException) […]

Posted in java | Tagged assertJ, java, junit, junit4, junit5, mokito, testing | Leave a response

Solving LazyInitializationException with sonar rules @Transactional method called from another method doesn’t obtain a transaction

By Chris on May 12, 2021

We recently added a feature that allowed direct modification on our content for some client vs using the same path (queues) that the batched content is using. Our user were really happy with it, but after our team implemented the new feature, we started having some LazyInitializationException. exception for that problem org.hibernate.LazyInitializationException: could not initialize […]

Posted in java | Tagged Exception, hibernate, java, LazyInitializationException | Leave a response

Why does Map.of not allow null keys and values?

By Chris on March 2, 2021

Once upon a time an engineer with years of experience encounter something so basic he doesn’t understand why he didn’t encounter it sooner. This week we had a strange error in our log stating that should have a null values in a map. After some digging in the service where that log was found, it […]

Posted in java | Tagged java, java.util.Map, maps, null | Leave a response

Constructor XXX in enum XXX cannot be applied to given types in mapstruct

By Chris on May 20, 2020

I was having that weird error when I was working with mapstruct, turn out that the default java version for mapstruct is java 6. Since our project was in java 11 I was getting the error “Constructor XXX in enum XXX cannot be applied to given types”. My starting config was : <dependencies> <dependency> <groupId>org.mapstruct</groupId> […]

Posted in error, java | Tagged java, java8, mapstruts, maven | Leave a response

List Return a java.lang.UnsupportedOperationException when adding or removing a element

By Chris on October 12, 2014

While trying to remove a element after creating a List from a array using the Array.asList(array[]) method I’ve stumbled on that error. java.lang.UnsupportedOperationException at java.util.AbstractList.add(AbstractList.java:131) at java.util.AbstractList.add(AbstractList.java:91) Then I remember this, list created by the Arrays.asList method are immutable Same goes for empty lists. So instead create a arraylist : List<String> list = new ArrayList<String>(Arrays.asList(split));

Posted in java, prog | Tagged arraylist, java, java.util.List | Leave a response

JENKINS: How to fix a java.net.NoRouteToHostException.

By Chris on October 5, 2014

Our build server (jenkins) had that error   BUILD FAILED com.jcraft.jsch.JSchException: java.net.NoRouteToHostException: No route to host Full stack trace below if you really need it. I assume there was a problem with where Jenkins was deploying the apps or at a issue trying to run integration test on the remote server. After talking to IT […]

Posted in prog | Tagged build server, java, jenkins | Leave a response

Why is String not sorting with the Local ?

By Chris on September 28, 2014

Comparing and sorting Strings might not work out like you expected specially when your dealing with a language other than English. Normally comparing strings in done with simple Unicode ordering. If you want to have localized ordering (the kind expected by an end user) you need to use a Collator. Commonly used String methods such […]

Posted in java, prog | Tagged collator, java, sorting, String | Leave a response

Lessons learned: Why struts not working ?

By Chris on September 2, 2014

If you happen to rename your folder that contain your jsp and js, don’t forget to update the struts config (and the tiles). This will save your precious time even hours …

Posted in java | Tagged java, javascript, js, jsp, struts | Leave a response

Next »

Tags

2018 2022 about app apparment arraylist blog book books condo date db errors gifts hibernate ideas inspiration java java.util.List jboss linux List mongodb MongoRepository MongoTemplate motivation mysql netstat oracle port productivity real estate reviews school Seth Godin sql String struts students The 100 days project The Practice to_date wedding welcome windows

Recent Comments

  • kevin on Oracle have no Boolean, how to fix this

Calendar

May 2022
MonTueWedThuFriSatSun
 1
2345678
9101112131415
16171819202122
23242526272829
3031 
« Apr  

Archives

  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • March 2021
  • February 2021
  • May 2020
  • January 2019
  • December 2018
  • July 2018
  • April 2018
  • January 2018
  • October 2014
  • September 2014
  • August 2014

Copyright © 2022 Some Trials & a lot of Errors.

Powered by WordPress and Hybrid.