Openfire Plugin: Null Pointer Exception when trying to get the instance of the plugin - plugins

I'm developing a plugin for openfire.
From the jsp, I'm using getters and setters to transfer data.
My problem is similar to the problem mentioned here:
https://community.igniterealtime.org/message/155892#155892
I have been trying to figure it out from a week.
I have the following code:
<%# page
import="org.jivesoftware.openfire.XMPPServer,
de.meisterfuu.openfire.plugin.teamFantasian_UserServicePlugin,
org.jivesoftware.util.ParamUtils,
org.jivesoftware.openfire.container.Plugin,
org.jivesoftware.util.*,
java.util.*,
java.util.HashMap,
java.util.Map"
errorPage="error.jsp"%>
<%# taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%# taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt"%>
<%
boolean save = request.getParameter("save") != null;
String pNameSpace = ParamUtils.getParameter(request, "pNameSpace");
String pModule = ParamUtils.getParameter(request, "pModule");
String pCreateUser = ParamUtils.getParameter(request, "pCreateUser");
String pCreateUser_input = ParamUtils.getParameter(request, "pCreateUser_input");
String pCreateUser_output = ParamUtils.getParameter(request, "pCreateUser_output");
teamFantasian_UserServicePlugin plugin = (teamFantasian_UserServicePlugin) XMPPServer.getInstance().getPluginManager().getPlugin("teamFantasian_UserServicePlugin");
Collection<Plugin> a = XMPPServer.getInstance().getPluginManager().getPlugins();
out.write(Arrays.toString(a.toArray()));
if(plugin == null) {
out.println("Cant find plugin ..!!");
return;
}
And this is my directory structure:
/home/manoj/final/Openfire/src/plugins/teamFantasian_UserServicePlugin
|-- lib
| |-- asm-3.1.jar
| |-- commons-pool2-2.0.jar
| |-- fluent-hc-4.3.2.jar
| |-- httpclient-4.3.3.jar
| |-- httpcore-4.3.2.jar
| |-- jackson-core-asl-1.9.2.jar
| |-- jackson-jaxrs-1.9.2.jar
| |-- jackson-mapper-asl-1.9.2.jar
| |-- jackson-xc-1.9.2.jar
| |-- jedis-2.4.2.jar
| |-- jersey-bundle-1.18.jar
| |-- jersey-servlet-1.18.jar
| |-- jettison-1.1.jar
| `-- jsr311-api-1.1.1.jar
|-- logo_large.gif
|-- logo_small.gif
|-- plugin.xml
|-- readme.html
`-- src
|-- i18n
| `-- teamFantasian_UserServicePlugin_i18n.properties
|-- java
| `-- de
| `-- meisterfuu
| `-- openfire
| `-- plugin
| |-- teamFantasian_UserServicePlugin.java
| `-- UserServiceHelper.java
`-- web
|-- images
| |-- error-16x16.gif
| `-- success-16x16.gif
`-- teamFantasian_UserServicePlugin.jsp
10 directories, 24 files

Don't use underscores for your plugin name.
Rename your Plugin to teamFantasianUserServicePlugin.
And get the Instance with:
XMPPServer.getInstance().getPluginManager().getPlugin("teamfantasianuserserviceplugin");
The plugin name should be lowercase.

Related

How to use foreignkey outside current model when migrate using aerich?

Following is the structure of my project.
|-- apps
| |-- user
| | |-- models.py
| |-- post
| | |-- models.py
|-- db
| | |-- database.py
Here is database.py
TORTOISE_ORM = {
"connections": {"default": f"mysql://user:password#127.0.0.1:3306/blog"},
"apps": {
"models": {
"models": ["apps.user.models", "apps.post.models", "aerich.models"],
"default_connection": "default",
},
}
}
In post/models.py, I need to define a user field which has a ForeignKeyField in user/models.py
class Article(MyAbstractBaseModel):
author = fields.ForeignKeyField(model_name="user.models", related_name='article')
As I am doing the migration by
1. aerich init -t db.database.TORTOISE_ORM
2. aerich init-db
It gives me an error
tortoise.exceptions.ConfigurationError: No app with name 'user' registered.
Anyone knows how can I fix this? Thanks in advance.

Openstack API not providing precise data

I am using Openstack - Stein in CentOS 7.9
I was using python to collect data about the openstack nova performance, like server names and id in the openstack project, i have 3 instance(server) created, i can see all three instance in openstack cli, but when i connect to api mentioned in openstack, it provides no data or less data.
I refereed openstack documentation here
[root#centos-vm1 kavin(keystone_admin)]# openstack server list
+--------------------------------------+-----------------+--------+----------------------------------------+-------+----------+
| ID | Name | Status | Networks | Image | Flavor |
+--------------------------------------+-----------------+--------+----------------------------------------+-------+----------+
| 08cf6226-0303-4b4c-ba53-10af79b81dae | test_instance_3 | ACTIVE | test_networ_3=10.150.0.8 | | m1.tiny |
| 9986f205-82b3-4cbb-bcdc-fb32eab97c83 | test_instance_1 | ACTIVE | test_networ_2=10.100.0.5, x.x.x.x | | m1.small |
| d1c0f520-8540-432c-8fe1-554390fd79bf | test_instance_2 | ACTIVE | test_networ_1=10.50.0.8 | | m1.small |
+--------------------------------------+-----------------+--------+----------------------------------------+-------+----------+
My python code:
import requests,json
from six.moves.urllib.parse import urljoin
identity = {
"methods": ["password"],
"password": {
"user": {
"name": "admin",
"domain": { "id": "default" },
"password": "xxxxxxxxxxxxxxx"
}
}
}
OS_AUTH_URL = 'http://x.x.x.x:5000/v3'
data = {'auth': {'identity': identity}}
HEADERS = {'Content-Type': 'application/json', 'scope': 'unscoped'}
r = requests.post(
OS_AUTH_URL+'/auth/tokens',
headers = HEADERS,
json = data,
verify = False
)
auth_token = r.headers['X-Subject-Token'] # i got auth token
# server list
NOVA_URL="http://x.x.x.x:8774/v2.1"
HEADERS = {"X-Auth-Token" : str(auth_token)}
r = requests.get(
NOVA_URL+'/servers',
headers = HEADERS,
)
r.raise_for_status()
print(r.json())
Output :
{'servers': []}
help me, collect accurate data using api calls, thanks
According to api-ref List Servers doc, maybe you should add the project scope in the request.
By default the servers are filtered using the project ID associated with the authenticated request.
In my opinion, you could use openstacksdk to execute the operation, simply with the Connection object and list_servers method.
import openstack
conn = openstack.connect(
region_name='example-region',
auth_url='http://x.x.x.x:5000/v3/',
username='amazing-user',
password='super-secret-password',
project_id='33...b5',
domain_id='05...03'
)
servers = conn.list_servers()

Spark Structured Stream qubole Kinesis connector errors out with "Got an exception while fetching credentials"

I am using the following code to write to Kinesis from a spark structured stream code. It errors out with following error. The AWS credentials have admin access. I am able to use aws console using that. What could be the issue here?
22/03/16 13:46:34 ERROR AWSInstanceProfileCredentialsProviderWithRetries: Got an exception while fetching credentials org.apache.spark.sql.kinesis.shaded.amazonaws.SdkClientException: Unable to load credentials from service endpoint
val finalDF = rawDF.select(expr("CAST(rand() AS STRING) as partitionKey"),
to_json(struct("*")).alias("data"))
finalDF.printSchema()
val query = finalDF.writeStream
.outputMode("update")
.format("kinesis")
.option("streamName", "sparkstream2")
.option("endpointUrl", "https://kinesis.us-east-1.amazonaws.com")
.option("region", "us-east-1")
.option("awsAccessKey", "") // Creds removed
.option("awsSecretKey", "") // Creds removed
.option("checkpointLocation", "chk-point-dir")
.start()
query.awaitTermination()
spark.stop()
Printschema output looks as follows
root
|-- partitionKey: string (nullable = false)
|-- data: string (nullable = true)
I am using the connector from qubole
https://github.com/qubole/kinesis-sql
I had this issue too - add on .option("awsUseInstanceProfile", "false"). The kinesis-sql package doesn't handle AWS credentials by default as one would expect. I found this GitHub issue for a lead here.

The value supplied for parameter 'instanceProfileName' is not valid

Running cdk deploy I receive the following error message:
CREATE_FAILED | AWS::ImageBuilder::InfrastructureConfiguration | TestInfrastructureConfiguration The value supplied for parameter 'instanceProfileName' is not valid. The provided instance profile does not exist. Please specify a different instance profile and try again. (Service: Imagebuilder, Status Code: 400, Request ID: 41f431d7-8544-48e9-9faf-a870b83b0100, Extended Request ID: null)
The C# code looks like this:
var instanceProfile = new CfnInstanceProfile(this, "TestInstanceProfile", new CfnInstanceProfileProps {
InstanceProfileName = "test-instance-profile",
Roles = new string[] { "TestServiceRoleForImageBuilder" }
});
var infrastructureConfiguration = new CfnInfrastructureConfiguration(this, "TestInfrastructureConfiguration", new CfnInfrastructureConfigurationProps {
Name = "test-infrastructure-configuration",
InstanceProfileName = instanceProfile.InstanceProfileName,
InstanceTypes = new string[] { "t2.medium" },
Logging = new CfnInfrastructureConfiguration.LoggingProperty {
S3Logs = new CfnInfrastructureConfiguration.S3LogsProperty {
S3BucketName = "s3-test-assets",
S3KeyPrefix = "ImageBuilder/Logs"
}
},
SubnetId = "subnet-12f3456f",
SecurityGroupIds = new string[] { "sg-12b3e4e5b67f8900f" }
});
The TestServiceRoleForImageBuilder exists and was working previously. Same code was running successfully about a month ago. Any suggestions?
If I remove the CfninfrastructureConfiguration creation part, deployment runs successfully:, but takes at least 2 minutes to complete.
AwsImageBuilderStack: deploying...
AwsImageBuilderStack: creating CloudFormation changeset...
0/3 | 14:24:37 | REVIEW_IN_PROGRESS | AWS::CloudFormation::Stack | AwsImageBuilderStack User Initiated
0/3 | 14:24:43 | CREATE_IN_PROGRESS | AWS::CloudFormation::Stack | AwsImageBuilderStack User Initiated
0/3 | 14:24:47 | CREATE_IN_PROGRESS | AWS::CDK::Metadata | CDKMetadata/Default (CDKMetadata)
0/3 | 14:24:47 | CREATE_IN_PROGRESS | AWS::IAM::InstanceProfile | TestInstanceProfile
0/3 | 14:24:47 | CREATE_IN_PROGRESS | AWS::IAM::InstanceProfile | TestInstanceProfile Resource creation Initiated
1/3 | 14:24:48 | CREATE_IN_PROGRESS | AWS::CDK::Metadata | CDKMetadata/Default (CDKMetadata) Resource creation Initiated
1/3 | 14:24:48 | CREATE_COMPLETE | AWS::CDK::Metadata | CDKMetadata/Default (CDKMetadata)
1/3 Currently in progress: AwsImageBuilderStack, TestInstanceProfile
3/3 | 14:26:48 | CREATE_COMPLETE | AWS::IAM::InstanceProfile | TestInstanceProfile
3/3 | 14:26:49 | CREATE_COMPLETE | AWS::CloudFormation::Stack | AwsImageBuilderStack
Is it probably some race condition? Should I use multiple stacks to achieve my goal?
Should it be possible to use a wait condition (AWS::CloudFormation::WaitCondition) to bypass the 2 minutes of creation time in case it is intended (AWS::IAM::InstanceProfile resources always take exactly 2 minutes to create)?
Environment
CDK CLI Version: 1.73.0
Node.js Version: 14.13.0
OS: Windows 10
Language (Version): C# (.NET Core 3.1)
Update
Since the cause seems to be AWS internal, I used a pre-created instance profile as a workaround. The profile can be either created through IAM Management Console or CLI. However it would be nice to have a proper solution.
You have to create a dependency between the two constructs. CDK does not infer it when using the optional name parameter, as opposed to the logical id (which doesn't seem to work in this situation).
infrastructureConfiguration.node.addDependency(instanceProfile)
Here are the relevant docs: https://docs.aws.amazon.com/cdk/api/latest/docs/core-readme.html#construct-dependencies

how to handle output files in parcel

I have a project with this structure:
src
|- index.pug
| - layout
| |- index.less
| - scripts
| |- index.js
For now, when I run parcel build src/index.pug, all the files are bundled and I've got this on the distribution folder:
dist
|- index.html
|- index.12345.css
|- index.12345.js
When I was expected something like:
ist
|- index.html
|- layout
| |- index.12345.css
|- scripts
| |- index.12345.js
So, my question is: Can I specify the output path for my CSS, js, and images using ParcelJS?
Unfortunately, this isn't supported out-of-the box by parcel. Parcel v1 you can use this plugin. For parcel v2, it is possible to write a namer plugin that accomplishes this.
Here's the code (in typescript):
import { Namer } from "#parcel/plugin";
import type { Bundle } from "#parcel/types";
import path from "path";
export default new Namer({
name({ bundle }) {
switch (bundle.type) {
case "js":
return getPathWithFolder("scripts", bundle);
case "less":
return getPathWithFolder("layout", bundle);
case "css":
return getPathWithFolder("layout", bundle);
default:
return null;
}
},
});
function getPathWithFolder(folderName: string, bundle: Bundle): string | null {
const filePath = bundle.getMainEntry()?.filePath;
if (!filePath) return null;
let nameWithoutExtension = path.basename(filePath, path.extname(filePath));
if (!bundle.needsStableName) {
// See: https://parceljs.org/plugin-system/namer/#content-hashing
nameWithoutExtension += "." + bundle.hashReference;
}
return `${folderName}/${nameWithoutExtension}.${bundle.type}`;
}
Then, supposing the above code was published in a package called parcel-namer-folders, you would add it to your parcel pipeline with this .parcelrc:
{
"extends": "#parcel/config-default",
"namers": ["parcel-namer-folders", "..."]
}
Here is an example repo where this is working.