Custom project mapstore build and printing

346 views
Skip to first unread message
Assigned to matteo.v...@geosolutionsgroup.com by lorenzo...@geosolutionsgroup.com

Karsten Vennemann

unread,
Dec 18, 2020, 9:35:42 PM12/18/20
to mapstore-developers

Dear Mapstorers,
I am currently setting up my MapStore development environment on a Ubuntu machine because  wanted to add some functionality as plugins.
I followed this guide https://mapstore.readthedocs.io/en/latest/developer-guide/project-creation-script/ and got the custom project to work correctly and I was able to log in onto the web portal.
The map I created using the web interface did not have the print functionality so I went back and ran the build again (as I successfully did for the MapStore2 directory ).  To get a war with print functionality then I ran
 ./build.sh v2020.02.02 printing in the custom project folder (that ran all through and the tests succeeded)
and created a new war in web/target. However, using that resulting war still  did not give me a print button on the web map (as it had for the default MapStore.war I have build that way previously).
Is generally what I did the correct way of getting the print functionality added to a custom project or did I miss something ?
Karsten

Matteo V.

unread,
Dec 21, 2020, 5:00:38 AM12/21/20
to mapstore-developers
Hi,

the procedure is correct.

can you clarify a thing, have you used a custom or a standard type of project?
Can you send me you localConfig.json ?

Karsten Vennemann

unread,
Dec 21, 2020, 7:50:28 PM12/21/20
to mapstore-developers
Hi Matteo,

I have used a standard project and the command to create it I ran was the following:

node ./createProject.js standard terramap 1.0.0 "custom mapstore test" https://github.com/karstenv/terramap  /home/karsten/programs/terramap            

The localConfig.json for that project "terramap" is here http://www.terragis.net/docs/other/gisme/localConfig.json

I also upgraded my node + npm from npm 6.14.9 and node 10.23.0 versions
to npm 6.14.10 and node v12.20.0 on this ubuntu 16.4 machine and will try again from scratch.

Cheers
Karsten

Matteo V.

unread,
Dec 22, 2020, 4:51:53 AM12/22/20
to mapstore-developers
Hi,
an important step to do before creating a custom project 
is to change starting branch in mapstore to v2020.02.02 i.e. the branch of the release 
and then run 

npm install 

before doing the build add -P$2 to the mvn clean install in the else branch
like the following

if [ $# -eq 0 ]
  then
    mvn clean install -Dmapstore2.version=$VERSION
  else
    mvn clean install -Dmapstore2.version=$1 -P$2
fi

now you can run 
./build.sh v2020.02.02 printing 

karsten

unread,
Dec 22, 2020, 3:00:08 PM12/22/20
to mapstore-...@googlegroups.com
Hi,
 
yes I tried to clone the correct branch from git using
 
git clone --depth 1 --branch v2020.02.02 https://github.com/geosolutions-it/MapStore2
 
The npm install in the MapStore2 dir then ends with errors (also after tyring to clean the entrie machine of old nodejs and npm versions).
After that I also tried by removing the Mapstore2 directory and using the zipped source code archive instead of the git source.
My node version is v12.20.0, npm 6.14.8
However errors I get after npm install in the Mapstore2 directory created from the zip archive
are the same with both approaches - see as below.
 
Does that have to do with node-gyp somehow ?
I also found .cache/node-gyp directory under my users home dir and the root user that I deleted but that did not fix the errors
 
What could be the reason for this?
 
Karsten
 

> ttf2...@2.0.3 install /home/karsten/programs/MapStore2-2020.02.02/node_modules/ttf2woff2
> (node-gyp rebuild > builderror.log) || (exit 0)
../csrc/addon.cc: In function ‘Nan::NAN_METHOD_RETURN_TYPE convert(Nan::NAN_METHOD_ARGS_TYPE)’:
../csrc/addon.cc:10:49: error: no matching function for call to ‘v8::Value::ToObject()’
   Local<Object> inputBuffer = info[0]->ToObject();
                                                 ^
In file included from /root/.cache/node-gyp/12.20.0/include/node/node.h:67:0,
                 from ../../nan/nan.h:56,
                 from ../csrc/addon.cc:1:
/root/.cache/node-gyp/12.20.0/include/node/v8.h:2672:44: note: candidate: v8::MaybeLocal<v8::Object> v8::Value::ToObject(v8::Local<v8::Context>) const
   V8_WARN_UNUSED_RESULT MaybeLocal<Object> ToObject(
                                            ^
/root/.cache/node-gyp/12.20.0/include/node/v8.h:2672:44: note:   candidate expects 1 argument, 0 provided
In file included from /root/.cache/node-gyp/12.20.0/include/node/v8-internal.h:14:0,
                 from /root/.cache/node-gyp/12.20.0/include/node/v8.h:27,
                 from /root/.cache/node-gyp/12.20.0/include/node/node.h:67,
                 from ../../nan/nan.h:56,
                 from ../csrc/addon.cc:1:
/root/.cache/node-gyp/12.20.0/include/node/v8.h:2686:31: note: candidate: v8::Local<v8::Object> v8::Value::ToObject(v8::Isolate*) const
                 Local<Object> ToObject(Isolate* isolate) const);
                               ^
/root/.cache/node-gyp/12.20.0/include/node/v8config.h:328:3: note: in definition of macro ‘V8_DEPRECATED’
   declarator __attribute__((deprecated(message)))
   ^
/root/.cache/node-gyp/12.20.0/include/node/v8.h:2686:31: note:   candidate expects 1 argument, 0 provided
                 Local<Object> ToObject(Isolate* isolate) const);
                               ^
/root/.cache/node-gyp/12.20.0/include/node/v8config.h:328:3: note: in definition of macro ‘V8_DEPRECATED’
   declarator __attribute__((deprecated(message)))
   ^
make: *** [Release/obj.target/addon/csrc/addon.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:314:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
gyp ERR! System Linux 4.15.0-128-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/karsten/programs/MapStore2-2020.02.02/node_modules/ttf2woff2
gyp ERR! node -v v12.20.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
 
 


From: mapstore-...@googlegroups.com [mailto:mapstore-...@googlegroups.com] On Behalf Of Matteo V.
Sent: Tuesday, December 22, 2020 01:52
To: mapstore-developers
Subject: [mapstore-developers] Re: Custom project mapstore build and printing

--
You received this message because you are subscribed to a topic in the Google Groups "mapstore-developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mapstore-developers/qm_Wp6tXsjc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mapstore-develo...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/mapstore-developers/69df1bb4-d561-49bd-8383-f0a7a781f156n%40googlegroups.com.

karsten

unread,
Dec 22, 2020, 3:23:24 PM12/22/20
to mapstore-...@googlegroups.com
Hi,
 
I tried the same on another 'fresh' server with Ubuntu 16.04, node version is v12.20.0, npm 6.14.8 and
trying to use git clone as below I tsill get teh same error with npm install.
 
Seems that I must be doing something wrong.
 
Any ideas ?
 
Cheers
Karsten


From: karsten [mailto:kar...@terragis.net]
Sent: Tuesday, December 22, 2020 12:00
To: 'mapstore-...@googlegroups.com'
Subject: RE: [mapstore-developers] Re: Custom project mapstore build and printing

karsten

unread,
Dec 22, 2020, 3:44:28 PM12/22/20
to mapstore-...@googlegroups.com
Ok the "magic" to fix all that was simply to remove the package-lock.json file in the MapStore2-2020.02.02 directory
Now on both servers the npm install works fine
 
Sorry for the noise
Karsten

From: mapstore-...@googlegroups.com [mailto:mapstore-...@googlegroups.com] On Behalf Of karsten
Sent: Tuesday, December 22, 2020 12:23

Karsten Vennemann

unread,
Dec 22, 2020, 4:46:09 PM12/22/20
to mapstore-developers
I am still running into trouble with creating a standard mapstore2 project.
The npm install in both the MapStore2 and the created standard mapstore project folder 'terramap2' ran through without errors.
I tried to make sure that I am using the correct version ( MapStore2-2020.02.02 ) by using the zip archive and then created a local git repository of that folder.
But running

./build.sh v2020.02.02 printing

runs into the errors below.
Does that mean I am still somehow am using the wrong version or anything else I am doing wrong ?
Karsten

> rimraf dist
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.resolve has an unknown property 'fallback'. These properties are valid:
   object { alias?, aliasFields?, cachePredicate?, cacheWithContext?, concord?, descriptionFiles?, enforceExtension?, enforceModuleExtension?, extensions?, fileSystem?, mainFields?, mainFiles?, moduleExtensions?, modules?, plugins?, resolver?, symlinks?, unsafeCache?, useSyncFileSystemCalls? }
   -> Options for the resolver
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! terr...@1.0.0 compile: `npm run clean && mkdirp ./dist && node --max_old_space_size=2048 ./node_modules/webpack/bin/webpack.js --config prod-webpack.config.js --env.production`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the terr...@1.0.0 compile script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-12-22T21_32_21_808Z-debug.log


----------------------------------------------------------------------------------------
file content of  root\.npm\_logs\2020-12-22T21_32_21_808Z-debug.log
----------------------------------------------------------------------------------------
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'compile' ]
2 info using n...@6.14.8
3 info using no...@v12.20.0
4 verbose run-script [ 'precompile', 'compile', 'postcompile' ]
5 info lifecycle terr...@1.0.0~precompile: terr...@1.0.0
6 info lifecycle terr...@1.0.0~compile: terr...@1.0.0
7 verbose lifecycle terr...@1.0.0~compile: unsafe-perm in lifecycle true
8 verbose lifecycle terr...@1.0.0~compile: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/karsten/programs/terramap2/node_modules/.bin:/home/karsten/programs/apache-maven-3.6.3/bin:/usr/lib/postgresql/12/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
9 verbose lifecycle terr...@1.0.0~compile: CWD: /home/karsten/programs/terramap2
10 silly lifecycle terr...@1.0.0~compile: Args: [
10 silly lifecycle   '-c',
10 silly lifecycle   'npm run clean && mkdirp ./dist && node --max_old_space_size=2048 ./node_modules/webpack/bin/webpack.js --config prod-webpack.config.js --env.production'
10 silly lifecycle ]
11 silly lifecycle terr...@1.0.0~compile: Returned: code: 1  signal: null
12 info lifecycle terr...@1.0.0~compile: Failed to exec compile script
13 verbose stack Error: terr...@1.0.0 compile: `npm run clean && mkdirp ./dist && node --max_old_space_size=2048 ./node_modules/webpack/bin/webpack.js --config prod-webpack.config.js --env.production`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:314:20)
13 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:314:20)
13 verbose stack     at maybeClose (internal/child_process.js:1022:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
14 verbose pkgid terr...@1.0.0
15 verbose cwd /home/karsten/programs/terramap2
16 verbose Linux 4.15.0-128-generic
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "compile"
18 verbose node v12.20.0
19 verbose npm  v6.14.8
20 error code ELIFECYCLE
21 error errno 1
22 error terr...@1.0.0 compile: `npm run clean && mkdirp ./dist && node --max_old_space_size=2048 ./node_modules/webpack/bin/webpack.js --config prod-webpack.config.js --env.production`
22 error Exit status 1
23 error Failed at the terr...@1.0.0 compile script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Karsten Vennemann

unread,
Dec 28, 2020, 6:13:25 PM12/28/20
to mapstore-developers
I still could not find out what might be leading to this problem with the standard project creation above. What are my options to manually creating one to be able to start writing my plugin / extension ? I previously had created a standard MapStore project without the printing capabilities and wanted to ad those...

Cheers
Karsten

Matteo V.

unread,
Mar 1, 2021, 11:47:10 AM3/1/21
to mapstore-developers
Hi, sorry for the delay,
do you still need help on this?

Karsten Vennemann

unread,
Mar 1, 2021, 5:07:15 PM3/1/21
to mapstore-developers
Hi yes indeed, I never did get this to work and gave up on it. However, let me try with the new release of Mapstore and I will come back after installing and testing with the version and creating a custom project is working correctly on my machine using that version

Stefan Overkamp

unread,
Dec 12, 2021, 6:38:37 AM12/12/21
to mapstore-...@googlegroups.com, Karsten Vennemann
Hi,

did anyone get a standard project creation with printing module running?

with
mvn clean install -Dmapstore2.version=v2021.02.00 -Pprinting
 I got an 90MB war file, but
[WARNING] Warning: selected war files include a WEB-INF/web.xml which will be ignored
(webxml attribute is missing from war task, or ignoreWebxml attribute is specified as 'true')
mapstore fails running in tomcat

with mvn clean install -Dmapstore2.version=v2021.02.00
I got a 68 MB war file which is running in tomcat.

Is it better to use mapstore directly instead of having a standard project?

The advice in https://mapstore.readthedocs.io/en/latest/developer-guide/printing-module/
"If you have an existing and deployed instance of MapStore and you want to add the printing module, you can build only the printing extension as a zip running mvn clean install -Pprintingbundle. " doesn't function in my installation:
[WARNING] The requested profile "printingbundle" could not be activated because it does not exist.

Thanks
Stefan
You received this message because you are subscribed to the Google Groups "mapstore-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapstore-develo...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/mapstore-developers/7917789b-1c8a-462e-b8d1-5f5b4f09b2d5n%40googlegroups.com.


-- 
Dipl. Ing. Stefan Overkamp
over...@posteo.de

Matteo Velludini

unread,
Dec 21, 2021, 6:27:32 AM12/21/21
to mapstore-developers

Hi,

indeed there is a problem with creation of projects and printing,
i have opened this issue to keep track and from next release it will be fixed, 
but if you want to fix it for your current version v2021.02.00 you can do the following

first of all check the logs maven is reporting, you will see that 
the path where the pom is taking the printing resources is wrong and it fails to copy them

[INFO] --- maven-resources-plugin:2.6:copy-resources (printing) @ printing_project-web ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Work\projects\_Geosolutions\testing_create_project\printing_project\web\..\MapStore2\resources\geoserver\print    
[INFO]

so in order to fix this locally
you have to edit your web/pom.xml

with the following change
from <directory>${basedir}/../MapStore2/resources/geoserver/print</directory>
to <directory>${basedir}/../MapStore2/java/printing/resources/geoserver/print</directory>


then i suggest to include the printing profile in the build script
so, you can edit build.sh  like the following
#!/bin/bash
set -e

export GITREV=`git log -1 --format="%H"`
export VERSION="SNAPSHOT-$GITREV"

# npm install
# npm run compile
# npm run lint

if [ $# -eq 0 ]
  then
    mvn clean install -Dmapstore2.version=$VERSION -Pprinting
  else
    mvn clean install -Dmapstore2.version=$1 -Pprinting
fi

Then you run ./build.sh

and this war should include also the printing folder,
check that is present
now if you run tomcat with this new war it will include the print plugin too
Reply all
Reply to author
Forward
0 new messages