Processing method and device for preferentially loading class libraries by application server

By using the application layer class loader in the application server to read the preconfigured class library loading file and configure the priority class file attributes, the class loading conflict problem of the application server during the deployment and access stages is solved, and the priority loading of the correct class file and the normal operation of the application is achieved.

CN119149136BActive Publication Date: 2025-05-02SHANDONG CVICSE MIDDLEWARE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411612508.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-13
Publication Date
2025-05-02
Estimated Expiration
2044-11-13

AI Technical Summary

Technical Problem

During the application server deployment and access stage, there is a class loading conflict problem. It is mainly because there are multiple versions of the same class in the jar file class library. When the application server sorts the ASCII code value, it may find the wrong class file.

Method used

Read the preconfigured class library loading file through the pre-created application layer class loader, and configure the jar file that needs to be loaded first with the priority loading attribute to ensure that the correct class file is loaded first into the classpath. If the class file found is an incorrect file, adjust the class library loading file according to the preset deployment method to find the correct class file.

Benefits of technology

It effectively avoids class loading conflict issues, ensures the normal operation of WEB applications in the deployment and access stages, and enhances the compatibility and availability of application servers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119149136B_ABST
    Figure CN119149136B_ABST
Patent Text Reader

Abstract

The present application discloses a processing method and device for preferentially loading a class library of an application server, and relates to the technical field of data processing of an application server. A pre-configured class library loading file is read through a pre-created application layer class loader, and a class file is searched from the class library loading file through a preset search method, wherein the class file is a file containing a software package file format that is preferentially loaded corresponding to a preferentially loaded class file attribute. If it is detected that the class file is an erroneous class file, a WEB application is deployed according to a preset deployment method, so as to search for a correct class file through the WEB application, load the correct class file for access, and if access to the correct class file fails, an error prompt is generated, the class library loading file is reconfigured according to the error prompt, and the step of reading the pre-configured class library loading file through the pre-created application layer class loader is returned until the WEB application is successfully deployed and accessed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data processing of application servers, and more specifically, to a processing method and device for preferentially loading a class library of an application server. Background Art

[0002] For application servers, the importance of ensuring the normal operation of applications is self-evident. Being compatible with applications developed with various frameworks is the development trend of application servers. Currently, most World Wide Web (WEB) applications contain file libraries in the package file format (Java Archive, jar). Since applications are developed by different manufacturers, their specifications also vary.

[0003] During the deployment or access phase, a web application may search for class files in the web application jar file library. In the process of searching for class files, in some scenarios (i.e., non-standard scenarios), some jar files in the web application jar file library have multiple versions (such as a-1.0.jar, a-2.0.jar, etc.), that is, the same class has multiple class files in the web application jar file library, and the content of each class file is inconsistent. When the application server searches for class files in the web application jar file library, it searches by sorting the ASCII code value of the jar file name. It will first find the class file in the jar file with the American Standard Code for Information Interchange (ASCII) code value sorted first (such as a-1.0.jar). However, during the operation of the web application, it actually needs the class file in the higher version jar file (such as a-2.0.jar). Because the application is not written in a standard way, when searching for class files in the normal order, it actually finds the wrong class file, which leads to a series of class loading conflicts in the deployment and access phases of the web application.

[0004] Therefore, how to avoid class loading conflicts in the deployment or access phase of WEB applications is an urgent problem to be solved in this application. Summary of the invention

[0005] In view of this, the present application discloses a processing method and device for preferentially loading class libraries by an application server, aiming to avoid a series of class loading conflict problems in the deployment stage and access stage of WEB applications.

[0006] In order to achieve the above purpose, the disclosed technical solution is as follows:

[0007] In a first aspect, the present application discloses a processing method for preferentially loading a class library by an application server, the method comprising:

[0008] The pre-configured class library loading file is read by a pre-created application layer class loader; wherein the application layer class loader is created by a pre-configured WEB application; the class library loading file is a standard deployment description file under a class loading attribute tag;

[0009] Searching for a class file from the class library loading file by a preset search method; wherein the class file is a file containing a software package file format that is preferentially loaded corresponding to a preferentially loaded class file attribute;

[0010] If it is detected that the class file is an erroneous class file, deploy the WEB application according to a preset deployment method to search for the correct class file through the WEB application;

[0011] Load the correct class file for access;

[0012] If access to the correct class file fails, an error message is generated, the class library loading file is reconfigured according to the error message, and the process returns to the step of reading the pre-configured class library loading file through the pre-created application layer class loader until the WEB application is successfully deployed and accessed.

[0013] Preferably, the process of configuring the class library to load the file includes:

[0014] Define the deployment description file in the class library loading file, and configure the class loading attribute tag to obtain the configured deployment description file;

[0015] The configured deployment description file is stored in the standard folder directory of the WEB application to complete the process of configuring the class library to load the file.

[0016] Preferably, the reading of the pre-configured class library loading file by a pre-created application layer class loader includes:

[0017] Deploy the pre-configured WEB application to the application server;

[0018] Creating an application layer class loader corresponding to the pre-configured WEB application through the application server;

[0019] The application layer class loader parses the deployment description file in the pre-configured class library loading file to obtain a class loading attribute tag;

[0020] Read the class loading attribute tag to complete the process of reading the name of the preferred loaded class file configured by the priority loading class file attribute;

[0021] The names of the preferentially loaded class files configured by the priority loading class file attribute are stored in the priority loading class file array;

[0022] Traversing the priority loading class file array, and adding the class files in the priority loading class file array to the class path of the application layer class loader according to a first preset order; wherein the first preset order is determined by the order of all the priority loading class files configured in the class loading attribute tag;

[0023] The class files in the priority loading class file array in the class path of the application layer class loader are filtered according to a preset filtering method, and all the remaining class files in the WEB application class file library are added to the class path of the application layer class loader in sequence according to a second preset order to complete the process of reading the pre-configured class library loading files; wherein, all the remaining class files in the WEB application class file library are the class files remaining after filtering the class files in the priority loading class file array in the class path.

[0024] Preferably, searching for a class file from the class library loading file in a preset search method includes:

[0025] In the application deployment phase, the class files are searched from the class library loading files in the order defined in the class path of the application layer class loader;

[0026] In the application deployment phase, searching for class files from the class library loading files in the order defined in the class path of the application layer class loader includes:

[0027] During the application deployment phase, priority is given to searching for the class files that are configured for priority loading in the class path of the application layer class loader until all the class files that are configured for priority loading by the application layer class loader are searched for, and then all remaining class files in the WEB application class file library are searched according to the second preset order.

[0028] Preferably, if it is detected that the class file is an erroneous class file, deploying the WEB application according to a preset deployment mode to search for the correct class file through the WEB application includes:

[0029] If the class file reports an error during the actual deployment process, determining that the class file is an erroneous class file;

[0030] The class library loading file is adjusted according to the erroneous class file, so that the correct class file actually required by the WEB application is configured into the priority loading class file attribute of the deployment description file, so as to search for the correct class file through the WEB application.

[0031] Preferably, loading the correct class file for access includes:

[0032] In the access phase, the correct class file is loaded by the application layer class loader for access.

[0033] The second aspect of the present application discloses a processing device for preferentially loading a class library by an application server, the device comprising:

[0034] A reading unit, used for reading a pre-configured class library loading file through a pre-created application layer class loader; wherein the application layer class loader is created by a pre-configured WEB application; the class library loading file is a standard deployment description file under a class loading attribute tag;

[0035] A search unit, used to search for a class file from the class library loading file by a preset search method; wherein the class file is a file containing a software package file format that is preferentially loaded corresponding to a preferentially loaded class file attribute;

[0036] A deployment unit, configured to deploy the WEB application according to a preset deployment mode if it is detected that the class file is an erroneous class file, so as to search for a correct class file through the WEB application;

[0037] A loading unit, used for loading the correct class file for access;

[0038] A configuration unit is generated, which is used to generate an error prompt if access to the correct class file fails, reconfigure the class library loading file according to the error prompt, and return to the step of reading the pre-configured class library loading file through the pre-created application layer class loader until the WEB application is successfully deployed and accessed.

[0039] Preferably, the reading unit for configuring the class library loading file includes:

[0040] Define a configuration module, which is used to define the deployment description file in the class library loading file, and configure the class loading attribute tag to obtain the configured deployment description file;

[0041] The first storage module is used to store the configured deployment description file in a standard folder directory of the WEB application to complete the process of configuring the class library to load the file.

[0042] Preferably, the reading unit comprises:

[0043] Deployment module, used to deploy pre-configured WEB applications to application servers;

[0044] A creation module, used to create an application layer class loader corresponding to the pre-configured WEB application through the application server;

[0045] A parsing module, used to parse the deployment description file in the pre-configured class library loading file through the application layer class loader to obtain a class loading attribute tag;

[0046] A reading module, used for reading the class loading attribute tag to complete the process of reading the name of the preferred loaded class file configured by the priority loading class file attribute;

[0047] A second storage module, used for storing the names of the preferentially loaded class files configured by the priority loading class file attribute into the priority loading class file array;

[0048] A traversal module, used to traverse the priority loading class file array, and add the class files in the priority loading class file array to the class path of the application layer class loader according to a first preset order; wherein the first preset order is determined by the order of all the priority loading class files configured in the class loading attribute tag;

[0049] A filtering module is used to filter the class files in the priority loading class file array in the class path of the application layer class loader according to a preset filtering method, and add all the remaining class files in the WEB application class file class library to the class path of the application layer class loader in sequence according to a second preset order to complete the process of reading the pre-configured class library loading file; wherein, all the remaining class files in the WEB application class file class library are the class files remaining after filtering the class files in the priority loading class file array in the class path.

[0050] Preferably, the search unit includes:

[0051] A first search module is used to search for class files from the class library loading files in the order defined in the class path of the application layer class loader during the application deployment phase;

[0052] The first search module is specifically used for:

[0053] During the application deployment phase, priority is given to searching for the class files that are configured for priority loading in the class path of the application layer class loader until all the class files that are configured for priority loading by the application layer class loader are searched for, and then all remaining class files in the WEB application class file library are searched according to the second preset order.

[0054] It can be known from the above technical scheme that the present application discloses a processing method and device for preferentially loading a class library by an application server, wherein a pre-configured class library loading file is read by a pre-created application layer class loader, wherein the application layer class loader is created by a pre-configured WEB application; the class library loading file is a standard deployment description file under a class loading attribute tag, and a class file is searched from the class library loading file by a preset search method, wherein the class file is a file containing a software package file format that is preferentially loaded corresponding to a preferential loading class file attribute; if a class file is detected to be an erroneous class file, a WEB application is deployed according to a preset deployment method, so as to search for the correct class file through the WEB application, load the correct class file for access, and if access to the correct class file fails, an error prompt is generated, the class library loading file is reconfigured according to the error prompt, and the step of reading the pre-configured class library loading file by the pre-created application layer class loader is returned to until the WEB application is successfully deployed and accessed.

[0055] Through the above scheme, according to the class loading attribute priorLoadJars configured in the deployment description file, the files containing the software package file format that need to be loaded first can be configured. The application layer class loader parses this configuration and adds the correct files containing the software package file format that are configured to be loaded first to the front position of the application layer class loader class path. Even in the scenario where the application is not written in a standardized way, the correct class files in this part of the files containing the software package file format can be preferentially found when searching for class files subsequently, thereby avoiding a series of class loading conflict problems in the deployment stage or access stage of the WEB application. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0057] Figure 1 A flowchart of a method for preferentially loading a class library by an application server disclosed in an embodiment of the present application;

[0058] Figure 2 A flowchart of another processing method for preferentially loading a class library by an application server disclosed in an embodiment of the present application;

[0059] Figure 3 A schematic diagram of the structure of a processing device for preferentially loading a class library by an application server disclosed in an embodiment of the present application;

[0060] Figure 4This is a schematic diagram of the structure of an electronic device disclosed in an embodiment of the present application. DETAILED DESCRIPTION

[0061] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0062] In this application, the terms "comprises", "comprising" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element.

[0063] As can be seen from the background technology, WEB applications may search for class files from the WEB application jar file class library during the deployment phase or the access phase. In the process of searching for class files, there are some scenarios (i.e., non-standard scenarios) in which some jar files in the WEB application jar file class library have multiple versions (such as a-1.0.jar, a-2.0.jar, etc.), that is, the same class has multiple class files in the WEB application jar file class library, and the content in each class file is not consistent. When the application server searches for class files from the WEB application jar file class library, it searches by sorting the ASCII code value of the jar file name, and first finds the class files in the jar file with the front ASCII code value (such as a-1.0.jar), but the WEB application actually needs the class files in the high version jar file (such as a-2.0.jar) during operation. Because the application is not written in a standard way, when searching for class files in the normal order, the wrong class files are actually found, which leads to a series of class loading conflict problems in the WEB application during the deployment phase or the access phase. Therefore, how to avoid class loading conflicts in the deployment or access phase of WEB applications is an urgent problem to be solved in this application.

[0064] Normally, a class only has one class file in the WEB application jar file library. However, in some scenarios (non-standard application writing scenarios), some jar files in the WEB application jar file library have multiple versions (such as a-1.0.jar, a-2.0.jar, etc.), that is, the same class has multiple class files in the WEB application jar file library, and the content of each class file is not consistent. The application layer class loader (WebappClassLoader) searches for class files from the WEB application jar file library. Normally, it searches by sorting the ASCII code value of the jar file name (roughly understood as the English alphabetical order, such as a.jar -> b.jar->c.jar, etc.), that is, searching for class files in order. In some of the above scenarios, since there are multiple class files for the same class in the WEB application jar file class library, when WebappClassLoader searches for class files in order, it will first find the class files in the jar files with the higher ASCII code values ​​(such as a-1.0.jar). However, during the operation of the WEB application, the class files in the higher version jar files (such as a-2.0.jar) are actually required. At this time, if the class files are searched in the normal way, the wrong class files are actually found due to the non-standard application writing, resulting in a series of class loading conflicts during the deployment or access phase of the WEB application.

[0065] In order to solve the above problems, the present application discloses a processing method and device for preferentially loading class libraries by an application server. According to the class loading attribute priorLoadJars configured in the deployment description file, the files containing the software package file format that need to be loaded preferentially can be configured. The application layer class loader parses this configuration and adds the configured correct files containing the software package file format that are preferentially loaded to the front position of the application layer class loader class path. Even in the scenario where the application is not written in a standardized manner, the correct class files in this part of the files containing the software package file format can be preferentially searched when searching for class files subsequently, thereby avoiding a series of class loading conflict problems in the deployment stage or access stage of the WEB application.

[0066] Through this application, in some of the above-mentioned scenarios, when WebappClassLoader searches for class files from the WEB application jar file class library, it can find the class files in the correct jar file, so that the WEB application is successfully deployed and accessed, the WEB application runs normally, and a series of class loading conflict problems are solved. It improves the processing mechanism of application server class library loading, solves the class loading conflict problem caused by searching for class files from the WEB application jar file class library in some scenarios during the deployment stage or access stage of the WEB application, makes up for the shortcomings of the prior art, and allows application developers to flexibly develop applications, reduce the workload of operation and maintenance personnel, facilitate the operation of operation and maintenance personnel, enhance the compatibility of application servers, and ensure the normal and stable operation of applications. The specific implementation method is specifically described through the following embodiments.

[0067] refer to Figure 1 As shown, a processing method for preferentially loading a class library by an application server disclosed in an embodiment of the present application is shown, and the processing method for loading a class library by an application server mainly includes the following steps:

[0068] S101: reading a pre-configured class library loading file through a pre-created WebappClassLoader; wherein the WebappClassLoader is created by a pre-configured WEB application; and the class library loading file is a standard deployment description file under a class loading attribute tag.

[0069] Among them, when WebappClassLoader is first deployed, the application server creates an independent WebappClassLoader for each application to load class classes or resource files.

[0070] The application server is used to expose business logic to client programs through various protocols. It is used to run web applications and maintain their life cycle operating environment, and provide access to business logic for use by client applications.

[0071] WEB applications are generally browser / server (B / S) mode, and are applications accessed through a browser.

[0072] Currently, the application server itself supports class loading configuration tags. Under the class loading tag, add the priority loading class file (jar file) attribute (priorLoadJars). This priorLoadJars attribute is a custom attribute that can be used to configure the jar files that need to be loaded first. If there are multiple jar files, they are separated by semicolons. The specific operations are as follows:

[0073] First, define the deployment descriptor file (inforsuite-web.xml) in the class library loading file and configure the class loading property tag to obtain the configured inforsuite-web.xml.

[0074] The specific code for defining inforsuite-web.xml and configuring the class loading attribute tag is as follows:

[0075] <class-loader>

[0076] <property name="priorLoadJars" value="">< / property>

[0077] < / class-loader> .

[0078] Among them, class-loader is the class loading configuration tag defined in inforsuite-web.xml.

[0079] Property is a class loading property configuration tag defined under the class-loader tag. It has two attributes: name and value. PriorLoadJars is a custom attribute. Its purpose is to configure the jar files that need to be loaded first. Multiple jar files are separated by semicolons.

[0080] It should be noted that the value here can be temporarily configured as empty. When the application is deployed for the first time, the version of the jar file actually required by the application is not yet known. Therefore, it is not necessary to fill it in here. The configuration can be adjusted according to the actual situation later.

[0081] A jar file is a software package file format that is commonly used to aggregate a large number of Java class files, related metadata, and resource files into one file in order to develop Java platform applications or libraries.

[0082] A class, also known as a Java class, is an abstract data type that represents a collection of objects with specific properties and behaviors.

[0083] If the deployer already has an understanding of the application itself and can clearly identify the jar file version actually required by the application, it can be configured directly, such as:

[0084] <class-loader>

[0085] <property name="priorLoadJars" value="a-2.0.jar,b-2.0.jar">< / property>

[0086] < / class-loader> .

[0087] Then, store the configured deployment description file (inforsuite-web.xml) in the standard folder (WEB-INF) of the WEB application to complete the process of configuring the class library to load the file.

[0088] Among them, place the configured inforsuite-web.xml above in the WEB-INF directory of the WEB application so that the application server can read this configuration during subsequent deployment.

[0089] The WEB-INF directory is a standard folder under the WEB application.

[0090] The specific process of reading the pre-configured class library loading file through the pre-created WebappClassLoader is shown in A1-A7.

[0091] A1: Deploy the pre-configured web application to the application server.

[0092] A2: Use the application server to create a pre-configured WebappClassLoader corresponding to the WEB application.

[0093] Among them, at the very beginning of deployment, the application server will first create a corresponding WebappClassLoader for this WEB application.

[0094] A3: Use WebappClassLoader to parse the inforsuite-web.xml file in the pre-configured class library loading file to obtain the class loading attribute tag.

[0095] Among them, the class loading attribute tag refers to <class-loader>In the label <property>Attributes tab, <property>Multiple tags can be configured, that is, there can be multiple attribute tags with different names (that is, attribute tags with different functions). This application only involves an example of an attribute named priorLoadJars.

[0096] A4: Read the class loading attribute tag to complete the process of reading the name of the preferred loaded jar file configured by the priorLoadJars attribute.

[0097] A5: Store the names of the jar files to be loaded preferentially configured by the priorLoadJars attribute into the priority loading jar file array.

[0098] In A5, the name of the jar file to be loaded first configured by the priorLoadJars attribute is read out and stored in the jar file array to be loaded first.

[0099] A6: Traverse the priority loading jar file array and add the jar files in the priority loading class file array to the class path of WebappClassLoader according to a first preset order; wherein the first preset order is determined by the order of all the priority loading jar files configured in the class loading attribute tag.

[0100] In A6, the array of jar files to be loaded first is traversed, and the jar files in the array are added to the class path of WebappClassLoader in sequence by calling the add jar file method of WebappClassLoader. That is, all the jar files to be loaded first configured in the class loading attribute tag are added to the front position of the class path of WebappClassLoader.

[0101] In order to facilitate understanding of the process of adding the jar files in the array to the class path of WebappClassLoader in sequence by calling the add jar file method of WebappClassLoader, an example is given here to illustrate:

[0102] For example, the WEB application WEB-INF / lib directory contains the following jar files:

[0103] a-1.0.jar, a-2.0.jar, b-1.0.jar, b-2.0.jar. Normally, the order of the class path in the WEB application class loader is a-1.0.jar, a-2.0.jar, b-1.0.jar, b-2.0.jar (i.e., sorted by ASCII code);

[0104] After the following configuration:

[0105] <class-loader>

[0106] <property name="priorLoadJars" value="a-2.0.jar,b-2.0.jar">< / property>

[0107] < / class-loader> ;

[0108] The order becomes: a-2.0.jar, b-2.0.jar, a-1.0.jar, b-1.0.jar, that is, the jar files configured in the jar file properties are loaded first and placed at the front of the class path of the WEB application class loader. The remaining jar files are still sorted according to ASCII codes and placed at the back of the class path of the WEB application class loader.

[0109] ASCII code is a computer encoding system based on the Latin alphabet, and a total of 128 characters have been defined so far.

[0110] A7: Filter the jar files in the priority loading jar file array in the class path of WebappClassLoader according to the preset filtering method, and add all the remaining jar files in the WEB application jar file class library to the class path of WebappClassLoader in the second preset order (ASCII value order) to complete the process of reading the pre-configured class library loading file; wherein, all the remaining jar files in the WEB application jar file class library are the jar files remaining after filtering the jar files in the priority loading class file array in the class path.

[0111] The preset filtering method is to call the filtering file method of the file class of JDK.

[0112] It should be noted that at this time, since the jar files that are loaded first have been added to the class path of WebappClassLoader, the WEB application jar file class library needs to exclude these jar files. By calling the filter file method of the JDK file class, these jar files are excluded, and then the WebappClassLoader's add jar file method is continued to be called to add all the remaining jar files in the WEB application jar file class library to the class path of WebappClassLoader in ASCII value order. At this point, WebappClassLoader has been configured according to the class loading attribute tag, and all jar packages are added to the class path in the defined order.

[0113] JDK is a software development kit for the Java language.

[0114] WebappClassLoader parses the priorLoadJars property and places the configured priority jar files at the front of the WebappClassLoader class path, that is, class files in this part of the jar files are searched first when searching for classes later.

[0115] S102: searching for a class file from the class library loading file by a preset search method; wherein the class file is a jar file corresponding to the priority loading of the priorLoadJars attribute.

[0116] It should be noted that the preset search method refers to a method of searching for class files in the order defined in the class path of WebappClassLoader.

[0117] In S102, in the application deployment phase, the jar file corresponding to the priorLoadJars attribute is searched for the priority loading jar file from the class library loading file in the order defined in the class path of WebappClassLoader.

[0118] During the application deployment phase, the WEB application loads the required class files by calling the WebappClassLoader's class loading method. When searching for class files, the class files are searched in the order defined in the WebappClassLoader's class path, that is, the class files in the configured priority jar files are searched first, and then the class files in all other jar files in the WEB application jar file class library are searched in ASCII value order.

[0119] Specifically, in the application deployment stage, the class files in the jar files that are configured for priority loading in the class path of WebappClassLoader are searched first until all the class files in the jar files that are prioritized for loading by WebappClassLoader are searched, and all other jar files in the WEB application jar file class library are searched according to the second preset order.

[0120] The application deployment phase is the WEB application deployment phase. The WEB application deployment phase is the process of deploying the WEB application to the application server.

[0121] It should be noted that the WEB application jar file class library is the WEB-INF / lib directory, a standard directory under the WEB-INF directory. The WEB application jar file class library contains multiple jar files required for the WEB application to run.

[0122] S103: If the class file is detected to be an erroneous class file, the WEB application is deployed according to a preset deployment method, so as to search for the correct class file of the jar file through the WEB application.

[0123] It should be noted that the erroneous class file refers to the class file that actually reports an error during deployment.

[0124] The default deployment method is to readjust the class library loading file according to the actual deployment error, configure the correct jar file actually required by the WEB application into the priorLoadJars attribute of the inforsuite-web.xml deployment description file, and redeploy the WEB application.

[0125] In S103, if the class file reports an error during the actual deployment process, it is determined that the class file is an erroneous class file, and the class library loading file is adjusted according to the erroneous class file, so that the correct jar file actually required by the WEB application is configured into the priorLoadJars attribute of inforsuite-web.xml, so as to find the class file of the correct jar file through the WEB application.

[0126] In some scenarios (i.e., non-standard scenarios), some jar files in the jar file class library of the WEB application have multiple versions. The jar files actually required by the WEB application are not located at the front of the class path of the WebappClassLoader. The class files found in the normal order are those in the wrong jar files. In this case, you need to readjust the class library loading file according to the actual deployment error, configure the correct jar files actually required by the WEB application to the priorLoadJars attribute of the inforsuite-web.xml deployment description file, and redeploy the WEB application so that the WEB application can find the class files in the correct jar file.

[0127] The essence of S103 is to readjust the class library loading files according to the actual deployment error, and solve the class loading conflict problem that occurs in the WEB application deployment.

[0128] S104: Load the correct class file for access.

[0129] In S104, in the access phase of the WEB application, the correct class file is loaded for access through the WEB application and the way of loading class files of WebappClassLoader.

[0130] In the WEB application access phase, the WEB application loads the required class files by calling the load class method of WebappClassLoader, which is similar to the above application deployment phase. Please refer to the above application deployment phase and will not be repeated here.

[0131] The WEB application access phase is the process of accessing the WEB application through a browser after the WEB application is deployed.

[0132] S105: If access to the correct class file fails, an error message is generated, the class library loading file is reconfigured according to the error message, and the process returns to the step of reading the pre-configured class library loading file through the pre-created application layer class loader until the WEB application is successfully deployed and accessed.

[0133] Failed to access the correct class file. The cause and solution of this scenario are similar to deployment failure. You need to uninstall the application first, readjust the class library loading file, and redeploy the WEB application.

[0134] By continuously adjusting the above-mentioned class library loading configuration files, the class loading conflict problem of the WEB application is solved, and finally the WEB application is successfully deployed and accessed.

[0135] In order to facilitate the understanding of the application server class library loading process, combined with Figure 2 Give an example. Figure 2 Another processing method for the application server to load the class library preferentially is shown.

[0136] Figure 2 In the preparation, configure the library loading file;

[0137] Deploy the application, create WebappClassLoader and read the configured class library loading file;

[0138] In the application deployment phase, class files are searched through the WEB application to obtain the WEB application deployment results;

[0139] Determine whether the WEB application deployment result is deployed successfully;

[0140] If the WEB application deployment fails, an error message is generated. Reconfigure the class library loading file according to the error message, and return to the step of deploying the application, creating WebappClassLoader and reading the configured class library loading file.

[0141] If the WEB application deployment result is successfully deployed, in the access phase, the WEB application is deployed according to the preset deployment method to find the correct class file through the WEB application;

[0142] Load the correct class file to access, obtain the application access result, and determine whether the application access result is successful;

[0143] If the application access result indicates that the access is successful, it is determined that the WEB application is deployed successfully and the access is successful;

[0144] If the application access result indicates that the access failed, uninstall the WEB application, generate an error prompt corresponding to the access failure, reconfigure the class library loading file according to the error prompt, return to execute the deployment application, create a WebappClassLoader and read the configured class library loading file.

[0145] The class loading attribute priorLoadJars configured in the inforsuite-web.xml deployment descriptor file of this application can configure the jar files that need to be loaded first. WebappClassLoader parses this configuration and adds the configured jar files to the front of the WebappClassLoader class path, so that when searching for class files later, the class files in this part of jar files will be searched first. Even in the scenario where the application is not written in a standardized way, the correct class files in this part of jar files can be searched first when searching for class files later, avoiding a series of class loading conflicts in the deployment or access stage of WEB applications.

[0146] The advantages of this application are as follows:

[0147] (1) Web application developers can develop Web applications according to standard specifications;

[0148] (2) Web application developers can use the configuration class library loading file to solve the class loading conflict problem caused by the web application searching for class files;

[0149] (3) By configuring the jar file loading priority attribute, the application server can use the configuration method to be compatible with non-standard application scenarios without modifying the application, which enhances the compatibility of the application server and ensures the normal and stable operation of the application;

[0150] (4) By configuring the jar file loading priority attribute, the application server can use the configuration method to be compatible with non-standard application scenarios without modifying the application, thereby enhancing the availability of the application server and making the subsequent operation and maintenance of the application server and WEB application simple and easy, reducing the workload of the operation and maintenance personnel.

[0151] The beneficial effects of the embodiments of the present application are as follows: according to the class loading attribute priorLoadJars configured in the deployment description file, the files containing the software package file format that need to be loaded first can be configured, and the application layer class loader parses this configuration and adds the correct files containing the software package file format that are configured to be loaded first to the front position of the application layer class loader class path. Even in the scenario where the application is not written in a standardized manner, the correct class files in this part of the jar files can be preferentially searched when searching for class files subsequently, thereby avoiding a series of class loading conflict problems in the deployment stage or access stage of the WEB application.

[0152] Based on the above embodiments Figure 1 A processing method for preferentially loading a class library by an application server is disclosed. The embodiment of the present application also discloses a processing device for preferentially loading a class library by an application server, such as Figure 3 As shown, the processing device for loading the application server class library includes:

[0153] The reading unit 301 is used to read the pre-configured class library loading file through the pre-created application layer class loader; wherein the application layer class loader is created by the pre-configured WEB application; the class library loading file is a standard deployment description file under the class loading attribute tag;

[0154] A search unit 302 is used to search for a class file from the class library loading file by a preset search method; wherein the class file is a file containing a software package file format that is preferentially loaded corresponding to a preferentially loaded class file attribute;

[0155] The deployment unit 303 is used to deploy the WEB application according to a preset deployment mode if it is detected that the class file is an erroneous class file, so as to search for the correct class file through the WEB application;

[0156] A loading unit 304, used to load the correct class file for access;

[0157] The configuration generating unit 305 is used to generate an error message if access to the correct class file fails, reconfigure the class library loading file according to the error message, and return to the step of reading the pre-configured class library loading file through the pre-created application layer class loader until the WEB application is successfully deployed and accessed.

[0158] Furthermore, the configuration library loading file reading unit 301 includes:

[0159] Define a configuration module, which is used to define the deployment description file in the class library loading file, and configure the class loading attribute tag to obtain the configured deployment description file;

[0160] The first storage module is used to store the configured deployment description file in a standard folder directory of the WEB application to complete the process of configuring the class library to load the file.

[0161] Furthermore, the reading unit 301 includes:

[0162] Deployment module, used to deploy pre-configured WEB applications to application servers;

[0163] Create a module for creating an application layer class loader corresponding to a pre-configured WEB application through an application server;

[0164] A parsing module is used to parse the deployment description file in the pre-configured class library loading file through the application layer class loader to obtain the class loading attribute tag;

[0165] A reading module is used to read the class loading attribute tag to complete the process of reading the name of the preferred loaded class file configured by the priority loading class file attribute;

[0166] A second storage module is used to store the names of the preferentially loaded class files configured by the preferentially loaded class file attribute into the preferentially loaded class file array;

[0167] A traversal module, used for traversing the priority loading class file array, and adding the class files in the priority loading class file array to the class path of the application layer class loader according to a first preset order; wherein the first preset order is determined by the order of all the priority loading class files configured in the class loading attribute tag;

[0168] A filtering module is used to filter the class files in the priority loading class file array in the class path of the application layer class loader according to a preset filtering method, and add all the remaining class files in the WEB application class file class library to the class path of the application layer class loader in sequence according to a second preset order to complete the process of reading the pre-configured class library loading files; wherein, all the remaining class files in the WEB application class file class library are the class files remaining after filtering the class files in the priority loading class file array in the class path.

[0169] Furthermore, the searching unit 302 includes:

[0170] A search module is used to search for class files from class library loading files in the order defined in the class path of the application layer class loader during the application deployment phase;

[0171] The search module is specifically used to prioritize the class files configured in the class path of the application layer class loader for loading in the application deployment phase, until all the class files configured in the application layer class loader for loading are searched, and then search for all other class files in the WEB application class file library in a second preset order.

[0172] Further, the deployment unit 303 includes:

[0173] A determination module is used to determine that a class file is an erroneous class file if an error is reported during the actual deployment process of the class file;

[0174] The configuration module is used to adjust the class library loading file according to the erroneous class file, so that the correct class file actually required by the WEB application is configured into the priority loading class file attribute of the deployment description file, so as to enable the WEB application to find the correct class file.

[0175] Furthermore, the loading unit 304 is specifically used to load the correct class file for access through the application layer class loader during the access phase.

[0176] The beneficial effects of the embodiments of the present application are as follows: according to the class loading attribute priorLoadJars configured in the deployment description file, the files containing the software package file format that need to be loaded first can be configured, and the application layer class loader parses this configuration and adds the configured correct files containing the software package file format that are loaded first to the front position of the application layer class loader class path. Even in the scenario where the application is not written in a standardized manner, the correct class files in this part of the files containing the software package file format can be preferentially searched when searching for class files subsequently, thereby avoiding a series of class loading conflict problems in the deployment stage or access stage of the WEB application.

[0177] An embodiment of the present application further provides a storage medium, which includes stored instructions, wherein when the instructions are executed, the device where the storage medium is located is controlled to execute the processing method for loading the application server class library as described above.

[0178] The present application also provides an electronic device, whose structural diagram is as follows: Figure 4 As shown, it specifically includes a memory 401 and one or more instructions 402, wherein the one or more instructions 402 are stored in the memory 401 and are configured to be executed by one or more processors 403 to execute the one or more instructions 402 to execute the processing method for loading the above-mentioned application server class library.

[0179] For the aforementioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the order of the actions described, because according to the present application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.

[0180] It should be noted that each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the embodiments can be referred to each other. For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0181] The steps in the methods of the embodiments of the present application can be adjusted in order, combined, and deleted according to actual needs.

[0182] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are merely used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations.

[0183] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

[0184] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.< / property> < / property>

Claims

1. A processing method for preferentially loading a class library by an application server, characterized in that: The method comprises: The pre-configured class library loading file is read by a pre-created application layer class loader; wherein the application layer class loader is created by a pre-configured WEB application; the class library loading file is a standard deployment description file under a class loading attribute tag; Searching for a class file from the class library loading file by a preset search method; wherein the class file is a file containing a software package file format that is preferentially loaded corresponding to a preferentially loaded class file attribute; If it is detected that the class file is an erroneous class file, deploy the WEB application according to a preset deployment method to search for the correct class file through the WEB application; Load the correct class file for access; If access to the correct class file fails, an error message is generated, the class library loading file is reconfigured according to the error message, and the process returns to the step of reading the pre-configured class library loading file through the pre-created application layer class loader until the WEB application is successfully deployed and accessed.

2. The method according to claim 1, characterized in that The process of configuring the library to load files includes: Define the deployment description file in the class library loading file, and configure the class loading attribute tag to obtain the configured deployment description file; The configured deployment description file is stored in the standard folder directory of the WEB application to complete the process of configuring the class library to load the file.

3. The method according to claim 1, characterized in that The method of reading a pre-configured class library loading file through a pre-created application layer class loader includes: Deploy the pre-configured WEB application to the application server; Creating an application layer class loader corresponding to the pre-configured WEB application through the application server; The application layer class loader parses the deployment description file in the pre-configured class library loading file to obtain a class loading attribute tag; Read the class loading attribute tag to complete the process of reading the name of the preferred loaded class file configured by the priority loading class file attribute; The names of the preferentially loaded class files configured by the priority loading class file attribute are stored in the priority loading class file array; Traversing the priority loading class file array, and adding the class files in the priority loading class file array to the class path of the application layer class loader according to a first preset order; wherein the first preset order is determined by the order of all the priority loading class files configured in the class loading attribute tag; The class files in the priority loading class file array in the WEB application class file library are filtered according to a preset filtering method, and all the remaining class files in the WEB application class file library are added to the class path of the application layer class loader in sequence according to a second preset order to complete the process of reading the pre-configured class library loading files; wherein, all the remaining class files in the WEB application class file library are the class files remaining after filtering the class files in the priority loading class file array in the class path; and the second preset order is an ASCII value order.

4. The method according to claim 3, characterized in that: The searching for the class file from the class library loading file by using a preset searching method includes: In the application deployment phase, the class files are searched from the class library loading files in the order defined in the class path of the application layer class loader; In the application deployment phase, searching for class files from the class library loading files in the order defined in the class path of the application layer class loader includes: During the application deployment phase, priority is given to searching for the class files that are configured for priority loading in the class path of the application layer class loader until all the class files that are configured for priority loading by the application layer class loader are searched for, and then all remaining class files in the WEB application class file library are searched according to the second preset order.

5. The method according to claim 1, characterized in that: If it is detected that the class file is an erroneous class file, deploying the WEB application according to a preset deployment method to search for the correct class file through the WEB application includes: If the class file reports an error during the actual deployment process, determining that the class file is an erroneous class file; The class library loading file is adjusted according to the erroneous class file, so that the correct class file actually required by the WEB application is configured into the priority loading class file attribute of the deployment description file, so as to search for the correct class file through the WEB application.

6. The method according to claim 1, characterized in that The loading of the correct class file for access includes: In the access phase, the correct class file is loaded by the application layer class loader for access.

7. A processing device for preferentially loading a class library on an application server, characterized in that: The device comprises: A reading unit, used for reading a pre-configured class library loading file through a pre-created application layer class loader; wherein the application layer class loader is created by a pre-configured WEB application; the class library loading file is a standard deployment description file under a class loading attribute tag; A search unit, used to search for a class file from the class library loading file by a preset search method; wherein the class file is a file containing a software package file format that is preferentially loaded corresponding to a preferentially loaded class file attribute; A deployment unit, configured to deploy the WEB application according to a preset deployment mode if it is detected that the class file is an erroneous class file, so as to search for a correct class file through the WEB application; A loading unit, used for loading the correct class file for access; A configuration unit is generated, which is used to generate an error prompt if access to the correct class file fails, reconfigure the class library loading file according to the error prompt, and return to the step of reading the pre-configured class library loading file through the pre-created application layer class loader until the WEB application is successfully deployed and accessed.

8. The device according to claim 7, characterized in that Configure the reading unit of the library loading file, including: Define a configuration module, which is used to define the deployment description file in the class library loading file, and configure the class loading attribute tag to obtain the configured deployment description file; The first storage module is used to store the configured deployment description file in a standard folder directory of the WEB application to complete the process of configuring the class library to load the file.

9. The device according to claim 7, characterized in that The reading unit comprises: Deployment module, used to deploy pre-configured WEB applications to application servers; A creation module, used to create an application layer class loader corresponding to the pre-configured WEB application through the application server; A parsing module, used to parse the deployment description file in the pre-configured class library loading file through the application layer class loader to obtain a class loading attribute tag; A reading module, used for reading the class loading attribute tag to complete the process of reading the name of the preferred loaded class file configured by the priority loading class file attribute; A second storage module, used for storing the names of the preferentially loaded class files configured by the priority loading class file attribute into the priority loading class file array; A traversal module, used to traverse the priority loading class file array, and add the class files in the priority loading class file array to the class path of the application layer class loader according to a first preset order; wherein the first preset order is determined by the order of all the priority loading class files configured in the class loading attribute tag; A filtering module is used to filter the class files in the priority loading class file array in the WEB application class file library according to a preset filtering method, and add all the remaining class files in the WEB application class file library to the class path of the application layer class loader in sequence according to a second preset order to complete the process of reading the pre-configured class library loading file; wherein, all the remaining class files in the WEB application class file library are the class files remaining after filtering the class files in the priority loading class file array in the class path; the second preset order is the ASCII value order.

10. The device according to claim 9, characterized in that The searching unit comprises: A first search module is used to search for class files from the class library loading files in the order defined in the class path of the application layer class loader during the application deployment phase; The first search module is specifically used for: During the application deployment phase, priority is given to searching for the class files that are configured for priority loading in the class path of the application layer class loader until all the class files that are configured for priority loading by the application layer class loader are searched for, and then all remaining class files in the WEB application class file library are searched according to the second preset order.

Citation Information

Patent Citations

  • JAVA virtual machine class loading method and system

    CN112463303A

  • Application server patch upgrading method and device, electronic equipment and storage medium

    CN117270931A