# Web services plugins error 12.1

**URL:** <https://community.siren.io/t/web-services-plugins-error-12-1/495>\
**Category:** Siren Platform/Investigate Tech Support Community\
**Created:** [May 23, 2022, 12:16pm UTC](https://community.siren.io/t/web-services-plugins-error-12-1/495 "2022-05-23T12:16:23Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![JamesMcGee](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@JamesMcGee](https://community.siren.io/u/JamesMcGee)\
**Post date:** [May 23, 2022, 12:16pm UTC](https://community.siren.io/t/web-services-plugins-error-12-1/495/1 "2022-05-23T12:16:23Z")

</div>

Hi,

I just upgraded to the new 12.1 version. Everything works great except my web services in the “plugins” folder.

I keep getting errors that I didn’t get before. I migrated back to 12.0.3 and everything works fine.

Thanks.

---

<div class="post-metadata">

**Author:** ![Fabio\_Corneti](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.siren.io/fabio_corneti/32/97_2.png) [@Fabio\_Corneti](https://community.siren.io/u/Fabio_Corneti)\
**Post date:** [May 23, 2022, 12:24pm UTC](https://community.siren.io/t/web-services-plugins-error-12-1/495/2 "2022-05-23T12:24:21Z")

</div>

Hello James,  
what errors are you getting?

---

<div class="post-metadata">

**Author:** ![JamesMcGee](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@JamesMcGee](https://community.siren.io/u/JamesMcGee)\
**Post date:** [May 23, 2022, 12:31pm UTC](https://community.siren.io/t/web-services-plugins-error-12-1/495/3 "2022-05-23T12:31:53Z")

</div>

Hi Fabio,

log [12:30:59.662] [warning][config][deprecation] investigate\_core.load\_jdbc is deprecated and is no longer used  
log [12:31:00.592] [fatal] TypeError: require(…) is not a function  
at Plugins.new (/opt/siren-investigate/src/server/plugins/plugin\_collection.js:65:43)  
at KbnServer.module.exports (/opt/siren-investigate/src/server/plugins/scan.js:68:22)  
at KbnServer.mixin (/opt/siren-investigate/src/server/kbn\_server.js:99:7)  
at Command. (/opt/siren-investigate/src/cli/serve/serve.js:153:7)  
FATAL TypeError: require(…) is not a function  
at Plugins.new (/opt/siren-investigate/src/server/plugins/plugin\_collection.js:65:43)  
at KbnServer.module.exports (/opt/siren-investigate/src/server/plugins/scan.js:68:22)  
at KbnServer.mixin (/opt/siren-investigate/src/server/kbn\_server.js:99:7)  
at Command. (/opt/siren-investigate/src/cli/serve/serve.js:153:7)

---

<div class="post-metadata">

**Author:** ![JamesMcGee](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@JamesMcGee](https://community.siren.io/u/JamesMcGee)\
**Post date:** [May 23, 2022, 12:32pm UTC](https://community.siren.io/t/web-services-plugins-error-12-1/495/4 "2022-05-23T12:32:45Z")

</div>

It’s the same error across all web scrips. I even used the default one (weather) and it does the same thing.

---

<div class="post-metadata">

**Author:** ![JamesMcGee](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@JamesMcGee](https://community.siren.io/u/JamesMcGee)\
**Post date:** [May 23, 2022, 12:59pm UTC](https://community.siren.io/t/web-services-plugins-error-12-1/495/5 "2022-05-23T12:59:16Z")

</div>

I double checked the code. Seems fine and works when invoked… Any ideas?

---

<div class="post-metadata">

**Author:** ![Fabio\_Corneti](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.siren.io/fabio_corneti/32/97_2.png) [@Fabio\_Corneti](https://community.siren.io/u/Fabio_Corneti)\
**Post date:** [May 23, 2022, 1:06pm UTC](https://community.siren.io/t/web-services-plugins-error-12-1/495/6 "2022-05-23T13:06:35Z")

</div>

The issue is likely caused by this line in the index file of the plugin:

```auto
module.exports = web_service_interface_1.registerServices('group', [ServiceName.default])

```

Removing `.default` would likely fix the issue, however this type of import should be handled out of the box, so there must be an issue preventing the recognition, we are currently investigating.

Ae you running Investigate on Docker or on a plain machine?

---

<div class="post-metadata">

**Author:** ![JamesMcGee](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@JamesMcGee](https://community.siren.io/u/JamesMcGee)\
**Post date:** [May 23, 2022, 1:18pm UTC](https://community.siren.io/t/web-services-plugins-error-12-1/495/7 "2022-05-23T13:18:07Z")

</div>

My index file looks like this:  
“use strict”;  
import { registerServices } from ‘@sirensolutions/web-service-interface’;  
import { MyWeatherService } from ‘./src/MyWeatherService’;  
export default registerServices(‘weather’, [MyWeatherService]);

Running on a plain VM

---

<div class="post-metadata">

**Author:** ![JamesMcGee](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@JamesMcGee](https://community.siren.io/u/JamesMcGee)\
**Post date:** [May 23, 2022, 1:21pm UTC](https://community.siren.io/t/web-services-plugins-error-12-1/495/8 "2022-05-23T13:21:10Z")

</div>

Inside the src folder it looks like this:

“use strict”  
import { ServiceDefinition, WebServiceError } from ‘@sirensolutions/web-service-interface’;  
import axios from ‘axios’;

export class MyWeatherService extends ServiceDefinition {  
name = ‘weatherservice’;  
inputSchema = {  
city\_name: {  
type: ‘text’,  
description: ‘name of the city to get weather information for’,  
required: true  
}  
};  
outputConfiguration = {  
weather: {  
name: ‘keyword’,  
main: ‘text’,  
location: ‘geo\_point’,  
temperature: ‘long’  
}  
};  
// Called to invoke the service. The inputs argument will have fields described in this.inputSchema  
async invoke(inputs) {  
// The API endpoint to send a query to  
const url = '[https://api.openweathermap.org/data/2.5/weather?’;](https://api.openweathermap.org/data/2.5/weather?';)

```
// Parameters are added to the end of a URL:
// E.g. https://api.openweathermap.org/data/2.5/weather?q=London&appid=<your-api-key>
const params = {
  q: inputs.city_name,
  appid: 'API' 
}
const headers = {
  'Content-Type': 'application/json'
}

// The axios library is used here, but you can use a different library/implementation for querying an API
const response = await axios.get(url, { params, headers })
  .catch(error => Promise.reject(error.response && error.response.status < 500 ? new WebServiceError(error.response.data) : error)); 

// Must return objects with the same structure as in this.outputConfiguration. These are stored in Elasticsearch automatically.
return {
  weather: [{
    name: response.data.name,
    main: response.data.weather[0].main,
    location: response.data.coord,
    temperature: response.data.main.temp
}]};

```

}  
}

---

<div class="post-metadata">

**Author:** ![JamesMcGee](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@JamesMcGee](https://community.siren.io/u/JamesMcGee)\
**Post date:** [May 23, 2022, 1:24pm UTC](https://community.siren.io/t/web-services-plugins-error-12-1/495/9 "2022-05-23T13:24:59Z")

</div>

Standing by. Thanks Fabio!

---

<div class="post-metadata">

**Author:** ![Fabio\_Corneti](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.siren.io/fabio_corneti/32/97_2.png) [@Fabio\_Corneti](https://community.siren.io/u/Fabio_Corneti)\
**Post date:** [May 23, 2022, 1:27pm UTC](https://community.siren.io/t/web-services-plugins-error-12-1/495/10 "2022-05-23T13:27:11Z")

</div>

Thanks for the info, this looks like an issue with the transpiler when processing plugins that were not produced by the generator tool, will get back to you if there’s a workaround, otherwise we’ll put a fix in 12.1.1 .

---

<div class="post-metadata">

**Author:** ![JamesMcGee](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@JamesMcGee](https://community.siren.io/u/JamesMcGee)\
**Post date:** [May 23, 2022, 1:34pm UTC](https://community.siren.io/t/web-services-plugins-error-12-1/495/11 "2022-05-23T13:34:00Z")

</div>

Thanks! Really hope you can find a workaround. Can’t have it not working…

---

<div class="post-metadata">

**Author:** ![JamesMcGee](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@JamesMcGee](https://community.siren.io/u/JamesMcGee)\
**Post date:** [May 23, 2022, 4:14pm UTC](https://community.siren.io/t/web-services-plugins-error-12-1/495/12 "2022-05-23T16:14:34Z")

</div>

Fabio,

I found a way around it. Just added it to the default section in siren\_web\_services. Works like a charm. Thanks!

---

<div class="post-metadata">

**Author:** ![Fabio\_Corneti](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.siren.io/fabio_corneti/32/97_2.png) [@Fabio\_Corneti](https://community.siren.io/u/Fabio_Corneti)\
**Post date:** [May 23, 2022, 6:03pm UTC](https://community.siren.io/t/web-services-plugins-error-12-1/495/13 "2022-05-23T18:03:25Z")

</div>

Hi James,  
another workaround would be to replace `src/server/plugins/plugin_collection.js` with the full contents of the gist below, then the plugins should run unchanged.

> <https://gist.github.com/fabiocorneti/4719f8149cf7573e4d961eb79b8340fe>
