Tag Archives: jar

[2022 New Solution] Error:java: Compilation failed: internal java compiler error

Error Reason

The reason for this error is mainly because of the jdk version problem, There are two reasons here, One is that the compiled version does not match, The other is that the current project jdk version does not support.

1:mac select Preferences

windows find Setting

Find Java Compiler

Select 1.8 on the right

2: Find File ->Project Structure->Project Settings

Choose 8

Choose 8

[Solved] Android Studio Generate APK Error: error_prone_annotations.jar (com.google.errorprone:error)

Android Studio failed to generate apk error:

Could not download error_prone_annotations.jar (com.google.errorprone:error)

 

Solution:

Modify the buildscript and allprojects in build.gradle file of your project:

google()jcenter()

to

maven { url ‘https://maven.aliyun.com/repository/google’ }maven { url ‘https://maven.aliyun.com/repository/jcenter’ }maven { url ‘http://maven.aliyun.com/nexus/content/groups/public’ }

Done!

[Solved] Jar error on Linux: no main manifest attribute

1: Running jar package in Linux environment, unable to find main

Reason: pom is missing configuration

Add the following to the pom file

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

[Solved] Springboot Package jar and Startup Error: It was loaded from the following location

Previously, when using springboot to develop the system, the @Resouse annotation was used. There was no exception during the idea runtime, but the jar package conflict was reported when the deployment was packaged.

09:07:51.234 [main] ERROR o.s.b.d.LoggingFailureAnalysisReporter - [report,40] - 

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.<init>(CommonAnnotationBeanPostProcessor.java:664)

The following method did not exist:

    'java.lang.String javax.annotation.Resource.lookup()'

The method's class, javax.annotation.Resource, is available from the following locations:

    jar:file:/C:/vic/vic-admin.jar!/BOOT-INF/lib/jsr250-api-1.0.jar!/javax/annotation/Resource.class
    jar:file:/C:/vic/vic-admin.jar!/BOOT-INF/lib/jakarta.annotation-api-1.3.5.jar!/javax/annotation/Resource.class

The class hierarchy was loaded from the following locations:

    javax.annotation.Resource: jar:file:/C:/vic/vic-admin.jar!/BOOT-INF/lib/jsr250-api-1.0.jar!/


Action:

Correct the classpath of your application so that it contains a single, compatible version of javax.annotation.Resource

Reason:

jsr250-api-1.0.jar and jakarta.annotation-api-1.3.5.jar are duplicated

Solution:

Import the following dependency in the pom of Maven. the codes is as below:

<dependency>
    <groupId>javax.annotation</groupId>
    <artifactId>javax.annotation-api</artifactId>
    <version>1.3.2</version>
</dependency>

The purpose of this is to make the system automatically import the latest jar package

Failed to scan osdt_cert.jar & osdt_core.jar [How to Solve]

java.io.FileNotFoundException: D:\WorkSpace\repository\com\oracle\ojdbc\oraclepki\oracle.osdt\osdt_cert.jar (系统找不到指定的路径。)
java.io.FileNotFoundException: D:\WorkSpace\repository\com\oracle\ojdbc\oraclepki\oracle.osdt\osdt_core.jar (系统找不到指定的路径。)

The reason for the problem is the dependency added in POM and the built-in dependence of toCat on JSP support, which is used to compile JSP.

<dependency>
  <groupId>org.apache.tomcat.embed</groupId>
    <artifactId>tomcat-embed-jasper</artifactId>
</dependency>

Solution: shield the jar package:
method 1: add the following codes in the startup class:

System.setProperty(org.apache.tomcat.util.scan.Constants.SKIP_JARS_PROPERTY,"*.jar");

Method 2: add the following codes in application.yml:

server:
  tomcat:
    additional-tld-skip-patterns:
      - osdt_cert.jar
      - osdt_core.jar

[Solved] jar Run Error: no main manifest attribute

Jar running error no main manifest attribute

Solution:

After investigation, it was found that it was pom.xml is not added in Maven project:

<packaging>jar</packaging>

And the following configurations:

<build>
<!--maven-->
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
  <resources>
  <!-- pom.xml resources -->
    <resource>
      <directory>src/main/java</directory>
      <includes>
        <include>**/*.properties</include>
      </includes>
    </resource>
    <resource>
      <!-- The *.xml file in the java directory will also be packaged when the project is packaged -->
      <directory>src/main/resources</directory>
    </resource>
    <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
  </resources>
</build>

[Solved] Tomcat Server Error: java.lang.NullPointerException Csonsole Error ClassNotFoundException: com.mysql.jdbc.Driver

tomcat Server Error:  java.lang.NullPointerException
Type Exception Report

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

java.lang.NullPointerException
	com.gxa.login.dbutils.DBUtils.executeQuery(DBUtils.java:26)
	com.gxa.login.dao.LoginDao.queryInfo(LoginDao.java:16)
	com.gxa.login.service.LoginService.login(LoginService.java:15)
	com.gxa.login.service.LoginServlet.doPost(LoginServlet.java:27)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Note The full stack trace of the root cause is available in the server logs.

 

An error is also reported in the console

Obviously, the driver was not found

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

java.sql.SQLException: No suitable driver found for jdbc: mysql://localhost:3306

Solution: check whether the jar package is correctly placed under web/WEB-INF/lib

Add to the directory to correctly identify and use:

 

[Solved] ApplicationContextException: Failed to start bean ‘documentationPluginsBootstrapper‘;

ApplicationContextException: Failed to start bean ‘documentationPluginsBootstrapper‘;

Spring boot reports the following errors:

org.springframework.context.applicationContextException: Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java. lang.NullPointerException

After testing for a long time, it is found that the reason for swagger2:

Version 3.0.0 was originally used:

<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>3.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>3.0.0</version>
</dependency>

It is said that:

Reason: This is because Springfox uses path matching based on AntPathMatcher, while Spring Boot 2.6.X uses PathPatternMatcher.
Solution: Configure in application.properties: spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER

After testing, no error was reported, but the search access http://localhost:8080/swagger-ui.html has 404

Final solution:

Switch the version of swagger2 and swaggerui to version 2.9.2

<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
<dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>2.9.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
<dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>2.9.2</version>
</dependency>

If it does not work like me, just add the following code in application.properties:

spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER

Problem solved!

[Solved] Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: Cannot find cla

preface

The problem encountered when learning Mybatis for the first time, when writing the global configuration file SqlMapConfig.xml, in the database connection pool section would like to introduce the configuration of db.properties as follows.

db.properties configuration

SqlMapConfig.xml

The error reports given are:

Error setting driver on UnpooledDataSource. Cause:java.lang.ClassNotFoundException: Cannot find class: ${jdbc.driver}

No corresponding connection was obtained. Because the properties file was not loaded:

After Add <properties> labeling, the program runs normally.

Done.

[Solved] Error creating bean with name ‘sqlSessionFactory‘ defined in class path resource

Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is
Could not resolve resource location pattern [classpath:com/test/mapper/*.xml]: class path resource [com/test/mapper/] cannot be resolved to URL because it does not exist

 

Spring MVC error
When you encounter this error, put the entity class in src/main/java instead of src/test/java

[Solved] shiro Error: SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder“.

shiro error: SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder“.

Shiro reports an error

SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder“.

Reason found after search:

Logging implication loading org.slf4j.impl.StaticLoggerBinder class failed
This warning message is reported when running the “org.slf4j.impl. Unable to load StaticLoggerBinder class into memory. This happens when a suitable SLF4J binding cannot be found on the class path. Putting one (and only one) of slf4j-nop.jar slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar, or logback-classic.jar on the class path should solve the problem.
Note that the slf4j-api version is 2.0. x and later using the ServiceLoader mechanism. Backends, such as logback 1.3 and later, target slf4j-api 2. Do not distribute with org.slf4j.impl.StaticLoggerBinder. If you set up a logging backend targeting slf4j-api 2.0. X, you need to install slf4j-api-2.x.jar on the class path. See the related faq entry.

Solution:
Remove one of the jar packages slf4j-nop.jar slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar or logback-classic.jar, leaving only one
runs successfully

[Solved] nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter

Error: javax/xml/bind/DatatypeConverter

Error content

org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter
  at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1055)
  at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
  at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
  at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
  at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
  at

Error reporting reason:

JAXB API is an API for java EE and this Jar package is no longer included in java SE 9.0.
By default, the Jar package for java EE will no longer be included in Java SE
In JDK 6/7/8 about this API are bundled together.

Solutioin:

Method I:

Downgrade the version of JDK to JDK 8

Method II:

The following parts are introduced into the dependencies of the pom.xml file:

<dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.3.0</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-impl</artifactId>
        <version>2.3.0</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-core</artifactId>
        <version>2.3.0</version>
    </dependency>
    <dependency>
        <groupId>javax.activation</groupId>
        <artifactId>activation</artifactId>
        <version>1.1.1</version>
    </dependency>