Refactor/Disable Lift-specific schedulers and actor systems in Boot.scala; update pom.xml to upgrade classutil to 1.5.1 and configure maven-war-plugin with attachClasses; replace scala.jdk.CollectionConverters with scala.collection.JavaConverters for compatibility; add obp-http4s-runner module with fat JAR assembly configuration; update ClassScanUtils to handle UnsupportedOperationException from old ASM versions

This commit is contained in:
hongwei 2025-12-10 15:36:23 +01:00
parent 21f6314e4d
commit e3e32458c4
14 changed files with 149 additions and 40 deletions

View File

@ -42,6 +42,19 @@
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<unpack>true</unpack>
<scope>runtime</scope>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>${project.build.outputDirectory}</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>
</configuration>
<executions>
<execution>
@ -388,7 +401,7 @@
<dependency>
<groupId>org.clapper</groupId>
<artifactId>classutil_${scala.version}</artifactId>
<version>1.4.0</version>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>com.github.grumlimited</groupId>
@ -666,6 +679,8 @@
<version>3.4.0</version>
<configuration>
<webXml>${webXmlPath}</webXml>
<attachClasses>true</attachClasses>
<classesClassifier>classes</classesClassifier>
</configuration>
</plugin>
<plugin>

View File

@ -33,7 +33,7 @@ import code.UserRefreshes.MappedUserRefreshes
import code.accountapplication.MappedAccountApplication
import code.accountattribute.MappedAccountAttribute
import code.accountholders.MapperAccountHolders
import code.actorsystem.ObpActorSystem
//import code.actorsystem.ObpActorSystem
import code.api.Constant._
import code.api.ResourceDocs1_4_0.ResourceDocs300.{ResourceDocs310, ResourceDocs400, ResourceDocs500, ResourceDocs510, ResourceDocs600}
import code.api.ResourceDocs1_4_0._
@ -328,7 +328,7 @@ class Boot extends MdcLoggable {
createBootstrapSuperUser()
//launch the scheduler to clean the database from the expired tokens and nonces, 1 hour
DataBaseCleanerScheduler.start(intervalInSeconds = 60*60)
// DataBaseCleanerScheduler.start(intervalInSeconds = 60*60)
// if (Props.devMode || Props.testMode) {
// StoredProceduresMockedData.createOrDropMockedPostgresStoredProcedures()
@ -428,15 +428,15 @@ class Boot extends MdcLoggable {
logger.debug(s"If you can read this, logging level is debug")
val actorSystem = ObpActorSystem.startLocalActorSystem()
connector match {
case "akka_vDec2018" =>
// Start Actor system of Akka connector
ObpActorSystem.startNorthSideAkkaConnectorActorSystem()
case "star" if (APIUtil.getPropsValue("starConnector_supported_types","").split(",").contains("akka")) =>
ObpActorSystem.startNorthSideAkkaConnectorActorSystem()
case _ => // Do nothing
}
// val actorSystem = ObpActorSystem.startLocalActorSystem()
// connector match {
// case "akka_vDec2018" =>
// // Start Actor system of Akka connector
// ObpActorSystem.startNorthSideAkkaConnectorActorSystem()
// case "star" if (APIUtil.getPropsValue("starConnector_supported_types","").split(",").contains("akka")) =>
// ObpActorSystem.startNorthSideAkkaConnectorActorSystem()
// case _ => // Do nothing
// }
// where to search snippets
LiftRules.addToPackages("code")
@ -751,13 +751,13 @@ class Boot extends MdcLoggable {
TransactionScheduler.startAll()
APIUtil.getPropsAsBoolValue("enable_metrics_scheduler", true) match {
case true =>
val interval =
APIUtil.getPropsAsIntValue("retain_metrics_scheduler_interval_in_seconds", 3600)
MetricsArchiveScheduler.start(intervalInSeconds = interval)
case false => // Do not start it
}
// APIUtil.getPropsAsBoolValue("enable_metrics_scheduler", true) match {
// case true =>
// val interval =
// APIUtil.getPropsAsIntValue("retain_metrics_scheduler_interval_in_seconds", 3600)
// MetricsArchiveScheduler.start(intervalInSeconds = interval)
// case false => // Do not start it
// }
object UsernameLockedChecker {
def onBeginServicing(session: LiftSession, req: Req): Unit = {

View File

@ -50,7 +50,7 @@ import sh.ory.hydra.model.OAuth2TokenIntrospection
import java.net.URI
import scala.concurrent.Future
import scala.jdk.CollectionConverters.mapAsJavaMapConverter
import scala.collection.JavaConverters._
/**
* This object provides the API calls necessary to third party applications

View File

@ -8,7 +8,7 @@ import java.security.cert._
import java.util.{Base64, Collections}
import javax.net.ssl.TrustManagerFactory
import scala.io.Source
import scala.jdk.CollectionConverters._
import scala.collection.JavaConverters._
import scala.util.{Failure, Success, Try}
object CertificateVerifier extends MdcLoggable {
@ -69,8 +69,8 @@ object CertificateVerifier extends MdcLoggable {
trustManagerFactory.init(trustStore)
// Get trusted CAs from the trust store
val trustAnchors = trustStore.aliases().asScala
.filter(trustStore.isCertificateEntry)
val trustAnchors = enumerationAsScalaIterator(trustStore.aliases())
.filter(trustStore.isCertificateEntry(_))
.map(alias => trustStore.getCertificate(alias).asInstanceOf[X509Certificate])
.map(cert => new TrustAnchor(cert, null))
.toSet

View File

@ -17,7 +17,7 @@ import java.time.format.DateTimeFormatter
import java.time.{Duration, ZoneOffset, ZonedDateTime}
import java.util
import scala.collection.immutable.{HashMap, List}
import scala.jdk.CollectionConverters.seqAsJavaListConverter
import scala.collection.JavaConverters._
object JwsUtil extends MdcLoggable {

View File

@ -113,7 +113,7 @@ import java.util.{Calendar, Date}
import scala.collection.immutable.{List, Nil}
import scala.collection.mutable.ArrayBuffer
import scala.concurrent.Future
import scala.jdk.CollectionConverters.collectionAsScalaIterableConverter
import scala.collection.JavaConverters._
trait APIMethods400 extends MdcLoggable {
self: RestHelper =>

View File

@ -10,7 +10,7 @@ import org.apache.commons.lang3.StringUtils.uncapitalize
import java.io.File
import java.net.URL
import java.util.Date
import scala.jdk.CollectionConverters.enumerationAsScalaIteratorConverter
import scala.collection.JavaConverters._
import scala.language.postfixOps
import scala.reflect.runtime.universe._
import scala.reflect.runtime.{universe => ru}

View File

@ -45,7 +45,7 @@ import net.liftweb.util.Helpers._
import sh.ory.hydra.api.AdminApi
import sh.ory.hydra.model.{AcceptConsentRequest, RejectRequest}
import scala.jdk.CollectionConverters.seqAsJavaListConverter
import scala.collection.JavaConverters._
import scala.xml.NodeSeq

View File

@ -43,7 +43,7 @@ import org.apache.commons.lang3.StringUtils
import org.codehaus.jackson.map.ObjectMapper
import scala.collection.immutable.{List, ListMap}
import scala.jdk.CollectionConverters.seqAsJavaListConverter
import scala.collection.JavaConverters._
import scala.xml.{Text, Unparsed}
class ConsumerRegistration extends MdcLoggable {

View File

@ -35,7 +35,15 @@ object ClassScanUtils {
*/
def getSubTypeObjects[T:TypeTag]: List[T] = {
val clazz = ReflectUtils.typeTagToClass[T]
finder.getClasses().filter(_.implements(clazz.getName)).map(_.name).map(companion[T](_)).toList
val classes = try {
finder.getClasses().toList
} catch {
case _: UnsupportedOperationException =>
// ASM version is too old for some class files (e.g. requires ASM7). In that case,
// skip scanned APIs instead of failing the whole application.
Seq.empty
}
classes.filter(_.implements(clazz.getName)).map(_.name).map(companion[T](_)).toList
}
/**
@ -43,14 +51,22 @@ object ClassScanUtils {
* @param predict check whether include this type in the result
* @return all fit type names
*/
def findTypes(predict: ClassInfo => Boolean): List[String] = finder.getClasses()
.filter(predict)
.map(it => {
val name = it.name
if(name.endsWith("$")) name.substring(0, name.length - 1)
else name
}) //some companion type name ends with $, it added by scalac, should remove from class name
.toList
def findTypes(predict: ClassInfo => Boolean): List[String] = {
val classes = try {
finder.getClasses().toList
} catch {
case _: UnsupportedOperationException =>
Seq.empty
}
classes
.filter(predict)
.map(it => {
val name = it.name
if(name.endsWith("$")) name.substring(0, name.length - 1)
else name
}) //some companion type name ends with $, it added by scalac, should remove from class name
.toList
}
/**
* get given class exists jar Files
@ -71,7 +87,13 @@ object ClassScanUtils {
*/
def getMappers(packageName:String = ""): Seq[ClassInfo] = {
val mapperInterface = "net.liftweb.mapper.LongKeyedMapper"
val infos = finder.getClasses().filter(it => it.interfaces.contains(mapperInterface))
val classes = try {
finder.getClasses().toList
} catch {
case _: UnsupportedOperationException =>
Seq.empty
}
val infos = classes.filter(it => it.interfaces.contains(mapperInterface))
if(StringUtils.isNoneBlank()) {
infos.filter(classInfo => classInfo.name.startsWith(packageName))
} else {

View File

@ -15,7 +15,7 @@ import sh.ory.hydra.model.OAuth2Client
import sh.ory.hydra.{ApiClient, Configuration}
import scala.collection.immutable.List
import scala.jdk.CollectionConverters.{mapAsJavaMapConverter, seqAsJavaListConverter}
import scala.collection.JavaConverters._
object HydraUtil extends MdcLoggable{

View File

@ -33,7 +33,7 @@ import com.openbankproject.commons.model.ListResult
import com.openbankproject.commons.util.{ApiVersion, ScannedApiVersion}
import org.scalatest.Tag
import scala.jdk.CollectionConverters.collectionAsScalaIterableConverter
import scala.collection.JavaConverters._
class GetScannedApiVersionsTest extends V400ServerSetup {
/**

71
obp-http4s-runner/pom.xml Normal file
View File

@ -0,0 +1,71 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.tesobe</groupId>
<artifactId>obp-parent</artifactId>
<version>1.10.1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>obp-http4s-runner</artifactId>
<packaging>jar</packaging>
<name>OBP Http4s Runner</name>
<dependencies>
<!-- Use obp-api compiled classes as a normal JAR -->
<dependency>
<groupId>com.tesobe</groupId>
<artifactId>obp-api</artifactId>
<version>${project.version}</version>
<classifier>classes</classifier>
<type>jar</type>
<exclusions>
<!-- Exclude old classutil version if present -->
<exclusion>
<groupId>org.clapper</groupId>
<artifactId>classutil_${scala.version}</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Explicitly include classutil 1.5.1 to override any transitive dependencies -->
<dependency>
<groupId>org.clapper</groupId>
<artifactId>classutil_${scala.version}</artifactId>
<version>1.5.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<archive>
<manifest>
<mainClass>bootstrap.http4s.Http4sServer</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<appendAssemblyId>false</appendAssemblyId>
<finalName>obp-http4s-runner</finalName>
</configuration>
<executions>
<execution>
<id>make-fat-jar</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -35,6 +35,7 @@
<modules>
<module>obp-commons</module>
<module>obp-api</module>
<module>obp-http4s-runner</module>
</modules>
<repositories>