JAVA Error Illegal access: this web application instance has been stopped already. Could not load net.sf

This exception occurs when you restart tomcat, but it does not affect the normal function.

Exception code:

Message: Illegal access: this web application instance has been stopped already.  Could not load net.sf.ehcache.store.disk.DiskStore$KeySet.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1776)
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1734)
	at net.sf.ehcache.store.disk.DiskStore.keySet(DiskStore.java:521)
	at net.sf.ehcache.store.disk.DiskStorageFactory$DiskExpiryTask.run(DiskStorageFactory.java:828)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)

Exception analysis: restart Tomcat repeatedly and frequently, resulting in the thread in the last tomat not closing normally
solutions:

Change the reloadable in server.xml in Tomcat from true to false.

After setting reloadable = “true”, Tomcat will monitor the source code of the project in real time, and restart the Tomcat server in case of any change. When debugging a program, relaodable = true is usually not set. It is unreasonable to restart Tomcat frequently. If you set reloadable = false, or do not set this property, only when you add, delete or rename method or instance fields, do you require the service to restart, which is suitable for you to debug programs.

File settings: server.xml & gt; reloadable=“false”。

PLSQL environment variable configuration tnsnames.ora file path

1、 Directory structure

D:\install\PLSQL
    |-- instantclient_11_2
        |-- tnsnames.ora
    |-- PLSQL Developer
    |-- readme.txt

2、 Environment variables
you must configure environment variables, otherwise the database fields will be added with random comments

NLS_LANG = SIMPLIFIED CHINESE_CHINA.ZHS16GBK

TNS_ADMIN = D:\install\PLSQL\instantclient_11_2

3、 PL/SQL developer environment settings

1. Location

    Tools -> Preferences -> Connections

2. Settings

    Oracle home directory name = D:\install\PLSQL\instantclient_11_2

    OCI library = D:\install\PLSQL\instantclient_11_2\oci.dll 

4. Supplement

The tnsnames.ora file needs to be created manually and set up accordingly, refer to the online tutorial.

Problem: you need to modify the tnsnames.ora file to configure the database connection, but you can’t find the path of the file. Many online searches say that it’s in the app directory of disk D, but you still can’t find it.

Solution: open PL/SQL and find help – & gt; Support information
after opening, you will see the PL/SQL version information and other configuration information. If you pull down, there will be a “TNS file”, which is the tnsnames.ora file path of the PL/SQL you installed. After modification, you need to restart PL/SQL

How to release Oracle PLSQL data lock table

(1)See which table is locked
select b.owner,b.object_name,a.session_id,a.locked_mode from vKaTeX parse error: Expected ‘EOF’, got ‘#’ at position 115: …,b.sid,b.serial#̲,logon_time fro…locked_object a,v$session b where a.session_id = b.sid order by b.logon_time;
(3)Kill the corresponding process
Execute the command: alter system kill session ‘1025,41’; (pay attention to the problem of spaces in the middle)
Here is the main point

---Lock table query SQL

SELECT object_name, machine, s.sid, s.serial# ,o.owner

FROM gv$locked_object l, dba_objects o, gv$session s 

WHERE l.object_id = o.object_id 

AND l.session_id = s.sid; 

Use this query to look up the locked object, the locking table device, and the sid and serial

2
--Force process shutdown

alter system kill session '1434, 2425';

Here 1434 and 2425 are the sid and serial of the previous query, respectively

3
--When 'ORA-00030: User session ID does not exist' appears

--query process number

select distinct s.sid,s.serial#,p.spid as system process number

from v$locked_object l , dba_objects o , v$session s , v$process p

where l.object_id=o.object_id and l.session_id=s.sid and s.paddr=p.addr;

4
Log in to the database server using the Xshell tool and execute the following command.

kill -9 system process number

The system process number is the spid queried in the previous step

 

At this point, the table locking problem can be solved perfectly!

How to get the current time in java time string

How to get the current time by Java
and convert it into java.sql.date format.

		long l = System.currentTimeMillis();
		//new date pair
		Date date = new Date(l);
		//convert to date output format
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		System.out.println(dateFormat.format(date)); 
		
		String response = dateFormat.format(date).replaceAll("[[\\s-:punct:]]","");
		System.out.println("response="+response);

2021-05-07 09:35:47response=202105

Non empty judgment method: the difference between isnotempty and isnotblank. isNullOrEmpty

In the project, we mostly use the non empty judgment method in stringutils. I believe most people have used the isnotempty or isempty method
public static Boolean isnotempty (string STR)
to judge whether a string is non empty, equal to! Isempty (string STR), where the space character cannot be excluded

Public static Boolean isnotblank (string STR)
to determine whether a string is not empty, its length is not 0, and it is not composed of whitespace! isBlank(String str)

Therefore, in many business logics, isnotblank is better than isnotempty. One is to judge whether the string is not empty and the length is not 0, and it is not composed of whitespace

isNullOrEmpty

StringUtils.IsNullOrEmpty(null) = true
StringUtils.IsNullOrEmpty("") = true
StringUtils.IsNullOrEmpty(" ") = true
StringUtils.IsNullOrEmpty("12345") = false
StringUtils.IsNullOrEmpty(" 12345 ") = false

When doing a query: List detail = systemService.findListbySql(getNewDataId);
Determine if it is emptyif (!ListUtils.isNullOrEmpty(detail)) {}

[Solved] Consider defining a bean of type ‘org.springframework.data.redis.core.RedisTemplate‘ in your configu

Today, I only added this paragraph to find that the project can’t start

@Autowired
private RedisTemplate<String, Object> template;

Project error report

Description:

Field template in com.yy.service.impl.YuumiUserServiceImpl required a bean of type 'org.springframework.data.redis.core.RedisTemplate' that could not be found.

The injection point has the following annotations:
	- @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'org.springframework.data.redis.core.RedisTemplate' in your configuration.

Solution:
Add Class

package com.yy.config;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.stereotype.Component; 

@Component
public class Config {

    @Bean(name = "template")
    public RedisTemplate<String, Object> template(RedisConnectionFactory factory) {
        // create RedisTemplate<String, Object>
        RedisTemplate<String, Object> template = new RedisTemplate<>();
        // Configuring the connection factory
        template.setConnectionFactory(factory);
        // Define the Jackson2JsonRedisSerializer serialization object
        Jackson2JsonRedisSerializer<Object> jacksonSeial = new Jackson2JsonRedisSerializer<>(Object.class);
        ObjectMapper om = new ObjectMapper();
        // Specify the fields to serialize, field, get and set, and the range of modifiers, ANY is both private and public
        om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
        // Specify the type of serialized input, the class must be non-final modified, final modified class, such as String, Integer, etc. will report an exception
        om.activateDefaultTyping(

                LaissezFaireSubTypeValidator.instance ,
                ObjectMapper.DefaultTyping.NON_FINAL,

                JsonTypeInfo.As.WRAPPER_ARRAY);
        jacksonSeial.setObjectMapper(om);
        StringRedisSerializer stringSerial = new StringRedisSerializer();
        // redis key Serialization method using stringSerial
        template.setKeySerializer(stringSerial);
        // redis value serialization method using jackson
        template.setValueSerializer(jacksonSeial);
        // redis hash key serialized using stringSerial
        template.setHashKeySerializer(stringSerial);
        // redis hash value serialized using jackson
        template.setHashValueSerializer(jacksonSeial);
        template.afterPropertiesSet();
        return template;
    }
}

The project runs successfully

Ant Design proformdigit fieldprops limits the number of decimal places entered

Proformdigit uses min limit to input the minimum value, Max limit to input the maximum value, fieldprops limit to input the decimal places

Keep two decimal places fieldprops = {precision: 2}}

<ProFormDigit 
	label="InputNumber" 
	name="num"
	min={1}
	max={22}
	fieldProps={{ precision: 2 }}
/>

fieldProps={{ precision: 0 }}

<ProFormDigit 
	label="InputNumber" 
	name="num"
	min={1}
	max={22}
	fieldProps={{ precision: 0 }}
/>

[Solved] org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.zyh.springboot.

Super detailed – springboot + mybatisplus can’t find a solution to mapper using XML
org.apache.ibatis.binding.bindingexception: invalid bound statement (not found): com.zyh.springboot.mapper.bowmapper.findlist
1. First, please look at my project directory, and my XML file is placed under mapper/XML

2, Add the following content in application.yml.
in fact, many students added mybatis plus at the beginning of the project, then add
mapper locations: classpath/COM/zyh/springboot/mapper/XML /. XML at the end.
note: there is no link between packages, such as com.zyh.springboot, which is incorrect
you can see that my mapper locations path is my XML path

#print sql code
mybatis-plus:
  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
    map-underscore-to-camel-case: true  
  type-aliases-package: com.zyh.springboot.entity
  mapper-locations: classpath*:/com/zyh/springboot/mapper/xml/*.xml

3. Add an XML resource to pom.xml. This step is very important. If you don’t add it, you will always report an error.
regardless of the path, you just need to fill in * /. XML

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </resource>
        </resources>
    </build>

4. Save the code, run the environment, and you can find the mapper

[Solved] RuntimeError: Trying to backward through the graph a second time…

RuntimeError: Trying to backward through the graph a second time, but the buffers have already been freed. Specify retain_graph=True when calling backward the first time.
torch.autograd.backward

torch.autograd.backward(tensors, grad_tensors=None, retain_graph=None, create_graph=False, grad_variables=None)

retain_ graph (bool, optional) – If False, the graph used to compute the grad will be freed. Note that in nearly all cases setting this option to True is not needed and often can be worked around in a much more efficient way.Defaults to the value of create_ graph.create_ graph (bool, optional) – If True, graph of the derivative will be constructed, allowing to compute higher order derivative products.Defaults to False.

retain_ graph = True (when to use it?)

retain_ Graph is a parameter that we can’t use in ordinary times, but we will use it in special cases

    1. when there are two outputs in a network that need to be backwarded respectively: output1. Backward(), output2. Backward(). When there are two losses in a network that need to be backwarded respectively: loss1. Backward(), loss1. Backward(). </ OL> when there are two outputs in a network that need to be backwarded respectively

Take case 2. For example,
if the code is written like this, the parameter at the beginning of the blog will appear:

loss1.backward()
loss2.backward()

Correct code:

loss1.backward(retain_graph=True) #Keep the intermediate arguments after backward.
loss2.backward() # All intermediate variables are freed for the next loop
optimizer.step() # update parameters

retain_ The graph parameter is true to keep the intermediate parameter, so that the backward() of two loss will not affect each other.

Supplement: when two losses of two networks need to be backwarded respectively for backhaul: loss1. Backward(), loss1. Backward()

#The case of two networks requires defining separate optimizers for each of the two networks
optimizer1= torch.optim.SGD(net1.parameters(), learning_rate, momentum,weight_decay)
optimizer2= torch.optim.SGD(net2.parameters(), learning_rate, momentum,weight_decay)
.....
#train Part of the loss return processing
loss1 = loss()
loss2 = loss()

optimizer1.zero_grad() #set the grade to zero
loss1.backward(retain_graph=True) #Keep the intermediate parameters after backward.
optimizer1.step()

optimizer2.zero_grad() #set the grade to zero
loss2.backward()
optimizer2.step()

scheduler = torch.optim.lr_ Scheduler. Steplr (
appendix:

Step explanation

optimizer.zero_ grad()

Initialize the gradient to zero
(because the derivative of loss of a batch with respect to weight is the sum of the derivative of loss with respect to weight of all samples)
corresponding to d_ weights = [0] * n

output = net(inputs)

The predicted value is obtained by forward propagation

loss = Loss(outputs, labels)

Ask for loss

loss.backward()

Back propagation for gradient
corresponding D_ weights = [d_ weights[j] + (label[k] – output ) * input[k][j] for j in range(n)]

optimizer.step()

Update all parameters
corresponding weights = [weights [k] + alpha * D_ weights[k] for k in range(n)]

[Solved] Python AssertionError: MMCV==1.1.0 is used but incompatible. Please install mmcv>=1.0.5, <=1.0.5.

Traceback (most recent call last):
  File "tools/test.py", line 12, in <module>
    from mmdet.apis import multi_gpu_test, single_gpu_test
  File "d:\a\a project\cv\mmdetection-master\mmdet\__init__.py", line 25, in <module>
    f'MMCV=={mmcv.__version__} is used but incompatible. ' \
AssertionError: MMCV==1.1.0 is used but incompatible. Please install mmcv>=1.0.5, <=1.0.5.
mmcv

The version needs to be 1.0.5, and the default installation is 1.1.0.

Unload mmcv first

pip uninstall mmcv
pip uninstall mmcv-full

Then install the version of mmcv as 1.0.5

pip install mmcv==1.0.5

Using shapely.geometry.polygon to calculate the IOU of any two quadrilaterals

The source is Mr. Bai Xiang of Huazhong University of science and technology.

import numpy as np 
import shapely
from shapely.geometry import Polygon,MultiPoint  #Polygon
 
line1=[2,0,2,2,0,0,0,0,2] #One-dimensional array representation of the coordinates of the four points of the quadrilateral, [x,y,x,y....]
a = np.array(line1).reshape(4, 2) # quadrilateral two-dimensional coordinate representation
poly1 = Polygon(a).convex_hull # python quadrilateral object, will automatically calculate four points, the last four points in the order of: top left bottom right bottom right top left top
print(Polygon(a).convex_hull) # you can print to see if this is the case

 
line2=[1,1,4,1,4,4,1,4]
b=np.array(line2).reshape(4, 2)
poly2 = Polygon(b).convex_hull
print(Polygon(b).convex_hull)
 
union_poly = np.concatenate((a,b))   #Merge two box coordinates to become 8*2
#print(union_poly)
print(MultiPoint(union_poly).convex_hull) # contains the smallest polygon point of the two quadrilaterals
if not poly1.intersects(poly2): #If the two quadrilaterals do not intersect
    iou = 0
else:
    try:
        inter_area = poly1.intersection(poly2).area #intersection area
        print(inter_area)
        #union_area = poly1.area + poly2.area - inter_area
        union_area = MultiPoint(union_poly).convex_hull.area
        print(union_area)
        if union_area == 0:
            iou= 0
        #iou = float(inter_area)/(union_area-inter_area)  #wrong
        iou=float(inter_area)/union_area
        # iou=float(inter_area) /(poly1.area+poly2.area-inter_area)
        # The source code gives two ways to calculate IOU, the first one is: intersection part / area of the smallest polygon containing two quadrilaterals  
        # The second one: intersection/merge (common way to calculate IOU of rectangular box) 
    except shapely.geos.TopologicalError:
        print('shapely.geos.TopologicalError occured, iou set to 0')
        iou = 0
 
print(a)
 
print(iou)

OS.Removedirs() and shutil.Rmtree() are used to delete the folder

summary

The OS. Removedirs () method is used to recursively delete a directory. Like rmdir (), if the subfolders are successfully deleted, removedirs () does not try their parent folder until an error is thrown (it is basically ignored because it generally means that your folder is not empty).

Grammar

The syntax format of the removedirs() method is as follows:

os.removedirs(path)

Parameters

path  — Directory path to remove

Return value

The method has no return value

example

The following example demonstrates the use of the removedirs() method:

import os,sys

import shutil

dstPath="test/"


print "Before directory deletion: %s" % os.listdir(dstPath)

# Recursively delete directories and files

# shutil.rmtree('test/aa')

# The following two functions are used to delete empty directory files

os.rmdir("test/aa")

#os.removedirs("test/aa")

print "After directory deletion: %s" % os.listdir(dstPath) 

Shutil module

shutil.copyfile( src, dst) # Copy from source src to dst. If the current dst already exists it will be overwritten

shutil.move( src, dst) # move the file or rename it

shutil.copymode( src, dst) #just copies its permissions, nothing else is copied

shutil.copystat( src, dst) #copy permissions, last access time, last modified time

shutil.copy( src, dst) #Copy a file to a file or a directory

shutil.copy2( src, dst) # copy the file last access time and modification time on top of the copy also copied over, similar to something like cp -p

shutil.copy2( src, dst) # if the two locations of the file system is the same then it is equivalent to rename operation, just change the name; if it is not in the same file system then it is to do the move operation

shutil.copytree( olddir, newdir, True/Flase) #Copy olddir to newdir, if the 3rd argument is True, then the symbolic link under the folder will be maintained when copying the directory, if the 3rd argument is False, then a physical copy will be generated in the copied directory instead of the symbolic Connections

shutil.rmtree( src ) # recursively delete a directory and all its contents