Tag Archives: java

JAVA ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2 JDWP exit erro

When running the program is suddenly the following exception occurs

ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [util.c:840]

The reason:

1.JDK1.6.1
2. There is an error in the last debugging code, which causes the process not to terminate and take up the Console output, and such error occurs when starting debugging later.

Solutions:

At the end of the program, the main() function adds: System.exit(0);
System.exit(0); will cause the program to be terminated immediately, and if there are threads in the program that are still executing tasks, subsequent tasks will not be able to continue.

 

org.hibernate.exception.SQLGrammarException: could not extract ResultSet, Resolve MySQL 5.7.5 or above GROUP_BY is not supported

Title: org.hibernate.exception.sqlgrammarexception: could not extract resultset, solve group above MySQL 5.7.5_ By is not supported

The reason for the problem:
MySQL 5.7.5 and above functions rely on the detection function. If only is enabled_ FULL_ GROUP_ By SQL mode (by default), MySQL will reject queries that select lists, having conditions, or order by lists, refer to non collection columns that are neither named nor functionally dependent on them in the group by clause( Before 5.7.5, MySQL did not detect any functional dependency, and only was not enabled by default_ FULL_ GROUP_ BY。 For a description of the behavior before 5.7.5, please refer to the MySQL 5.6 reference manual.)

Solution 1:

Open navcat,

Query with SQL:

select @@global.sql_ mode

The values are as follows:

ONLY_ FULL_ GROUP_ BY,STRICT_ TRANS_ TABLES,NO_ ZERO_ IN_ DATE,NO_ ZERO_ DATE,ERROR_ FOR_ DIVISION_ BY_ ZERO,NO_ AUTO_ CREATE_ USER,NO_ ENGINE_ SUBSTITUTION

Remove only_ FULL_ GROUP_ By, reset the value.

set @@global.sql_ mode
=’STRICT_ TRANS_ TABLES,NO_ ZERO_ IN_ DATE,NO_ ZERO_ DATE,ERROR_ FOR_ DIVISION_ BY_ ZERO,NO_ AUTO_ CREATE_ USER,NO_ ENGINE_ SUBSTITUTION’;

Solution 2:

Successful steps:

Item open

sudo vim /etc/mysql/conf.d/mysql.cnf

Scroll to the bottom of the file and copy and paste

[mysqld]
sql_ mode=STRICT_ TRANS_ TABLES,NO_ ZERO_ IN_ DATE,NO_ ZERO_ DATE,ERROR_ FOR_ DIVISION_ BY_ ZERO,NO_ AUTO_ CREATE_ USER,NO_ ENGINE_ SUBSTITUTION

Go to the bottom of the file

Save and exit input mode

sudo service mysql restart

Restart mysql
complete

How to use C # to get image format without system. Drawing. Common

I wrote a blog to get the correct format of the picture. The code shown in the blog has been working well. Until today, when deploying the program to alicloud function computing, the following error occurred:

System.Drawing is not supported on this platform.

This shows that we can’t use GDI + related functions on the alicloud function computing server. Even so, we can still get the image format by reading the file header

   public static class ImageHelper
    {
        public enum ImageFormat
        {
            Bmp,
            Jpeg,
            Gif,
            Tiff,
            Png,
            Unknown
        }


        public static ImageFormat GetImageFormat(byte[] bytes)
        {
            var bmp = Encoding.ASCII.GetBytes("BM"); // BMP
            var gif = Encoding.ASCII.GetBytes("GIF"); // GIF
            var png = new byte[] {137, 80, 78, 71}; // PNG
            var tiff = new byte[] {73, 73, 42}; // TIFF
            var tiff2 = new byte[] {77, 77, 42}; // TIFF
            var jpeg = new byte[] {255, 216, 255, 224}; // jpeg
            var jpeg2 = new byte[] {255, 216, 255, 225}; // jpeg canon


            if (bmp.SequenceEqual(bytes.Take(bmp.Length)))
            {
                return ImageFormat.Bmp;
            }


            if (gif.SequenceEqual(bytes.Take(gif.Length)))
            {
                return ImageFormat.Gif;
            }


            if (png.SequenceEqual(bytes.Take(png.Length)))
            {
                return ImageFormat.Png;
            }


            if (tiff.SequenceEqual(bytes.Take(tiff.Length)))
            {
                return ImageFormat.Tiff;
            }


            if (tiff2.SequenceEqual(bytes.Take(tiff2.Length)))
            {
                return ImageFormat.Tiff;
            }


            if (jpeg.SequenceEqual(bytes.Take(jpeg.Length)))
            {
                return ImageFormat.Jpeg;
            }


            if (jpeg2.SequenceEqual(bytes.Take(jpeg2.Length)))
            {
                return ImageFormat.Jpeg;
            }


            return ImageFormat.Unknown;
        }
    }

new  ImageHelper   You need a binary array as a parameter, but that doesn’t mean you need to read all the contents of the file into memory. Using the following code can get better running effect:

    var fn = @"D:\1.jpg";
    using (var fs = File.OpenRead(fn))
    {
        var header = new byte[10];
        await fs.ReadAsync(header, 0, 10);
        var ext = ImageHelper.GetImageFormat(header);
        ext.Dump();
    }

Report error when using microwave “must either be declared abstract” abstract method “getWXPayDomain()” in WXPayConfig

report errors:

Handler dispatch failed; nested exception is java.lang.AbstractMethodError:“must either be declared abstract   abstract method ‘getWXPayDomain()’ in ‘WXPayConfig

The payment can not work normally

 
 
solve:

You need to download the Java version of the SDK package officially, and then open the wxpayconfig file

Add a public to all the abstract methods, and then package and install them locally to solve the problem

 
 
After watching, Congratulations, I know a little more!!!

The more you know, the more you don’t know!  
~ Thank you for reading,   Your support is the biggest motivation for my study!   come on.  , Strangers work together and encourage each other!!

Note: if there is any improvement or mistake in this article, you are welcome to specify one or two~~

net.sf.jasperreports.compilers.ReportExpressionEvaluationData

net.sf.jasperreports.compilers.ReportExpressionEvaluationData

net.sf.jasperreports.compilers.ReportExpressionEvaluationData

net.sf.jasperreports.compilers.ReportExpressionEvaluationData

An error occurred when using Jasper + ireport to generate report file
cause: Jasper uses version 5.6, which corresponds to ireport 5.6, and then uses Tibco Jaspersoft studio-6.16.0 to edit and compile the template, resulting in the addition of new elements of version 6.16 to the template and the use of jar package of Jasper 5.6 in the project, which causes the title exception, Because the lower version jar can’t compile the higher version elements.

Can’t Dubbo’s @ service be injected into the spring container?

Solution: rebuild the module and test again
when testing the Dubbo provider, adding @ service under the Dubbo path to the business implementation code will report that a test class is not injected
org.springframework.beans.factory.unsatisfied dependencyexception: error creating bean with name ‘com.tanhua.dubbo.server.api.testrecommenduserapi XXXXXX,
No qualifying bean of type ‘com. Tanhua. Dubbo. Server. API. Recommenduserapi’ available: (I think the interface recommenduserapi was not injected), so I replaced it with spring’s @ service line; But shouldn’t Dubbo’s @ service have spring’s @ service function?Baidu for a long time did not belong to their correct answer; After carefully checking the scan package, the annotation @ runwith (springrunner. Class) @ springboottest
on the test class has been added, and the @ service under Dubbo still reports an error
at last, the module was simply rebuilt by copying and pasting, and the final test was successful!! But what’s wrong?I don’t know. Maybe it’s related to building a module! Hope it works…

java.lang.AbstractMethodError: Receiver class com.alibaba.cloud.sentinel.feign.SentinelContractHolde

Caused by: java.lang.AbstractMethodError: Receiver class com.alibaba.cloud.sentinel.feign.SentinelContractHolder does not define or inherit an implementation of the resolved method abstract parseAndValidatateMetadata(Ljava/lang/Class;) Ljava/util/List; of interface feign.Contract.

When doing openfeign for sentinel service, I encountered the following errors:

according to the source code tracing, I found that there was a problem with the implementation class of feign’s contract interface. In my project springcloud, Sr1 version h, depends on the following:

the reason for the problem is that the version is inconsistent. For feign’s contract interface, 2.2.1 and 2.2.2 are different
2.2.1.RELEASE:

// TODO: break this and correct spelling at some point
List<MethodMetadata> parseAndValidatateMetadata(Class<?> targetType);

2.2.2.RELEASE:

List<MethodMetadata> parseAndValidateMetadata(Class<?> targetType);

In 2.2.1.release, there is a line of comment description. The spelling of interface method name is wrong. In 2.2.2.release, the method name has been corrected, that is, the method name has changed
the sentinelcontractholder class in spring cloud Alibaba sentinel uses this method of the interface (feign 2.2.1. Release version)


```java
@Override
public List<MethodMetadata> parseAndValidatateMetadata(Class<?> targetType) {
	List<MethodMetadata> metadatas = delegate.parseAndValidatateMetadata(targetType);
	metadatas.forEach(metadata -> METADATA_MAP
			.put(targetType.getName() + metadata.configKey(), metadata));
	return metadatas;
}

After finding out the reason, modify the implementation class of contract interface of feign. Create a package of com.alibaba.cloud.sentinel.feign in the appropriate place of the project. Modify the implementation class sentinelcontractholder as follows:

/**
 * @author geng
 * @create 2021/4/30 -- 10:47
 */
public class SentinelContractHolder implements Contract {
    private final Contract delegate;

    /**
     * map key is constructed by ClassFullName + configKey. configKey is constructed by
     * {@link feign.Feign#configKey}
     */
    public final static Map<String, MethodMetadata> METADATA_MAP = new HashMap<>();

    public SentinelContractHolder(Contract delegate) {
        this.delegate = delegate;
    }

    @Override
    public List<MethodMetadata> parseAndValidateMetadata(Class<?> targetType) {
        List<MethodMetadata> metadatas = delegate.parseAndValidateMetadata(targetType);
        metadatas.forEach(metadata -> METADATA_MAP
                .put(targetType.getName() + metadata.configKey(), metadata));
        return metadatas;
    }
}

Run again, start successfully!

Cannot resolve reference to bean ‘sqlSessionFactory‘ while setting bean property ‘sqlSessionFactory‘

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘collectionService’: Unsatisfied dependency expressed through field ‘collectionDao’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘collectionDao’ defined in file [E:\IdeaProjects\myMusic\target\track-stacking\WEB-INF\classes\com\hechenbo\trackstacking\dao\CollectionDao.class]: Cannot resolve reference to bean ‘sqlSessionFactory’ while setting bean property ‘sqlSessionFactory’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sqlSessionFactory’ defined in class path resource [bean.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type ‘java.lang.String’ to required type ‘org.springframework.core.io.Resource[]’ for property ‘mapperLocations’; nested exception is java.lang.IllegalArgumentException: Could not resolve resource location pattern [classpath:com/hechenbo/trackstacking/dao/impl/*.xml]: class path resource [com/hechenbo/trackstacking/dao/impl/] cannot be resolved to URL because it does not exist

Error creating bean with name ‘collectionDao’ defined in file [E:\IdeaProjects\myMusic\target\track-stacking\WEB-INF\classes\com\hechenbo\trackstacking\dao\CollectionDao.class]
maven will compile and package the file will miss the xml file, when starting tomcat can not find the xml file, in all configuration files are no problem, the target folder does not contain the mapping xml file.
The xml file is not packaged by maven under the target. Add it to the <build> tag in pom.xml:

<resources>
          <resource>
              <directory>src/main/java</directory>
              <includes>
                  <include>**/*.xml</include>
              </includes>
              <filtering>true</filtering>
          </resource>
      </resources>

Then clean in Maven and restart Tomcat to display the mapping XML file in the class directory

Uncaught TypeError: Cannot read property ‘toFixed‘ of null

Error chart:

when making the line chart , the data is obtained through Ajax , that is, clicking different values will display different charts, and then such an error occurs in the process of testing<
refer to several blogs:
ecarts.js report error cannot read property ‘ToFixed’ of null
it’s written very carefully, but it’s useless for my questions here ε=(´ο`*))) Alas

In the process of solving the above problems, the console has a warning there is a chart instance already initialized on the DOM (not in the screenshot above), and I want to know the problem to be solved, so I take a look at Baidu:
1, there is a chart instance already initialized on the DOM
2 Ecart notes – initialization and destruction
although this is not helpful for my problems, it makes me understand ecarts a little more. Let’s talk about the problems I have solved!

In fact, it’s very simple, I suddenly have an idea, try the next result is good
at the beginning, there are data (more than two), and graphics can be drawn
when you click other, the graph will not come out (at this time, there is only one data). After thinking about it, the line chart can be drawn from at least two data, ah!

Solution: there may be only one data

Cause: java.sql.BatchUpdateException: Unknown column ‘xxx‘ in ‘field list‘

Error 12164 – [xnio-1 TASK-2] p.p.c.s.c.globalexception handler resolver: Global exception information ex = com.xxx.cd.mapper.cdinvoiceinfomapper.insert (batch index # 1) failed———— Error information

Cause: java.sql.batchupdateexception: unknown column ‘xxx’ in ‘field list’ — prompt reason

Finding problems

First of all, the error prompt means that the field cannot be found in the database and the input is invalid

resolvent

    first check the database to see if there is this field in the table. If not, add it. Then add this field to the corresponding mapper.xml and entity class. If the above problems do not exist or cannot be solved, it is recommended to check on the web side to see if there is this missing data in your input data. If not, check the service layer, Open the configuration in Nacos, maintain the table directory in this field, and find that there is this table, but this table does not need this field. Remove this table from it, and then you can do it

Summary

Don’t be afraid when you make mistakes. It’s best to read the error information and the reason patiently, and understand the meaning roughly. If you don’t understand, ask your colleagues first.

Error assembling WAR: Problem creating war: Execution exception (and the archive is probably corrup

Using idea development, Maven build error:

 Error assembling WAR: Problem creating war: Execution exception (and the archive is probably corrupt but I could not delete it)

The cause of the error is that the memory of the JVM is not enough, so it’s better to configure it. The steps are as follows:

So we modify Maven’s JVM parameters directly in idea,

file-> setting-> Build,Execution,Deployment-> Maven-> Runner

Set the JVM parameter in VM option column, – xmx1g – XX: maxmetaspacesize = 128M

After setting, click Install on the right side to start the compilation, the parameter takes effect, and the maximum heap memory becomes 1g
0