Author Archives: Robins

React Native Project Run Error [How to Solve]

React native version: 0.67

Initialize and run the project according to the official document

$ npx react-native init AwesomeProject
$ yarn ios

The error message is as follows

The following build commands failed: 
	PhaseScriptExecution [CP-User]\ Generate\ Specs /Users/zh/Library/Developer/Xcode/DerivedData/AwesomeProject-cvxgkvyxvvajjvaydcivldmzlgxr/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-5F4C70EF7D90A5A5BDAEB404279F232A.sh (in target 'FBReactNativeSpec' from project 'Pods') (1 failure)

Possible causes

  1. The project path contains white space characters
  2. NVM is used for node installation

I’m because of reason 2. The solution is to go to node_modules/react-native/scripts/find-node. SH, comment out this part of the file

if [[ -s "$HOME/.nvm/nvm.sh" ]]; then
   # shellcheck source=/dev/null
   . "$HOME/.nvm/nvm.sh"
 elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then
   # shellcheck source=/dev/null
   . "$(brew --prefix nvm)/nvm.sh"
 fi

Then execute yarn IOS , and the execution will be successful

[Solved] Azure Python SDK Error: The resource principal named https://management.azure.com was not found in the tenant China Azure

Problem description

When using the python SDK, when logging in to China azure (mooncake) and accessing the alertsmanagement resources, you often encounter the error message “environmentcredential: authentication failed”.

Python code:

from azure.identity import DefaultAzureCredential
from azure.mgmt.alertsmanagement import AlertsManagementClient

# Acquire a credential object using CLI-based authentication.
credential = DefaultAzureCredential()
subscription_id = "xxxx-xxxx-xxxx-xxxx-xxxx"

alertClient = AlertsManagementClient(credential,subscription_id,base_url="https://management.chinacloudapi.cn/")

rules = alertClient.smart_detector_alert_rules.list()
for rule in rules:
    print("Rule Name: " + rule.name)

Error message:

PS C:\LBWorkSpace\MyCode\46-alertrule-python> python getrule.py
DefaultAzureCredential failed to retrieve a token from the included credentials.
Attempted credentials:
        EnvironmentCredential: Authentication failed: AADSTS500011: The resource principal named https://management.azure.com was not found in the tenant named xxx Mooncake. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You might have sent your authentication request to the wrong tenant.
Trace ID: xxxxxxxx-xxxx-xxxx-xxxx-9e130dbf7900
Correlation ID: xxxxxxxx-xxxx-xxxx-xxxx-46769c9e1e10
Timestamp: 2022-01-27 12:09:35Z
To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot.
Traceback (most recent call last):
  File "C:\LBWorkSpace\MyCode\46-alertrule-python\getrule.py", line 15, in <module>
    for rule in rules:
  File "C:\Users\bulu\AppData\Local\Programs\Python\Python310\lib\site-packages\azure\core\paging.py", line 129, in __next__
    return next(self._page_iterator)
  File "C:\Users\bulu\AppData\Local\Programs\Python\Python310\lib\site-packages\azure\core\paging.py", line 76, in __next__
    self._response = self._get_next(self.continuation_token)
  File "C:\Users\bulu\AppData\Local\Programs\Python\Python310\lib\site-packages\azure\core\pipeline\policies\_redirect.py", line 158, in send
    response = self.next.send(request)
  File "C:\Users\bulu\AppData\Local\Programs\Python\Python310\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 445, in send
    response = self.next.send(request)
  File "C:\Users\bulu\AppData\Local\Programs\Python\Python310\lib\site-packages\azure\core\pipeline\policies\_authentication.py", line 117, in send
    self.on_request(request)
  File "C:\Users\bulu\AppData\Local\Programs\Python\Python310\lib\site-packages\azure\core\pipeline\policies\_authentication.py", line 94, in on_request
    self._token = self._credential.get_token(*self._scopes)
  File "C:\Users\bulu\AppData\Local\Programs\Python\Python310\lib\site-packages\azure\identity\_credentials\default.py", line 172, in get_token
    return super(DefaultAzureCredential, self).get_token(*scopes, **kwargs)
  File "C:\Users\bulu\AppData\Local\Programs\Python\Python310\lib\site-packages\azure\identity\_credentials\chained.py", line 108, in get_token
    raise ClientAuthenticationError(message=message)
azure.core.exceptions.ClientAuthenticationError: DefaultAzureCredential failed to retrieve a token from the included credentials.
Attempted credentials:
        EnvironmentCredential: Authentication failed: AADSTS500011: The resource principal named https://management.azure.com was not found in the tenant named xxxx Mooncake. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You might have sent your authentication request to the wrong tenant.
Trace ID: xxxxxxxx-xxxx-xxxx-xxxx-9e130dbf7900
Correlation ID: xxxxxxxx-xxxx-xxxx-xxxx-46769c9e1e10
Timestamp: 2022-01-27 12:09:35Z
To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot.

Problem-solving:

From the error message https://management.azure.com, we know that the problem is due to the default value of Resource Principal used in AlertsManagementClient, which was not changed to base_url with the specification of

https://management.chinacloudapi.cn/ . The problem can be mitigated by specifying credential_scopes as [“https://management.chinacloudapi.cn/.default”] when constructing the AlertsManagementClient object.
The modified code is :

# pre:
alertClient = AlertsManagementClient(credential,subscription_id,base_url="https://management.chinacloudapi.cn/")

# new:
alertClient = AlertsManagementClient(credential,subscription_id,base_url="https://management.chinacloudapi.cn/",credential_scopes=["https://management.chinacloudapi.cn/.default"])

PS: when creating client objects of other resources, if you encounter the same principal problem, you can set credential_Scopes to solve the problem.

The complete code that can travel far is:

# Import the needed credential and management objects from the libraries.
from azure.identity import DefaultAzureCredential
from azure.mgmt.alertsmanagement import AlertsManagementClient

# Acquire a credential object using CLI-based authentication.
credential = DefaultAzureCredential()
subscription_id = "a9dc7515-7692-4316-9ad4-762f383eec10"

# # pre:
# alertClient = AlertsManagementClient(credential,subscription_id,base_url="https://management.chinacloudapi.cn/")
# Modified:
alertClient = AlertsManagementClient(credential,subscription_id,base_url="https://management.chinacloudapi.cn/",credential_scopes=["https://management.chinacloudapi.cn/.default"])



rules = alertClient.smart_detector_alert_rules.list()
for rule in rules:
    print("Rule Name: " + rule.name)

Operation results:

The correct MonitorManagementClient object to get metric_alerts and activity_log_alerts Get Alert Rule code

from azure.mgmt.monitor import MonitorManagementClient
from azure.identity import DefaultAzureCredential
from msrestazure.azure_cloud import AZURE_CHINA_CLOUD as CLOUD
import os


os.environ["SUBSCRIPTION_ID"] = "xxxxxxyour-subidxxxxxx"
os.environ["AZURE_TENANT_ID"] = "your tenant idxxxxx"
os.environ["AZURE_CLIENT_ID"]  = "client_id_sp"
os.environ["AZURE_CLIENT_SECRET"]  = "pw_sp"
subscription_id = os.environ["SUBSCRIPTION_ID"]

credential = DefaultAzureCredential(authority=CLOUD.endpoints.active_directory)

# create client
client1 = MonitorManagementClient(
    credential,
    subscription_id,
    base_url=CLOUD.endpoints.resource_manager,
    credential_scopes=[CLOUD.endpoints.resource_manager + "/.default"]
)

#classic
my_alerts1 = client1.alert_rules.list_by_subscription()

for j in my_alerts1:
    print(j)

#log search alerts
client2 = MonitorManagementClient(
    credential,
    subscription_id,
    base_url=CLOUD.endpoints.resource_manager,
    credential_scopes=[CLOUD.endpoints.resource_manager + "/.default"]
)
my_alerts2 = client2.scheduled_query_rules.list_by_subscription()
for j in my_alerts2:
    print(j)

#activity alerts
client3 = MonitorManagementClient(
    credential,
    subscription_id,
    base_url=CLOUD.endpoints.resource_manager,
    credential_scopes=[CLOUD.endpoints.resource_manager + "/.default"],
    api_version="2017-04-01"
)

my_alerts3 = client3.activity_log_alerts.list_by_subscription_id()
for j in my_alerts3:
    print(j)

#metric alerts
client4 = MonitorManagementClient(
    credential,
    subscription_id,
    base_url=CLOUD.endpoints.resource_manager,
    credential_scopes=[CLOUD.endpoints.resource_manager + "/.default"]
)

my_alerts4 = client4.metric_alerts.list_by_subscription()
for j in my_alerts4:
    print(j)

Outcome:

[Solved] Homebrew curl: (60) SSL certificate problem: certificate has expired

1. Problem description

Homebrew has a problem installing GIT

curl: (60) SSL certificate problem: certificate has expired More details here: https://curl.haxx.se/docs/sslcerts.html
If you'd like to turn off curl's verification of the certificate, use the -k (or --insecure) option. 
HTTPS-proxy has similar options --proxy-cacert and --proxy-insecure.
Error: Failed to download resource "pcre2"

Probably because homebrew has not been updated for a long time, the local certificate has expired.

2. Solution

echo insecure >> ~/.curlrc
HOMEBREW_CURLRC=1
export HOMEBREW_CURLRC
#brew install git

 

WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! [How to Fix]

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:36vsuYywBZkJ0W04SmMFKgSPvJk/FoUTCOkIytwSS1I.
Please contact your system administrator.
Add correct host key in /c/Users/86131/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /c/Users/86131/.ssh/known_hosts:21
ECDSA host key for 106.52.223.232 has changed and you have requested strict checking.
Host key verification failed.

If you encounter this problem, you only need to execute

vi ~/.ssh/known_hosts

Then delete the connection IP information. For example, if I connect to 106.52.223.232, I will delete the IP information

[Solved] oracle Execute netca Error: UnsatisfiedLinkError exception loading native library: njni11

@Write at the beginning: after testing, this kind of problem occurs when centos8 installs Oracle 11g R2

@There will also be no response after lsnrctl start. After checking the lsnrctl file, it is found that the file is also 0kb

@It may be a compatibility problem. It is recommended to install Oracle help center with the system recommended by Oracle

1. Execute netca/silent/responsefile/data/Oracle/response/netca RSP error unsatisfiedlinkerror exception loading native library: njni11

[oracle@oracle ~]$ netca /silent /responsefile /datas/oracle/response/netca.rsp
UnsatisfiedLinkError exception loading native library: njni11
java.lang.UnsatisfiedLinkError: /datas/oracle/product/11.2.0/db_1/lib/libnjni11.so: /datas/oracle/product/11.2.0/db_1/lib/libclntsh.so.11.1: file too short
java.lang.UnsatisfiedLinkError: jniGetOracleHome
	at oracle.net.common.NetGetEnv.jniGetOracleHome(Native Method)
	at oracle.net.common.NetGetEnv.getOracleHome(Unknown Source)
	at oracle.net.ca.NetCALogger.getOracleHome(NetCALogger.java:230)
	at oracle.net.ca.NetCALogger.initOracleParameters(NetCALogger.java:215)
	at oracle.net.ca.NetCALogger.initLogger(NetCALogger.java:130)
	at oracle.net.ca.NetCA.main(NetCA.java:404)

Error: jniGetOracleHome
Oracle Net Services configuration failed.  The exit code is 1

2. View/data/Oracle/product/11.2.0/db_1/lib/libclntsh.so.11.1 documents found 0kb

3. Find libclntsh.so.11.1 file In the system (the installation information directory orainventory happens to exist)

find/-name libclntsh.so.11.1

4. Cover the damaged libclntsh.so.11.1 documents

cp /datas/oracle/product/11.2.0/db_1/inventory/backup/2021-04-27_02-37-24PM/Scripts/ext/lib/libclntsh.so.11.1 /datas/oracle/product/11.2.0/db_1/lib/libclntsh.so.11.1

5. Execute the netca command again and solve the problem successfully

[Solved] Linux-SSH: WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED

Linux-SSH:WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED solution:

ssh 192.168.21.53:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending key in /root/.ssh/known_hosts:1
RSA host key for 192.168.xxx.xxx has changed and you have requested strict checking.
Host key verification failed.

First input more ~/.ssh/known_hosts
You will see the following content:
… … … …
192.168.21.53 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDQ25kqKE1uT7wtcaFp3zFSMxpwweif0YcKMNmpp4Alql/ZmPHaS/fI1dmXxyzq77wj8uXJgkh7xF0doyFeBk1c8D7jG/5SkAdpwlh6uixYEI3SlRY96InnQd/zEqRGjMvwoEcSmdMdkRsrK5EkPblhDfsQgc5RwKJpkQ+GWXM7oibHZB/P/G2Husnwb0rSwIRvUkwfamM9wDBtA3nEZLcG6wScwm2sZ8SwL9eJMNJXRHR90vewQ6MVrv+k5kB+BSrJ92TH8uZP3R9oO4X6tvRKNZOubQJqKqPDujVrTCD9XnMDb+Mx0yKMqvoGoVBM7fnZMGWtTHBkacsyYSiXaJrV
vi ~/.ssh/known_hosts, edit this file, delete the content beginning with 192.168.21.53, :wq! save and exit can be.

Cause Analysis:
It is also possible that a host key has just been changed.

[Solved] No qualifying bean of type ‘org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder’ available:

DEBUG o.s.b.diagnostics.LoggingFailureAnalysisReporter – Application failed to start due to an exception

org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1493)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1104)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
        at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
        at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1080)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:857)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)

Solution:

Add the following jar pack”

		<dependency>
   			<groupId>org.springframework.boot</groupId>
   			<artifactId>spring-boot-starter-data-jpa</artifactId>
   			<version>${springboot.version}</version>
		</dependency>

Version can be the springboot version of your own project. The problem is solved!

How to Solve DbVisualizer Error: Could not read XML file

Database connection tool is a daily tool for our software test engineers. Once we report some inexplicable errors at the critical moment, I believe we are very distressed
of course, companies have different database connection tools, such as dbvisualizer, PLSQL, sqldeveloper, toad for SQL Server/MySQL and so on
now I’d like to introduce an annoying and inexplicable error reporting and solution of my dbvisualizer.

The following error occurred while opening dbvisualizer:

Error message: Could not read XML file: C:\Users\lxw\.dbvis\config70\dbvis.xml Error is: Error on line 1: no content is allowed in the preface

Solution:

1. Follow the above path to find dbvis.xml

2. After opening, you will find two files:
First File: dbvis.xml
Second File: dbvis.xml.bak

3. Back up dbvis.xml.bak file and rename dbvis.xml.bak to dbvis.xml is OK

How to Solve Mybatis generator Execute Error

Generator version

<!-- MyBatis -->
    <dependency>
      <groupId>org.mybatis.generator</groupId>
      <artifactId>mybatis-generator-core</artifactId>
      <version>1.3.3</version>
    </dependency>

Error reporting information

Solution:

The current version of generator is due to org mybatis. The version of generator is too low and needs to be upgraded to 1.3.7

[Solved] Nginx-FastCGI-“Primary script unknown” while reading response header from upstream,

After adding fastcgi support to nginx, verify the PHP page and report an error file not found. Check the log display

FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream,

At first, I thought it was a permission problem, so I started to configure it first

location  ~ \.php$ {
          root  /data/nginx/html/php;
          default_type text/html;
          fastcgi_pass  127.0.0.1:9000;
          fastcgi_index  index.php;
          #fastcgi_param  SCRIPT_FILENAME /data/nginx/php$fastcgi_script_name;
          fastcgi_param   SCRIPT_FILENAME  $document_root$fastcgi_script_name;   //error
          fastcgi_param   SCRIPT_FILENAME  $document_root$fastcgi_script_name;
          include  fastcgi_params;
       }

It looks like the configuration is the same, in fact, there is a w problem here, I am a direct copy of win to linux,, using nginx -t file is OK, not detected at all, you can download the WinMerge file to compare the upper and lower lines, you can also cat -A detect win spaces.