Reputation: 1256
In our organization we have several JHipster
generated projects, they were done with version 3.0.0 and we haven't upgraded them since.
I've been working on upgrading one of them for the past 5 days, please find breakdown below:
I have tried three different approaches:
1.- Use the jhipster:upgrade
tool
Steps:
This process could break down into several steps such as:
1.- Creating local npm
folder to be able to install generators for different jhipster
versions with no persmission issues
2.- Erasing all old installations of yo
and jhipster
3.- Cloning project and creating dev branches
4.- Erase .jhipster
folder so entities are not affected by upgrade
5.- Once the upgrade code runs, we need to tweak several files/dependencies so the mvn clean/install
works
Complications
After applying all these steps, I find that the 2nd level cache
from Hibernate
refuses to work, asking me to include all classes in cache, I try several fixes/workarounds such as:
1.- Deleting liquibase
from project
2.- Configuring DatabaseConfiguration.java
with old settings and downloading old versions of libraries for this
3.- Configuring dev.yml
file to start as in old version
4.- Disable 2nd level cache
After doing this the cache
and liquibase
do not represent a problem, however, we go to another complication, this time involving the RememberMe
services, the JhipsterProperties
parameter for the constructor comes in empty, I debugged for a while, finding no relevant information on this and decided to drop this and try with method 2
2.- Re-create the upgrade steps manually.
For this method I follow the script found in github: https://github.com/jhipster/generator-jhipster/issues/3761
I installed locally the 3.4.0
version of Jhipster
to try and make a smooth transition and I do not erase the entities as in method 1, however now the project files just won’t load, the upgrade_branch
becomes resilient and whatever I do, I end up needing to erase the project and re-clone it
3.- Use the jhipster
command in the project root folder
I use version 3.4.0
for this too
The upgrade process runs smooth, changes the version in the package.json
file and links fine to the database first attempt (except for having to delete liquibase
again, which recreates itself during upgrade)
However we face a new issue with the RememberMe
tokens: Custom Persistence RememberMeServices]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: key cannot be empty or null
A little bit of research:
There are a number of reports and git-hub tickets stating that jhipster upgrade
doesn't work properly and, in fact, at this time, on the latest version, users are told that they may need to upgrade in a manual way as per this ticket: https://github.com/jhipster/generator-jhipster/issues/5883
I also consulted an ex-colleague who tried this and reckoned that it was much easier to make a new project and copy the necessary code rather than trying to manually migrate the conflicting pieces of code that arouse after doing an upgrade
Now, I also read in the git hub tickets that plenty of users seem to upgrade their projects seamlessly, so the questions I have would be:
1.- Am I facing the same issues as other developers but fail to know the technologies enough as to be able to solve them?
2.- Is there a solution at all to these kind of issues (2nd level cache and JhipsterProperties not holding key/not being passed as variable to constuctor)?
EDIT
I have found answer to the missing key in JHipsterProperties
. When running yo jhipster
it asks you if you want to overwrite a series of files, I just marked yes for all and so it overwrote the application.yml
where the key is stored for the properties, not restoring it or creating a new one. I tried running it again after cloning the project from master and it worked fine by choosing not to overwrite application.yml
(but overwriting the rest of the files)
EDIT 2
I finally managed to sort the hibernate cache issue by:
1.- Manually adding the cache for all entities in the CacheConfiguration.java
file, such as this:
cm.createCache(org.wwarn.drugquality.domain.AntiretroviralSurveyData.class.getName(), jcacheConfiguration);
cm.createCache(org.wwarn.drugquality.domain.Country.class.getName(), jcacheConfiguration);
And so on with all (48) entities
2.- Jhipster team now defaults cache region to the jhipster config properties looking like this:
hibernate.cache.region.factory_class: io.github.jhipster.config.jcache.NoDefaultJCacheRegionFactory
I had to change it to this:
hibernate.cache.region.factory_class: org.hibernate.cache.jcache.JCacheRegionFactory
And now it works just fine
Front end is broken and many customized code will need to be modified/replaced, but I finally managed to upgrade my project from v3.0.0
to v4.0.8
(using the yo jhipster
command, as the upgrade tool just doesn't work for me) Now the application is rolling smooth on the backend, and ready for a slow migration to Angular 2-4
Upvotes: 2
Views: 941
Reputation: 16294
Most of the issues of the upgrade were related to Windows and yarn. If you use Linux or OSX and npm < 5, you're in a better shape.
Also, if you run it often, issues will be easier to solve than a big version leap as you experienced.
This tool is very useful but it's still relatively new, things will get better over time.
You can run manually the steps from upgrade
by just reading its code, it's quite easy to follow and read its documentation.
Upvotes: 2