Category Archives: JAVA

[Solved] Runtime JAR file has version 1.4 which is older than required for API version 1.5

Today, I packed a project and suddenly reported an error, which made people unable to touch the problem. This project is developed in Java.

/Users/xxx/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.4.20/9be77b243a362b745e365f286627b8724337009c
/kotlin-stdlib-1.4.20.jar: Runtime JAR file has version 1.4 which is older than required for API version 1.5

w: Runtime JAR files in the classpath have the version 1.4, which is older than the API version 1.5. 
Consider using the runtime of version 1.5, or pass '-api-version 1.4' explicitly to restrict 
the available APIs to the runtime of version 1.4. You can also pass '-language-version 1.4' instead, 
which will restrict not only the APIs to the specified version, but also the language features

After reading the prompt, it should be the jar package version.

But the problem must be:

kotlin-stdlib

How should I solve it?

It should be inadvertently used the package written by kotlin, so the package will use this dependency when compiling, but it is not specified, so I can only use the one that comes with the system, but kotlin has been upgraded to the latest version.

1. Add Classpath: build.Gradle (Project: XXXX)

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"

2.Add dependencies: build.gradle(project:xxxx.app)

implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.6.10'

Where: XXXX your project name.

The above two steps basically solve the above error reporting. If there are still errors, take a look at the prompt and solve it.

Here, an attribute in the layout is missing, and files of different devices are generated by default.

If you can’t use other V24 and land, you can delete them.

How to Solve idea Import ojdbc Pack Error

Download online or ask colleagues to pass two jars, ojdbc6-11.2 0.7. 0. Jar and jconn3 0.jar

Put in the same folder:

CMD in this folder is as follows: press enter to enter the CMD console.

Enter the following two commands:

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.3 -Dpackaging=jar -Dfile=ojdbc6-11.2.0.3.jar

mvn install:install-file -DgroupId=com.sybase -DartifactId=jconn -Dversion=3-6.0 -Dpackaging=jar -Dfile=jconn3-6.0.jar

Represents a successful addition. For build failure, please check whether the version number, groupid, file name, etc. in the statement are consistent with the actual situation, and then run it after modification.

Note: If you have installed multiple maven versions, please check which version the current maven_home address is. This command is to install the jar locally into our local maven warehouse. If the warehouse is wrong, it won’t work if you install it.

After installation, right-click the project and update project

Click OK, and then Maven install again. No error will be reported

[Solved] org.apache.catalina.startup.HostConfig.deployWAR Error deploying web application archive

At 23:00 yesterday, an error was reported after an old project was packaged and released to the cloud server. Tomcat9 couldn’t start, which wasted me several hours.

This error has been encountered before and has been forgotten for a long time. It is hereby recorded

Error log

22-Dec-2021 23:52:18.703 SEVERE [main] org.apache.catalina.startup.HostConfig.deployWAR Error deploying web application archive [/usr/tomcat/webapps/project.war]
    java.lang.IllegalStateException: Error starting child
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:731)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:696)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1024)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1911)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
        at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
        at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:825)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:475)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1618)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:319)
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
        at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:423)
        at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:366)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:948)
        at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:835)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1388)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
        at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:921)
        at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:263)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.StandardService.startInternal(StandardService.java:437)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:934)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:772)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:345)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:476)
    Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/project]]
        at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:728)
        ... 37 more

process

My environment is centenos7 + tomcat9 + jdk8 + springboot2*

After reporting the error, I checked a lot of information on the Internet, and a variety of solutions emerge one after another

But it’s not egg, as usual nonsense.

On the Internet

1. It’s said to change Java_ A configuration related to random numbers under JRE/lib under home (changed, useless)

2. It’s said to change the Tomcat Version (never tried, trouble)

3. It’s said to change C. under Tomcat conf So and so configuration file (useless at first sight)

4. Some people say that the JDK is low (mine is 1.8, so it’s impossible)

5. It is said that the version of the spring * * * framework is inconsistent with the relevant environment (as long as it can run in the editor, it generally does not exist)

5. A reliable post: Tomcat/conf/server The item corresponding to the docbase attribute of the context node under the host node in XML is wrong (this is possible, but mine is OK)

Solution:

Empty the target folder, pack again, publish, success!

[Solved] IDEA 2021.3 Error: Error launching IDEA if you already have a 64-bit JDK installed,define a JAVA_HOME

In the process of activating the idea, just modify the vmoptions file and restart IntelliJ idea, the following error will be reported.

Solution:

In the directory: C:\Users\${your.username}\AppData\Roaming\JetBrains\IntelliJIdea2020.3 there is a file named idea.64.exe.vmoptions , just delete the changed file.

 

ps: I installed the JDK separately before installing IDEA, but this does not affect my normal installation of IDEA; after the above problems are solved, the normal activation steps can also be performed, and a vmoptions file will be regenerated.

Tomcat Deployed Applications Start Error: java.lang.ClassCastException: [XXX].filter.CharacterEncoding cannot be cast to jakarta.servlet.Filter

When xiaomengxin was learning to deploy applications on the Java Web, he found that the console could not normally connect to the MySQL database, but it was always normal when using the idea test. Looking at the Tomcat startup log, he found that there was an error message. Through comparison, he found that tomcat9 was configured in the idea and tomcat10 was installed on the server, Baidu knows that the servlet package of tomcat10 and later has changed and needs to be imported into Jakarta servlet.* Replace javax.XML with a new package servlet.* Or directly replace it with tomcat9 version to avoid this error.

Error screenshot:

[Solved] javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure

background

Java version 1.8 0. Today, I tried to access an HTTPS interface with Java, but threw the following exception:

javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure

reason

Starting from java8 update31, SSL V3 protocol is disabled by default due to security vulnerabilities in SSL protocol.

Solution:

Find the JDK 1.8 installation directory. For example, my java folder is called jdk1.8.0_301, find the Java Security file

Delete the three algorithms in the figure in the file

Delete as shown in the figure

Finally, restart the project.

[Solved] SpringBoot Package Error: Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-res

Problem description

Springboot application packaging error: failed to execute goal org apache. maven. plugins:maven-resources-plugin:3.2. 0:resources (default-res

Cause analysis

Maven resources plugin dependency is missing in plugins tag.

<plugins>
<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <excludes>
            <exclude>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
            </exclude>
        </excludes>
    </configuration>
</plugin>
</plugins>

Add configuration item

        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.1.0</version>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>

Now the problem is solved.

[Solved] Java EE file upload Error: web.xml error

Javaee file upload
Web.xml error
The error content is as follows:

cvc-id.3: A field of identity constraint ‘web-common-servlet-name-uniqueness’ matched element ‘web-app’, but this element
does not have a simple type.

Solution:

xsi:schemaLocation=”http://java.sun.com/xml/ns/javaee
Change the ‘java’ to uppercase

[Solved] IOS12 + Xscode12 Error: Building for iOS Simulator, but linking in dylib built for iOS, file ‘/Users/XXX/Desktop/XXXX/XXX.framework/JSSDK’ for architecture arm64

Problem description: An error occurred during the compilation process,Building for iOS Simulator, but linking in dylib built for iOS, file ‘/Users/XXX/Desktop/XXXX/XXX.framework/JSSDK’ for architecture arm64
Development environment: IOS 12 + Xcode 12.0
Solution: