问:
'UICollectionView must be initialized with a non-nil layout parameter' bug
I'm initializing a UICollectionViewController in SceneDelegate:

```<code>func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
    guard let windowScene = (scene as? UIWindowScene) else { return }

    let window = UIWindow(windowScene: windowScene)
    let tabBarVC = AppTabBarController()

    // I init with a layout here
    let collectionVC = CollectionViewController(collectionViewLayout: UICollectionViewFlowLayout())

    collectionVC.tabBarItem = UITabBarItem(tabBarSystemItem: .favorites, tag: 2)
    tabBarVC.viewControllers = [collectionVC]
    let navigationController = UINavigationController(rootViewController: tabBarVC)

    window.rootViewController = navigationController
    window.makeKeyAndVisible()

    self.window = window
}
</code>```

Then I have my UICollectionViewController class:

```<code>class CollectionViewController: UICollectionViewController {

    private let searchController = UISearchController(searchResultsController: UICollectionViewController())

    override func viewDidLoad() {
        super.viewDidLoad()

        searchController.searchResultsUpdater = self
        searchController.automaticallyShowsSearchResultsController = true
        searchController.obscuresBackgroundDuringPresentation = true

        collectionView.delegate = self
        collectionView.dataSource = self
        collectionView.register(CollectionViewCell.self, forCellWithReuseIdentifier: CollectionViewCell.reuseID)
        collectionView.keyboardDismissMode = .onDrag
        collectionView.reloadData()

        let refreshControl = UIRefreshControl()
        refreshControl.addTarget(self, action:  #selector(refreshData), for: .valueChanged)
        collectionView.refreshControl = refreshControl
    }
}
</code>```

I initialize my CVC with a layout but I still have the nil layout error which doesn't make any sense:

Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: 'UICollectionView must be
initialized with a non-nil layout parameter'

答:
According to the docs , these are the valid initializers for a UICollectionViewController

init(collectionViewLayout: UICollectionViewLayout)

init(nibName: String?, bundle: Bundle?)

init?(coder: NSCoder)

In your scene delegate, this is done fine:

```<code>let collectionVC
    = CollectionViewController(collectionViewLayout: UICollectionViewFlowLayout())
</code>```

However, in your CollectionViewController, you don't use any of the viable initializers when initializing UISearchController

```<code>private let searchController
    = UISearchController(searchResultsController: UICollectionViewController())
</code>```

I believe it is this UICollectionViewController you are trying to instantiate with an invalid initializer that is causing your problems

Body:
I'm initializing a UICollectionViewController in SceneDelegate:

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
    guard let windowScene = (scene as? UIWindowScene) else { return }

    let window = UIWindow(windowScene: windowScene)
    let tabBarVC = AppTabBarController()

    // I init with a layout here
    let collectionVC = CollectionViewController(collectionViewLayout: UICollectionViewFlowLayout())

    collectionVC.tabBarItem = UITabBarItem(tabBarSystemItem: .favorites, tag: 2)
    tabBarVC.viewControllers = [collectionVC]
    let navigationController = UINavigationController(rootViewController: tabBarVC)

    window.rootViewController = navigationController
    window.makeKeyAndVisible()

    self.window = window
}

Then I have my UICollectionViewController class:

class CollectionViewController: UICollectionViewController {

    private let searchController = UISearchController(searchResultsController: UICollectionViewController())

    override func viewDidLoad() {
        super.viewDidLoad()

        searchController.searchResultsUpdater = self
        searchController.automaticallyShowsSearchResultsController = true
        searchController.obscuresBackgroundDuringPresentation = true

        collectionView.delegate = self
        collectionView.dataSource = self
        collectionView.register(CollectionViewCell.self, forCellWithReuseIdentifier: CollectionViewCell.reuseID)
        collectionView.keyboardDismissMode = .onDrag
        collectionView.reloadData()

        let refreshControl = UIRefreshControl()
        refreshControl.addTarget(self, action:  #selector(refreshData), for: .valueChanged)
        collectionView.refreshControl = refreshControl
    }
}

I initialize my CVC with a layout but I still have the nil layout error which doesn't make any sense:

Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: 'UICollectionView must be
initialized with a non-nil layout parameter'

Body:
According to the docs , these are the valid initializers for a UICollectionViewController

init(collectionViewLayout: UICollectionViewLayout)

init(nibName: String?, bundle: Bundle?)

init?(coder: NSCoder)

In your scene delegate, this is done fine:

let collectionVC
    = CollectionViewController(collectionViewLayout: UICollectionViewFlowLayout())

However, in your CollectionViewController, you don't use any of the viable initializers when initializing UISearchController

private let searchController
    = UISearchController(searchResultsController: UICollectionViewController())

I believe it is this UICollectionViewController you are trying to instantiate with an invalid initializer that is causing your problems


来源: stackexchange

问:
java.lang.IllegalArgumentException: parseAlgParameters failed: ObjectIdentifier() -- data isn't an object ID (tag = 48)
In my one AWS EC2 server, I deployed three services [Auth, orders, Security]. I configured SSL for three services, The SSL is the same for three services, The Auth orders services working fine after doing some tunning, but the Security service has 'java.lang.IllegalArgumentException: parseAlgParameters failed: ObjectIdentifier() -- data isn't an object ID (tag = 48)' problem.
My Server has below Java Version:
openjdk version "1.8.0_302"
OpenJDK Runtime Environment (build 1.8.0_302-b08)
OpenJDK 64-Bit Server VM (build 25.302-b08, mixed mode)
I deployed my jar files from my windows PC, for my windows PC all three services working fine. but it's an issue with my AWS Centos server.

initially, I converted my .crt file to .p12 with Openssl3, that time all my three services has the above issue. So degraded my OpenSSL to the 1.1.1 version. then build my jars to AWS. So 'Auth' and 'Order' services are started working. but still am having issue in my security service.
below is the pom.xml for authentication.

```<code>    <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.2.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.lc.auth</groupId>
    <artifactId>AuthenticationService</artifactId>
    <version>MVP-V2.0.0</version>
    <name>AuthenticationService</name>
    <description>Authentication Service</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>

        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web-services</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
            <version>8.0.11</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- https://mvnrepository.com/artifact/log4j/log4j -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.11</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>

    <dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>2.4</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-oauth2-jose -->
<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-oauth2-jose</artifactId>
    <version>5.2.3.RELEASE</version>
     <exclusions>
        <exclusion>
            <groupId>com.nimbusds</groupId>
            <artifactId>nimbus-jose-jwt</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/com.nimbusds/nimbus-jose-jwt -->
<dependency>
    <groupId>com.nimbusds</groupId>
    <artifactId>nimbus-jose-jwt</artifactId>
    <version>7.9</version>
</dependency>
<dependency>
    <groupId>org.imgscalr</groupId>
    <artifactId>imgscalr-lib</artifactId>
    <version>4.2</version>
</dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>
</code>```

below is the Auth application.properties file

```<code>server.port=8282
server.ssl.enabled=true
server.ssl.key-store: classpath:localhost.p12
server.ssl.key-store-password: XXXXXX08
server.ssl.keyStoreType: PKCS12

spring.datasource.url=jdbc:ipaddr:3306/db_authentications?useSSL=false
spring.datasource.username=admin
spring.datasource.password=xxxx

spring.data.jdbc.repositories.enabled=false
spring.jpa.properties.hibernate.order_inserts=true

spring.datasource.max-active=100 # advanced configuration...
spring.datasource.max-idle=100
spring.datasource.min-idle=8
spring.jpa.hibernate.use-new-id-generator-mappings=false

spring.jpa.show-sql=false
spring.jpa.open-in-view=false

logging.level.org.springframework.web: DEBUG
logging.level.org.hibernate: ERROR

spring.main.banner-mode=off

#server.undertow.accesslog.enabled=true
#server.undertow.accesslog.dir=target/logs
#server.undertow.accesslog.pattern=combined
#server.compression.enabled=true
#server.compression.min-response-size=1

# Enable response compression
server.compression.enabled=true

# The comma-separated list of mime types that should be compressed
server.compression.mime-types=text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json

# Compress the response only if the response size is at least 1KB
server.compression.min-response-size=1000

# Enable HTTP/2 support, if the current environment supports it
server.http2.enabled=true

# Maximum time the response should be cached (in seconds)
spring.resources.cache.cachecontrol.max-age=120

# The cache must re-validate stale resources with the server. Any expired resources must not be used without re-validating.
spring.resources.cache.cachecontrol.must-revalidate=true

# The resources are private and intended for a single user. They must not be stored by a shared cache (e.g CDN).
spring.resources.cache.cachecontrol.cache-private= false

# The resources are public and any cache may store the response.
spring.resources.cache.cachecontrol.cache-public= true

spring.servlet.multipart.enabled=true

# Write files to disk if the file size is more than 2KB.
spring.servlet.multipart.file-size-threshold=2KB

# The intermediate disk location where the uploaded files are written
spring.servlet.multipart.location=/tmp

# Maximum file size that can be uploaded
spring.servlet.multipart.max-file-size=50MB

# Maximum allowed multipart request size
spring.servlet.multipart.max-request-size=75MB

spring.task.execution.pool.keep-alive = 60s
server.undertow.always-set-keep-alive = false
</code>```

below is Security Service pom.xml

```<code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.0.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.lc.inventory.security</groupId>
    <artifactId>LittleCarrotsInventorySecurityService</artifactId>
    <version>MVP-V2.0.0</version>
    <name>LittleCarrotsInventorySecurityService</name>
    <description>Little Carrots Inventory Security Service</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <!--
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
-->

        </dependency>
        <!-- <dependency> -->
        <!-- <groupId>org.springframework.boot</groupId> -->
        <!-- <artifactId>spring-boot-starter-undertow</artifactId> -->
        <!-- </dependency> -->

        <!-- https://mvnrepository.com/artifact/io.undertow/undertow-core -->
        <!--
        <dependency>
            <groupId>io.undertow</groupId>
            <artifactId>undertow-core</artifactId>
            <version>2.2.0.Final</version>
        </dependency>
-->
        <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>4.0.1</version>
            <scope>provided</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/io.undertow/undertow-servlet -->
        <!--
        <dependency>
            <groupId>io.undertow</groupId>
            <artifactId>undertow-servlet</artifactId>
            <version>2.2.0.Final</version>
        </dependency>
-->

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web-services</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- https://mvnrepository.com/artifact/log4j/log4j -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <version>3.2.0</version>
        </dependency>

        <dependency>
            <groupId>io.lettuce</groupId>
            <artifactId>lettuce-core</artifactId>
            <version>5.2.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.session</groupId>
            <artifactId>spring-session-core</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.11</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.4</version>
        </dependency>

<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-oauth2-jose -->
<!-- https://mvnrepository.com/artifact/com.nimbusds/nimbus-jose-jwt -->
<dependency>
    <groupId>com.nimbusds</groupId>
    <artifactId>nimbus-jose-jwt</artifactId>
    <version>7.9</version>
</dependency>

    <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
    <version>2.8.6</version>
</dependency>

        <dependency>
            <groupId>org.springframework.kafka</groupId>
            <artifactId>spring-kafka</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.kafka</groupId>
            <artifactId>spring-kafka-test</artifactId>
            <scope>test</scope>
        </dependency>
                <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.11.3</version>
</dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>
</code>```

below is Security service application.properties file

```<code>server.port= 8443
server.ssl.enabled=true
server.ssl.key-store: classpath:localhost.p12
server.ssl.key-store-password: xxxxx
server.ssl.keyStoreType: PKCS12

spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration

spring.h2.console.enabled=true

#LIVE DB URLS ENABLE ON MAIN STREAM
spring.datasource.url=jdbc:mysql://ipadr:3306/main_securityservice?useSSL=false
spring.datasource.username=admin
spring.datasource.password=xxxx

spring.data.jdbc.repositories.enabled=false
spring.jpa.properties.hibernate.order_inserts=true

spring.datasource.max-active=100 # advanced configuration...
spring.datasource.max-idle=100
spring.datasource.min-idle=8
spring.jpa.hibernate.use-new-id-generator-mappings=false

spring.jpa.show-sql=false
spring.jpa.open-in-view=false

logging.level.org.springframework.web: DEBUG
logging.level.org.hibernate: ERROR

spring.main.banner-mode=off

#server.undertow.accesslog.enabled=true
#server.undertow.accesslog.dir=target/logs
#server.undertow.accesslog.pattern=combined
#server.compression.enabled=true
#server.compression.min-response-size=1

# Enable response compression
server.compression.enabled=true

# The comma-separated list of mime types that should be compressed
server.compression.mime-types=text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json

# Compress the response only if the response size is at least 1KB
server.compression.min-response-size=1000

# Enable HTTP/2 support, if the current environment supports it
server.http2.enabled=true

# Maximum time the response should be cached (in seconds)
spring.resources.cache.cachecontrol.max-age=120

# The cache must re-validate stale resources with the server. Any expired resources must not be used without re-validating.
spring.resources.cache.cachecontrol.must-revalidate=false

# The resources are private and intended for a single user. They must not be stored by a shared cache (e.g CDN).
spring.resources.cache.cachecontrol.cache-private= false

# The resources are public and any cache may store the response.
spring.resources.cache.cachecontrol.cache-public= false

spring.servlet.multipart.enabled=true

# Write files to disk if the file size is more than 2KB.
spring.servlet.multipart.file-size-threshold=2KB

# The intermediate disk location where the uploaded files are written
spring.servlet.multipart.location=/tmp

# Maximum file size that can be uploaded
spring.servlet.multipart.max-file-size=50MB

# Maximum allowed multipart request size
spring.servlet.multipart.max-request-size=75MB

spring.task.execution.pool.keep-alive = 60s
server.undertow.always-set-keep-alive = false

server.undertow.eager-filter-init=true
</code>```

after the some references I updated open jdk also but no solution, below is full exception details.

```<code>org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
        at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:185) ~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
        at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:53) ~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
        at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:360) ~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
        at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:158) ~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
        at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:122) ~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:894) ~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553) ~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) [spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
        at com.lc.sk.inventory.security.SecurityServiceApplication.main(SecurityServiceApplication.java:15) [classes!/:MVP-V2.0.0]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_302]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_302]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_302]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_302]
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) [SecurityService-MVP-V2.0.0.jar:MVP-V2.0.0]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:109) [SecurityService-MVP-V2.0.0.jar:MVP-V2.0.0]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) [SecurityService-MVP-V2.0.0.jar:MVP-V2.0.0]
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) [SecurityService-MVP-V2.0.0.jar:MVP-V2.0.0]
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:229) ~[spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
        at org.springframework.boot.web.servlet.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:43) ~[spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
        at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:182) ~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
        ... 22 common frames omitted
Caused by: java.lang.IllegalArgumentException: standardService.connector.startFailed
        at org.apache.catalina.core.StandardService.addConnector(StandardService.java:231) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.java:282) ~[spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:213) ~[spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
        ... 24 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Protocol handler start failed
        at org.apache.catalina.connector.Connector.startInternal(Connector.java:1058) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        at org.apache.catalina.core.StandardService.addConnector(StandardService.java:227) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        ... 26 common frames omitted
Caused by: java.lang.IllegalArgumentException: parseAlgParameters failed: ObjectIdentifier() -- data isn't an object ID (tag = 48)
        at org.apache.tomcat.util.net.AbstractJsseEndpoint.createSSLContext(AbstractJsseEndpoint.java:99) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        at org.apache.tomcat.util.net.AbstractJsseEndpoint.initialiseSsl(AbstractJsseEndpoint.java:71) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:216) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        at org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.java:1141) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1227) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:592) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        at org.apache.catalina.connector.Connector.startInternal(Connector.java:1055) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        ... 28 common frames omitted
Caused by: java.io.IOException: parseAlgParameters failed: ObjectIdentifier() -- data isn't an object ID (tag = 48)
        at sun.security.pkcs12.PKCS12KeyStore.parseAlgParameters(PKCS12KeyStore.java:829) ~[na:1.8.0_302]
        at sun.security.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:2037) ~[na:1.8.0_302]
        at java.security.KeyStore.load(KeyStore.java:1445) ~[na:1.8.0_302]
        at org.apache.tomcat.util.security.KeyStoreUtil.load(KeyStoreUtil.java:67) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        at org.apache.tomcat.util.net.SSLUtilBase.getStore(SSLUtilBase.java:216) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        at org.apache.tomcat.util.net.SSLHostConfigCertificate.getCertificateKeystore(SSLHostConfigCertificate.java:207) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        at org.apache.tomcat.util.net.SSLUtilBase.getKeyManagers(SSLUtilBase.java:282) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        at org.apache.tomcat.util.net.SSLUtilBase.createSSLContext(SSLUtilBase.java:246) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        at org.apache.tomcat.util.net.AbstractJsseEndpoint.createSSLContext(AbstractJsseEndpoint.java:97) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        ... 34 common frames omitted
Caused by: java.io.IOException: ObjectIdentifier() -- data isn't an object ID (tag = 48)
        at sun.security.util.ObjectIdentifier.<init>(ObjectIdentifier.java:285) ~[na:1.8.0_302]
        at sun.security.util.DerInputStream.getOID(DerInputStream.java:320) ~[na:1.8.0_302]
        at com.sun.crypto.provider.PBES2Parameters.engineInit(PBES2Parameters.java:267) ~[sunjce_provider.jar:1.8.0_302]
        at java.security.AlgorithmParameters.init(AlgorithmParameters.java:293) ~[na:1.8.0_302]
        at sun.security.pkcs12.PKCS12KeyStore.parseAlgParameters(PKCS12KeyStore.java:825) ~[na:1.8.0_302]
        ... 42 common frames omitted
</code>```

答:
In my case, it also happens on jks file.
The jks file is produced by Java-11 keytool, and consumed by Java-8.

We need to recreate the jks using Java-8 keytool.

ContentLicense: CC BY-SA 4.0

Body:
In my one AWS EC2 server, I deployed three services [Auth, orders, Security]. I configured SSL for three services, The SSL is the same for three services, The Auth orders services working fine after doing some tunning, but the Security service has 'java.lang.IllegalArgumentException: parseAlgParameters failed: ObjectIdentifier() -- data isn't an object ID (tag = 48)' problem.
My Server has below Java Version:
openjdk version "1.8.0_302"
OpenJDK Runtime Environment (build 1.8.0_302-b08)
OpenJDK 64-Bit Server VM (build 25.302-b08, mixed mode)
I deployed my jar files from my windows PC, for my windows PC all three services working fine. but it's an issue with my AWS Centos server.

initially, I converted my .crt file to .p12 with Openssl3, that time all my three services has the above issue. So degraded my OpenSSL to the 1.1.1 version. then build my jars to AWS. So 'Auth' and 'Order' services are started working. but still am having issue in my security service.
below is the pom.xml for authentication.

    <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.2.RELEASE</version>
        <relativePath />
    </parent>
    <groupId>com.lc.auth</groupId>
    <artifactId>AuthenticationService</artifactId>
    <version>MVP-V2.0.0</version>
    <name>AuthenticationService</name>
    <description>Authentication Service</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>

        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web-services</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
            <version>8.0.11</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.11</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>

    <dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>2.4</version>
</dependency>

<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-oauth2-jose</artifactId>
    <version>5.2.3.RELEASE</version>
     <exclusions>
        <exclusion>
            <groupId>com.nimbusds</groupId>
            <artifactId>nimbus-jose-jwt</artifactId>
        </exclusion>
    </exclusions>
</dependency>

<dependency>
    <groupId>com.nimbusds</groupId>
    <artifactId>nimbus-jose-jwt</artifactId>
    <version>7.9</version>
</dependency>
<dependency>
    <groupId>org.imgscalr</groupId>
    <artifactId>imgscalr-lib</artifactId>
    <version>4.2</version>
</dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

below is the Auth application.properties file

server.port=8282
server.ssl.enabled=true
server.ssl.key-store: classpath:localhost.p12
server.ssl.key-store-password: XXXXXX08
server.ssl.keyStoreType: PKCS12

spring.datasource.url=jdbc:ipaddr:3306/db_authentications?useSSL=false
spring.datasource.username=admin
spring.datasource.password=xxxx

spring.data.jdbc.repositories.enabled=false
spring.jpa.properties.hibernate.order_inserts=true

spring.datasource.max-active=100 # advanced configuration...
spring.datasource.max-idle=100
spring.datasource.min-idle=8
spring.jpa.hibernate.use-new-id-generator-mappings=false

spring.jpa.show-sql=false
spring.jpa.open-in-view=false

logging.level.org.springframework.web: DEBUG
logging.level.org.hibernate: ERROR

spring.main.banner-mode=off

#server.undertow.accesslog.enabled=true
#server.undertow.accesslog.dir=target/logs
#server.undertow.accesslog.pattern=combined
#server.compression.enabled=true
#server.compression.min-response-size=1

# Enable response compression
server.compression.enabled=true

# The comma-separated list of mime types that should be compressed
server.compression.mime-types=text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json

# Compress the response only if the response size is at least 1KB
server.compression.min-response-size=1000

# Enable HTTP/2 support, if the current environment supports it
server.http2.enabled=true

# Maximum time the response should be cached (in seconds)
spring.resources.cache.cachecontrol.max-age=120

# The cache must re-validate stale resources with the server. Any expired resources must not be used without re-validating.
spring.resources.cache.cachecontrol.must-revalidate=true

# The resources are private and intended for a single user. They must not be stored by a shared cache (e.g CDN).
spring.resources.cache.cachecontrol.cache-private= false

# The resources are public and any cache may store the response.
spring.resources.cache.cachecontrol.cache-public= true

spring.servlet.multipart.enabled=true

# Write files to disk if the file size is more than 2KB.
spring.servlet.multipart.file-size-threshold=2KB

# The intermediate disk location where the uploaded files are written
spring.servlet.multipart.location=/tmp

# Maximum file size that can be uploaded
spring.servlet.multipart.max-file-size=50MB

# Maximum allowed multipart request size
spring.servlet.multipart.max-request-size=75MB

spring.task.execution.pool.keep-alive = 60s
server.undertow.always-set-keep-alive = false

below is Security Service pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.0.RELEASE</version>
        <relativePath />
    </parent>
    <groupId>com.lc.inventory.security</groupId>
    <artifactId>LittleCarrotsInventorySecurityService</artifactId>
    <version>MVP-V2.0.0</version>
    <name>LittleCarrotsInventorySecurityService</name>
    <description>Little Carrots Inventory Security Service</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>

        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>4.0.1</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web-services</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <version>3.2.0</version>
        </dependency>

        <dependency>
            <groupId>io.lettuce</groupId>
            <artifactId>lettuce-core</artifactId>
            <version>5.2.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.session</groupId>
            <artifactId>spring-session-core</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.11</version>
        </dependency>

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.4</version>
        </dependency>

<dependency>
    <groupId>com.nimbusds</groupId>
    <artifactId>nimbus-jose-jwt</artifactId>
    <version>7.9</version>
</dependency>

<dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
    <version>2.8.6</version>
</dependency>

        <dependency>
            <groupId>org.springframework.kafka</groupId>
            <artifactId>spring-kafka</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.kafka</groupId>
            <artifactId>spring-kafka-test</artifactId>
            <scope>test</scope>
        </dependency>

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.11.3</version>
</dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

below is Security service application.properties file

server.port= 8443
server.ssl.enabled=true
server.ssl.key-store: classpath:localhost.p12
server.ssl.key-store-password: xxxxx
server.ssl.keyStoreType: PKCS12

spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration

spring.h2.console.enabled=true

#LIVE DB URLS ENABLE ON MAIN STREAM
spring.datasource.url=jdbc:mysql://ipadr:3306/main_securityservice?useSSL=false
spring.datasource.username=admin
spring.datasource.password=xxxx

spring.data.jdbc.repositories.enabled=false
spring.jpa.properties.hibernate.order_inserts=true

spring.datasource.max-active=100 # advanced configuration...
spring.datasource.max-idle=100
spring.datasource.min-idle=8
spring.jpa.hibernate.use-new-id-generator-mappings=false

spring.jpa.show-sql=false
spring.jpa.open-in-view=false

logging.level.org.springframework.web: DEBUG
logging.level.org.hibernate: ERROR

spring.main.banner-mode=off

#server.undertow.accesslog.enabled=true
#server.undertow.accesslog.dir=target/logs
#server.undertow.accesslog.pattern=combined
#server.compression.enabled=true
#server.compression.min-response-size=1

# Enable response compression
server.compression.enabled=true

# The comma-separated list of mime types that should be compressed
server.compression.mime-types=text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json

# Compress the response only if the response size is at least 1KB
server.compression.min-response-size=1000

# Enable HTTP/2 support, if the current environment supports it
server.http2.enabled=true

# Maximum time the response should be cached (in seconds)
spring.resources.cache.cachecontrol.max-age=120

# The cache must re-validate stale resources with the server. Any expired resources must not be used without re-validating.
spring.resources.cache.cachecontrol.must-revalidate=false

# The resources are private and intended for a single user. They must not be stored by a shared cache (e.g CDN).
spring.resources.cache.cachecontrol.cache-private= false

# The resources are public and any cache may store the response.
spring.resources.cache.cachecontrol.cache-public= false

spring.servlet.multipart.enabled=true

# Write files to disk if the file size is more than 2KB.
spring.servlet.multipart.file-size-threshold=2KB

# The intermediate disk location where the uploaded files are written
spring.servlet.multipart.location=/tmp

# Maximum file size that can be uploaded
spring.servlet.multipart.max-file-size=50MB

# Maximum allowed multipart request size
spring.servlet.multipart.max-request-size=75MB

spring.task.execution.pool.keep-alive = 60s
server.undertow.always-set-keep-alive = false

server.undertow.eager-filter-init=true

after the some references I updated open jdk also but no solution, below is full exception details.

org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
        at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:185) ~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
        at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:53) ~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
        at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:360) ~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
        at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:158) ~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
        at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:122) ~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:894) ~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553) ~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) [spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
        at com.lc.sk.inventory.security.SecurityServiceApplication.main(SecurityServiceApplication.java:15) [classes!/:MVP-V2.0.0]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_302]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_302]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_302]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_302]
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) [SecurityService-MVP-V2.0.0.jar:MVP-V2.0.0]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:109) [SecurityService-MVP-V2.0.0.jar:MVP-V2.0.0]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) [SecurityService-MVP-V2.0.0.jar:MVP-V2.0.0]
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) [SecurityService-MVP-V2.0.0.jar:MVP-V2.0.0]
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:229) ~[spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
        at org.springframework.boot.web.servlet.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:43) ~[spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
        at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:182) ~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
        ... 22 common frames omitted
Caused by: java.lang.IllegalArgumentException: standardService.connector.startFailed
        at org.apache.catalina.core.StandardService.addConnector(StandardService.java:231) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.java:282) ~[spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:213) ~[spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
        ... 24 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Protocol handler start failed
        at org.apache.catalina.connector.Connector.startInternal(Connector.java:1058) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        at org.apache.catalina.core.StandardService.addConnector(StandardService.java:227) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        ... 26 common frames omitted
Caused by: java.lang.IllegalArgumentException: parseAlgParameters failed: ObjectIdentifier() -- data isn't an object ID (tag = 48)
        at org.apache.tomcat.util.net.AbstractJsseEndpoint.createSSLContext(AbstractJsseEndpoint.java:99) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        at org.apache.tomcat.util.net.AbstractJsseEndpoint.initialiseSsl(AbstractJsseEndpoint.java:71) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:216) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        at org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.java:1141) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1227) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:592) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        at org.apache.catalina.connector.Connector.startInternal(Connector.java:1055) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        ... 28 common frames omitted
Caused by: java.io.IOException: parseAlgParameters failed: ObjectIdentifier() -- data isn't an object ID (tag = 48)
        at sun.security.pkcs12.PKCS12KeyStore.parseAlgParameters(PKCS12KeyStore.java:829) ~[na:1.8.0_302]
        at sun.security.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:2037) ~[na:1.8.0_302]
        at java.security.KeyStore.load(KeyStore.java:1445) ~[na:1.8.0_302]
        at org.apache.tomcat.util.security.KeyStoreUtil.load(KeyStoreUtil.java:67) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        at org.apache.tomcat.util.net.SSLUtilBase.getStore(SSLUtilBase.java:216) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        at org.apache.tomcat.util.net.SSLHostConfigCertificate.getCertificateKeystore(SSLHostConfigCertificate.java:207) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        at org.apache.tomcat.util.net.SSLUtilBase.getKeyManagers(SSLUtilBase.java:282) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        at org.apache.tomcat.util.net.SSLUtilBase.createSSLContext(SSLUtilBase.java:246) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        at org.apache.tomcat.util.net.AbstractJsseEndpoint.createSSLContext(AbstractJsseEndpoint.java:97) ~[tomcat-embed-core-9.0.35.jar!/:9.0.35]
        ... 34 common frames omitted
Caused by: java.io.IOException: ObjectIdentifier() -- data isn't an object ID (tag = 48)
        at sun.security.util.ObjectIdentifier.<init>(ObjectIdentifier.java:285) ~[na:1.8.0_302]
        at sun.security.util.DerInputStream.getOID(DerInputStream.java:320) ~[na:1.8.0_302]
        at com.sun.crypto.provider.PBES2Parameters.engineInit(PBES2Parameters.java:267) ~[sunjce_provider.jar:1.8.0_302]
        at java.security.AlgorithmParameters.init(AlgorithmParameters.java:293) ~[na:1.8.0_302]
        at sun.security.pkcs12.PKCS12KeyStore.parseAlgParameters(PKCS12KeyStore.java:825) ~[na:1.8.0_302]
        ... 42 common frames omitted


问:
How to build CMake Debug version using different target name for executables?
I am building using cmake -DCMAKE_BUILD_TYPE=Debug ..

And I am using set(CMAKE_DEBUG_POSTFIX d) to add a d to the end of the filename.

This is working for static libraries and I expected it to work for executables as well. But, at least in my case, it is compiling all the static libraries using *d.a and the executable without d suffix.

Am I missing something?

答:
You are not missing anything. As the documentation says (emphasis mine):

When a non-executable target is created its <CONFIG>_POSTFIX target property is initialized with the value of this variable if it is set.

See: https://cmake.org/cmake/help/latest/variable/CMAKE_CONFIG_POSTFIX.html

By the sounds of it, though, you could manually set the property on your executable target with set_target_properties:

```<code>set_target_properties(
  target1 ... targetN
  PROPERTIES
  DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}"
)
</code>```

Note, however, that it doesn't apply to executables by default because that's rarely what you want. For libraries, it's fairly common to package and deploy debug and release configurations simultaneously. On Windows, for development, it is a requirement. On the other hand, one very rarely needs to deploy debug applications and hence one very rarely wants a postfix applied.

Body:
You are not missing anything. As the documentation says (emphasis mine):

When a non-executable target is created its <CONFIG>_POSTFIX target property is initialized with the value of this variable if it is set.

See: https://cmake.org/cmake/help/latest/variable/CMAKE_CONFIG_POSTFIX.html

By the sounds of it, though, you could manually set the property on your executable target with set_target_properties:

set_target_properties(
  target1 ... targetN
  PROPERTIES
  DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}"
)

Note, however, that it doesn't apply to executables by default because that's rarely what you want. For libraries, it's fairly common to package and deploy debug and release configurations simultaneously. On Windows, for development, it is a requirement. On the other hand, one very rarely needs to deploy debug applications and hence one very rarely wants a postfix applied.


问:
Removing legend on charts with chart.js v2
I'm making a homepage using, Bootstrap, JQuery and Chart.js (v2). I had my implementation working using v1, but recently just got into Bower and downloaded v2 using that.

I'm making a grid of 4 columns each containing a pie chart, however the scaling in v2 is sort of confusing for me to get working. I want the charts to be responsive so they scale properly with the smaller devices such as tablets and smartphones, and one of my problems is getting rid of the legend of the charts as well as the hover information when hovering the mouse over the sections of my chart.

index.html

```<code><body>
    <div class="container">
        <div class="row">
            <div class="col-xs-3">
                <canvas id="chart1"></canvas>
            </div>
            <div class="col-xs-3">
                <canvas id="chart1"></canvas>
            </div>
            <div class="col-xs-3">
                <canvas id="chart1"></canvas>
            </div>
            <div class="col-xs-3">
                <canvas id="chart1"></canvas>
            </div>
        </div>
    </div>
</body>
</code>```

functions.js

```<code>$(document).ready(function(){
    var canvas = $("#chart1");
    var data = {
        labels: [],
        datasets: [{
            data: [10, 10],
            backgroundColor: ["#F7464A", "#FDB45C"],
            hoverBackgroundColor: ["#FF5A5E", "#FFC870"]
        }]
    };

    var chart1 = new Chart(canvas, {
        type: "pie",
        data: data,
    });
});
</code>```

If I remove the empty "labels" field the chart doesn't work anymore. And by the looks of it there is a small spacing at the top of the chart which could indicate that the headers are written, but they are just empty strings.

Does anyone have an idea of how to remove the legend, and the hover description? I simply can't get my head around how this is used

I will get my hands around a jsfiddle as soon as I get time!

EDIT: Link to the docs: https://nnnick.github.io/Chart.js/docs-v2/#getting-started

答:
For me this didn't work:

legend: { display: false }

But this works great, thank you.

plugins: {
legend: {
display: false,
},
}

ContentLicense: CC BY-SA 3.0

Body:
I'm making a homepage using, Bootstrap, JQuery and Chart.js (v2). I had my implementation working using v1, but recently just got into Bower and downloaded v2 using that.

I'm making a grid of 4 columns each containing a pie chart, however the scaling in v2 is sort of confusing for me to get working. I want the charts to be responsive so they scale properly with the smaller devices such as tablets and smartphones, and one of my problems is getting rid of the legend of the charts as well as the hover information when hovering the mouse over the sections of my chart.

index.html

                <canvas id="chart1"></canvas>

                <canvas id="chart1"></canvas>

                <canvas id="chart1"></canvas>

                <canvas id="chart1"></canvas>

functions.js

$(document).ready(function(){
    var canvas = $("#chart1");
    var data = {
        labels: [],
        datasets: [{
            data: [10, 10],
            backgroundColor: ["#F7464A", "#FDB45C"],
            hoverBackgroundColor: ["#FF5A5E", "#FFC870"]
        }]
    };

    var chart1 = new Chart(canvas, {
        type: "pie",
        data: data,
    });
});

If I remove the empty "labels" field the chart doesn't work anymore. And by the looks of it there is a small spacing at the top of the chart which could indicate that the headers are written, but they are just empty strings.

Does anyone have an idea of how to remove the legend, and the hover description? I simply can't get my head around how this is used

I will get my hands around a jsfiddle as soon as I get time!

EDIT: Link to the docs: https://nnnick.github.io/Chart.js/docs-v2/#getting-started


问:
TypeScript: Can I achieve this use generics and conditional types instead of function overloads?
I am trying to write a function that either:

takes a single string as its only argument, in which case it returns a string

or takes one string and two numbers as its arguments in which case it returns a number

```<code>fn('foo') // ✅
fn('foo', 1, 2) // ✅

fn() // type error ❌
fn('foo', 1) // type error ❌
</code>```

I understand that this can be implemented via function overloads in TypeScript

function fn(a: string): string
function fn(a: string, b: number, c: number): number
function fn(a: string, b?: number, c?: number): string | number {
    if(arguments.length === 1) return a
    else return b as number
}

const str = fn('foo') // 'foo'
const num = fn('foo', 1, 2) // 1

```

However, I was wondering if this can also be achieved by conditional types without using function overloads since it seems to me that a lot of times conditional types would do the trick.

I guess it is easy to adjust return types according to arguments' types just by using conditional types but it seems impossible to regulate function signatures such has how many arguments it can take.

答:
Maybe something like this could work:

```<code>type X = readonly [string, number, number];
type Y = X | [string];

type ReturnVal<T> = T extends X ? number : string;

function fn<T extends Y>(...args: T): ReturnVal<T> {
  if (args.length === 1) return args[0] as ReturnVal<T>;
  else return args[1] as ReturnVal<T>;
}

const val1 = fn("dwe");
const val2 = fn("dwe", 2); //Argument of type '["dwe", 2]' is not assignable to parameter of type 'Y'.
const val3 = fn("dwe", 2, 3);
</code>```

I am sure it can be written better but it is just a snippet

Body:
I am trying to write a function that either:

takes a single string as its only argument, in which case it returns a string

or takes one string and two numbers as its arguments in which case it returns a number

fn('foo') // ✅
fn('foo', 1, 2) // ✅

fn() // type error ❌
fn('foo', 1) // type error ❌

I understand that this can be implemented via function overloads in TypeScript

function fn(a: string): string
function fn(a: string, b: number, c: number): number
function fn(a: string, b?: number, c?: number): string | number {
    if(arguments.length === 1) return a
    else return b as number
}

const str = fn('foo') // 'foo'
const num = fn('foo', 1, 2) // 1

However, I was wondering if this can also be achieved by conditional types without using function overloads since it seems to me that a lot of times conditional types would do the trick.

I guess it is easy to adjust return types according to arguments' types just by using conditional types but it seems impossible to regulate function signatures such has how many arguments it can take.

Body:
Maybe something like this could work:

type X = readonly [string, number, number];
type Y = X | [string];

type ReturnVal<T> = T extends X ? number : string;

function fn<T extends Y>(...args: T): ReturnVal<T> {
  if (args.length === 1) return args[0] as ReturnVal<T>;
  else return args[1] as ReturnVal<T>;
}

const val1 = fn("dwe");
const val2 = fn("dwe", 2); //Argument of type '["dwe", 2]' is not assignable to parameter of type 'Y'.
const val3 = fn("dwe", 2, 3);

I am sure it can be written better but it is just a snippet


问:
How to split string in 3 characters and keep on appending in JMeter
I have requirement to implement search suggestion in JMeter script like given below,
let say i have string iPhone then requests in JMeter should be like this

How to write logic to split string (iPhone) like iPh, iPho, iPhon, iPhone?

https://example.com?q=iPh

https://example.com?q=iPho

https://example.com?q=iPhon

https://example.com?q=iPhone

How can i implement this in JMeter script, first Hit will be after 3 characters.

答:
Something like:

```<code>def string = 'iPhone'

0.upto(string.length() - 3, index -> {
   if (index == 0) {
       vars.put('somevar_' + (index + 1), string.take(3))
   } else {
       vars.put('somevar_' + (index + 1), string.take(3 + index))
   }
})
</code>```

should do the trick for you, it will produce the following JMeter Variables

```<code>somevar_1=iPh
somevar_2=iPho
somevar_3=iPhon
somevar_4=iPhone
</code>```

which can be iterated using ForEach Controller like:

Demo:

More information on Groovy scripting in JMeter: Apache Groovy - Why and How You Should Use It

Body:
Something like:

def string = 'iPhone'

0.upto(string.length() - 3, index -> {
   if (index == 0) {
       vars.put('somevar_' + (index + 1), string.take(3))
   } else {
       vars.put('somevar_' + (index + 1), string.take(3 + index))
   }
})

should do the trick for you, it will produce the following JMeter Variables

somevar_1=iPh
somevar_2=iPho
somevar_3=iPhon
somevar_4=iPhone

which can be iterated using ForEach Controller like:

Demo:

More information on Groovy scripting in JMeter: Apache Groovy - Why and How You Should Use It


问:
Facebook ads - Products feed - Multiple shipping zones setting
I'm writing a feed from an e-shop, to give to facebook.

So far so good. The feed is in XML format, and the reference provides a sample, and the format for the shipping field in the item, within the feed, is:

```<code><g:shipping>
    <g:country>UK</g:country>
    <g:service>Standard</g:service>
    <g:price>4.95 GBP</g:price>
</g:shipping>
</code>```

However, the reference states that the format should be a comma-separated string, like this:

```<code>Blob with different prices for each country and region.
Different regions are comma-separated.
The format should be COUNTRY:STATE:SHIPPING_TYPE:PRICE.

e.g.

US:CA:Ground:9.99 USD, US:NY:Air:15.99 USD
</code>```

Do you catch the contradiction?

If I try in my feed:

```<code><g:shipping>US:CA:Ground:9.99 USD, US:NY:Air:15.99 USD</g:shipping>
</code>```

I get errors, that country or price is missing.

So, I will have to stick to the sample.

The question is:

Which is the right way to provide multiple shipping zones in the feed?

The debugging tool here is not helping at all...

Do I repeat the g:shipping fieldset?

```<code><g:shipping>
    <g:country>UK</g:country>
    <g:service>Standard</g:service>
    <g:price>4.95 GBP</g:price>
</g:shipping>
<g:shipping>
    <g:country>US</g:country>
    <g:service>Standard</g:service>
    <g:price>5.30 GBP</g:price>
</g:shipping>
</code>```

Do I iterate within the fieldset?

```<code><g:shipping>
    <g:country>UK</g:country>
    <g:service>Standard</g:service>
    <g:price>4.95 GBP</g:price>
    <g:country>US</g:country>
    <g:service>Standard</g:service>
    <g:price>5.30 GBP</g:price>
</g:shipping>
</code>```

Or what, if anything, do I have to do to have multiple zones, before switching to CSV (which I don't want to do, but I will if I have to: CSV supports the comma-separated format for multiple zones)?

答:
For anyone gets warnings about shipping_price_value, shipping_price;
If you are using php and  SimpleXMLElement add xmlns:g: to define xml namespace otherwise facebook throws warnings.

Interestingly this only affects shipping fields.

```<code>$shipping = $item->addChild('xmlns:g:shipping');
$shipping->addChild('xmlns:g:country', 'TR');
$shipping->addChild('xmlns:g:service', 'Karayolu');
$shipping->addChild('xmlns:g:price', '14.90 TRY');
</code>```

Body:
I'm writing a feed from an e-shop, to give to facebook.

So far so good. The feed is in XML format, and the reference provides a sample, and the format for the shipping field in the item, within the feed, is:

<g:shipping>
    <g:country>UK</g:country>
    <g:service>Standard</g:service>
    <g:price>4.95 GBP</g:price>
</g:shipping>

However, the reference states that the format should be a comma-separated string, like this:

Blob with different prices for each country and region.
Different regions are comma-separated.
The format should be COUNTRY:STATE:SHIPPING_TYPE:PRICE.

e.g.

US:CA:Ground:9.99 USD, US:NY:Air:15.99 USD

Do you catch the contradiction?

If I try in my feed:

<g:shipping>US:CA:Ground:9.99 USD, US:NY:Air:15.99 USD</g:shipping>

I get errors, that country or price is missing.

So, I will have to stick to the sample.

The question is:

Which is the right way to provide multiple shipping zones in the feed?

The debugging tool here is not helping at all...

Do I repeat the g:shipping fieldset?

<g:shipping>
    <g:country>UK</g:country>
    <g:service>Standard</g:service>
    <g:price>4.95 GBP</g:price>
</g:shipping>
<g:shipping>
    <g:country>US</g:country>
    <g:service>Standard</g:service>
    <g:price>5.30 GBP</g:price>
</g:shipping>

Do I iterate within the fieldset?

<g:shipping>
    <g:country>UK</g:country>
    <g:service>Standard</g:service>
    <g:price>4.95 GBP</g:price>
    <g:country>US</g:country>
    <g:service>Standard</g:service>
    <g:price>5.30 GBP</g:price>
</g:shipping>

Or what, if anything, do I have to do to have multiple zones, before switching to CSV (which I don't want to do, but I will if I have to: CSV supports the comma-separated format for multiple zones)?

Body:
For anyone gets warnings about shipping_price_value, shipping_price;
If you are using php and  SimpleXMLElement add xmlns:g: to define xml namespace otherwise facebook throws warnings.

Interestingly this only affects shipping fields.

$shipping = $item->addChild('xmlns:g:shipping');
$shipping->addChild('xmlns:g:country', 'TR');
$shipping->addChild('xmlns:g:service', 'Karayolu');
$shipping->addChild('xmlns:g:price', '14.90 TRY');


问:
useNavigate() may be used only in the context of a <Router> component
See my code below. I'm trying to add this button that goes back to the previous page using react-router-dom but I get the below error, and also all the components on my website disappear.

Error:

useNavigate() may be used only in the context of a component

My code:

```<code>function App() {
  const navigate = useNavigate();
  return (
    <BrowserRouter>
      <div>
      <button onClick={() => navigate(-1)}>go back</button>
        <Nav/>
        <Routes>
          <Route exact path="/" element={<Home/>}/>
          <Route exact path="/home" element={<Home/>}/>
          <Route exact path="/upcoming/:user" element={<Upcoming/>}/>
          <Route exact path="/record/:user" element={<Record/>}/>
          <Route path="*" element={<NotFound/>}/>
        </Routes>
      </div>
    </BrowserRouter>
  );
}
</code>```

And this is the error I got in console:

答:
I had this same issue but with testing a component that has the hook useNavigate on it. Solved it by wrapping my component in a Route with Routes and BrowserRouter. Hope this helps others with the same error.

```<code>let container = null;
    beforeEach(() => {
    container = document.createElement("div");
    document.body.appendChild(container);
});

afterEach(() => {
    // cleanup on exiting
    unmountComponentAtNode(container);
    container.remove();
    container = null;
});

test('finds qualified insurrance policies', () => {
    act(() => {
    render(
    <BrowserRouter>
        <Routes>
            <Route path="*" element= {<QuaifiedPolicies policyTypes={false} />}/>
        </Routes>
    </BrowserRouter>
        , container);
    });
    expect(screen.getByLabelText('some text'))
});
</code>```

Body:
See my code below. I'm trying to add this button that goes back to the previous page using react-router-dom but I get the below error, and also all the components on my website disappear.

Error:

useNavigate() may be used only in the context of a component

My code:

function App() {
  const navigate = useNavigate();
  return (
    <BrowserRouter>

      <button onClick={() => navigate(-1)}>go back</button>

        <Routes>
          <Route exact path="/" element={<Home/>}/>
          <Route exact path="/home" element={<Home/>}/>
          <Route exact path="/upcoming/:user" element={<Upcoming/>}/>
          <Route exact path="/record/:user" element={<Record/>}/>
          <Route path="*" element={<NotFound/>}/>
        </Routes>

    </BrowserRouter>
  );
}

And this is the error I got in console:

Body:
I had this same issue but with testing a component that has the hook useNavigate on it. Solved it by wrapping my component in a Route with Routes and BrowserRouter. Hope this helps others with the same error.

let container = null;
    beforeEach(() => {
    container = document.createElement("div");
    document.body.appendChild(container);
});

afterEach(() => {
    // cleanup on exiting
    unmountComponentAtNode(container);
    container.remove();
    container = null;
});

test('finds qualified insurrance policies', () => {
    act(() => {
    render(
    <BrowserRouter>
        <Routes>
            <Route path="*" element= {<QuaifiedPolicies policyTypes={false} />}/>
        </Routes>
    </BrowserRouter>
        , container);
    });
    expect(screen.getByLabelText('some text'))
});