问:
All Quartz Scheduler worker threads are in waiting state due to this Quartz jobs are not getting triggered
Currently we are upgrading JBOSS from EAP 6.4 version to 7.4 version.
We are using quartz(2.3.2) for scheduling the jobs. Its looks like quartz scheduler is getting started and we have two scheduler: DefaultQuartzScheduler and the customised scheduler instance of our application(CgnmsQuartz).

Reference application logs:

```<code>[ch=AbstractQuartzScheduler][sev=INFO][tid=MSC service thread 1-2]: no custom quartz-config file found. falling back to the default config provided by quartz.
[ch=StdSchedulerFactory][sev=INFO][tid=MSC service thread 1-2]: Using default implementation for ThreadExecutor
[ch=SimpleThreadPool][sev=INFO][tid=MSC service thread 1-2]: Job execution threads will use class loader of thread: MSC service thread 1-2
[ch=SchedulerSignalerImpl][sev=INFO][tid=MSC service thread 1-2]: Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-2]: Quartz Scheduler v.2.3.2 created.
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-2]: JobFactory set to: org.apache.deltaspike.scheduler.impl.CdiAwareJobFactory@126fea5d
[ch=RAMJobStore][sev=INFO][tid=MSC service thread 1-2]: RAMJobStore initialized.
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-2][part=572.1/7]: Scheduler meta-data: Quartz Scheduler (v2.3.2) 'DefaultQuartzScheduler' with instanceId 'NON_CLUSTERED'
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-2][part=572.2/7]:   Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-2][part=572.3/7]:   NOT STARTED.
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-2][part=572.4/7]:   Currently in standby mode.
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-2][part=572.5/7]:   Number of jobs executed: 0
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-2][part=572.6/7]:   Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-2][part=572.7/7]:   Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.
[ch=StdSchedulerFactory][sev=INFO][tid=MSC service thread 1-2]: Quartz scheduler 'DefaultQuartzScheduler' initialized from an externally provided properties instance.
[ch=StdSchedulerFactory][sev=INFO][tid=MSC service thread 1-2]: Quartz scheduler version: 2.3.2
[ch=QuartzService][sev=INFO][tid=MSC service thread 1-6]: Create QuartzService(Quartz)...
[ch=QuartzService][sev=INFO][tid=MSC service thread 1-6]: QuartzService(Quartz) created.
[ch=QuartzService][sev=INFO][tid=MSC service thread 1-6]: Start QuartzService(Quartz)...
[ch=StdSchedulerFactory][sev=INFO][tid=MSC service thread 1-6]: Using default implementation for ThreadExecutor
[ch=SchedulerSignalerImpl][sev=INFO][tid=MSC service thread 1-6]: Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-6]: Quartz Scheduler v.2.3.2 created.
ch=JobStoreCMT][sev=INFO][tid=MSC service thread 1-6]: Using db table-based data access locking (synchronization).
[ch=JobStoreCMT][sev=INFO][tid=MSC service thread 1-6]: JobStoreCMT initialized.
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-6][part=594.1/7]: Scheduler meta-data: Quartz Scheduler (v2.3.2) 'CgnmsQuartz' with instanceId 'FND-Nayana1670481633032'
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-6][part=594.2/7]:   Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-6][part=594.3/7]:   NOT STARTED.
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-6][part=594.4/7]:   Currently in standby mode.
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-6][part=594.5/7]:   Number of jobs executed: 0
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-6][part=594.6/7]:   Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 320 threads.
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-6][part=594.7/7]:   Using job-store 'org.quartz.impl.jdbcjobstore.JobStoreCMT' - which supports persistence. and is clustered.
[ch=StdSchedulerFactory][sev=INFO][tid=MSC service thread 1-6]: Quartz scheduler 'CgnmsQuartz' initialized from an externally provided properties instance.
[ch=StdSchedulerFactory][sev=INFO][tid=MSC service thread 1-6]: Quartz scheduler version: 2.3.2
[ch=QuartzService][sev=INFO][tid=MSC service thread 1-6]: Skipping starting the scheduler (will not run jobs).
[ch=QuartzService][sev=INFO][tid=MSC service thread 1-6]: QuartzService(Quartz) started.
</code>```
```<code>Below is the quartz properties are set under jboss-service.xml:
</code>```
```<code>   <?xml version="1.0" encoding="UTF-8"?>
<server>

  <mbean code="org.quartz.ee.jmx.jboss.QuartzService" name="com.cisco.cgms:service=QuartzService">
    <attribute name="JndiName">Quartz</attribute>
    <!-- Do not start the scheduler when it is created.  The initialized plugin will start it once the system is up -->
    <attribute name="StartScheduler">false</attribute>
    <attribute name="Properties">
       org.quartz.scheduler.instanceName=CgnmsQuartz
       org.quartz.scheduler.instanceId=AUTO
       org.quartz.scheduler.rmi.export=false
       org.quartz.scheduler.rmi.proxy=false
       org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool
       org.quartz.threadPool.threadCount=${quartz.threadPool.threadCount}
       org.quartz.threadPool.threadPriority=4
       org.quartz.jobStore.misfireThreshold=60000
       org.quartz.scheduler.dbFailureRetryInterval=60000
       org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreCMT
       org.quartz.jobStore.driverDelegateClass=${quartz.jobstore.driver.delegate.class}
       org.quartz.jobStore.useProperties=false
       org.quartz.jobStore.tablePrefix=QRTZ_

       org.quartz.jobStore.dataSource=myDS
       org.quartz.dataSource.myDS.jndiURL=java:/DefaultDS
       org.quartz.jobStore.isClustered=true
       org.quartz.jobStore.clusterCheckinInterval=20000

       org.quartz.jobStore.nonManagedTXDataSource=myDS1
       org.quartz.jobStore.dontSetAutoCommitFalse=${autocommit.property.value}
       org.quartz.dataSource.myDS1.jndiURL=java:/DefaultDS
    </attribute>
      <!-- <attribute name="PropertiesFile">${jboss.server.config.url}/config-quartz.properties</attribute>-->
  </mbean>
</code>```

According to the thread dump collected, the quartz worker threads for instance CgnmsQuartz are  in waiting state:

```<code>CgnmsQuartz_QuartzSchedulerThread" #495 prio=5 os_prio=0 tid=0x000000000e7f1800 nid=0x4307 waiting on condition [0x00007f19cda23000]java.lang.Thread.State: TIMED_WAITING (sleeping)at java.lang.Thread.sleep(Native Method)at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:273)
</code>```
```<code>Locked ownable synchronizers:- None
</code>```
```<code>CgnmsQuartz_Worker-320" #494 prio=4 os_prio=0 tid=0x000000000e7ef800 nid=0x4306 in Object.wait() [0x00007f19cdb24000]java.lang.Thread.State: TIMED_WAITING (on object monitor)at java.lang.Object.wait(Native Method)at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:568)- locked <0x00000000d3c1b1c8> (a java.lang.Object)
</code>```
```<code>Locked ownable synchronizers:- None
</code>```

Moreover, we can see one exception related to quartz during the startup of the application:

```<code> An error occurred while scanning for the next triggers to fire.
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.2/16]: org.quartz.JobPersistenceException: Unexpected runtime exception: interface java.sql.Connection is not visible from class loader [See nested exception: java.lang.IllegalArgumentException: interface java.sql.Connection is not visible from class loader]
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.3/16]:         at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3890)
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.4/16]:         at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTriggers(JobStoreSupport.java:2802)
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.5/16]:         at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:287)
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.6/16]: Caused by: java.lang.IllegalArgumentException: interface java.sql.Connection is not visible from class loader
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.7/16]:         at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:581)
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.8/16]:         at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:557)
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.9/16]:         at java.lang.reflect.WeakCache$Factory.get(WeakCache.java:230)
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.10/16]:         at java.lang.reflect.WeakCache.get(WeakCache.java:127)
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.11/16]:         at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:419)
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.12/16]:         at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:719)
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.13/16]:         at org.quartz.impl.jdbcjobstore.JobStoreSupport.getAttributeRestoringConnection(JobStoreSupport.java:771)
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.14/16]:         at org.quartz.impl.jdbcjobstore.JobStoreCMT.getNonManagedTXConnection(JobStoreCMT.java:186)
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.15/16]:         at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3861)
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.16/16]:         ... 2 more

</code>```

The jobs are not getting trigger due to worker thread issue.
Please help us with your valuable inputs.

Body:
Currently we are upgrading JBOSS from EAP 6.4 version to 7.4 version.
We are using quartz(2.3.2) for scheduling the jobs. Its looks like quartz scheduler is getting started and we have two scheduler: DefaultQuartzScheduler and the customised scheduler instance of our application(CgnmsQuartz).

Reference application logs:

[ch=AbstractQuartzScheduler][sev=INFO][tid=MSC service thread 1-2]: no custom quartz-config file found. falling back to the default config provided by quartz.
[ch=StdSchedulerFactory][sev=INFO][tid=MSC service thread 1-2]: Using default implementation for ThreadExecutor
[ch=SimpleThreadPool][sev=INFO][tid=MSC service thread 1-2]: Job execution threads will use class loader of thread: MSC service thread 1-2
[ch=SchedulerSignalerImpl][sev=INFO][tid=MSC service thread 1-2]: Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-2]: Quartz Scheduler v.2.3.2 created.
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-2]: JobFactory set to: org.apache.deltaspike.scheduler.impl.CdiAwareJobFactory@126fea5d
[ch=RAMJobStore][sev=INFO][tid=MSC service thread 1-2]: RAMJobStore initialized.
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-2][part=572.1/7]: Scheduler meta-data: Quartz Scheduler (v2.3.2) 'DefaultQuartzScheduler' with instanceId 'NON_CLUSTERED'
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-2][part=572.2/7]:   Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-2][part=572.3/7]:   NOT STARTED.
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-2][part=572.4/7]:   Currently in standby mode.
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-2][part=572.5/7]:   Number of jobs executed: 0
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-2][part=572.6/7]:   Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-2][part=572.7/7]:   Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.
[ch=StdSchedulerFactory][sev=INFO][tid=MSC service thread 1-2]: Quartz scheduler 'DefaultQuartzScheduler' initialized from an externally provided properties instance.
[ch=StdSchedulerFactory][sev=INFO][tid=MSC service thread 1-2]: Quartz scheduler version: 2.3.2
[ch=QuartzService][sev=INFO][tid=MSC service thread 1-6]: Create QuartzService(Quartz)...
[ch=QuartzService][sev=INFO][tid=MSC service thread 1-6]: QuartzService(Quartz) created.
[ch=QuartzService][sev=INFO][tid=MSC service thread 1-6]: Start QuartzService(Quartz)...
[ch=StdSchedulerFactory][sev=INFO][tid=MSC service thread 1-6]: Using default implementation for ThreadExecutor
[ch=SchedulerSignalerImpl][sev=INFO][tid=MSC service thread 1-6]: Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-6]: Quartz Scheduler v.2.3.2 created.
ch=JobStoreCMT][sev=INFO][tid=MSC service thread 1-6]: Using db table-based data access locking (synchronization).
[ch=JobStoreCMT][sev=INFO][tid=MSC service thread 1-6]: JobStoreCMT initialized.
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-6][part=594.1/7]: Scheduler meta-data: Quartz Scheduler (v2.3.2) 'CgnmsQuartz' with instanceId 'FND-Nayana1670481633032'
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-6][part=594.2/7]:   Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-6][part=594.3/7]:   NOT STARTED.
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-6][part=594.4/7]:   Currently in standby mode.
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-6][part=594.5/7]:   Number of jobs executed: 0
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-6][part=594.6/7]:   Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 320 threads.
[ch=QuartzScheduler][sev=INFO][tid=MSC service thread 1-6][part=594.7/7]:   Using job-store 'org.quartz.impl.jdbcjobstore.JobStoreCMT' - which supports persistence. and is clustered.
[ch=StdSchedulerFactory][sev=INFO][tid=MSC service thread 1-6]: Quartz scheduler 'CgnmsQuartz' initialized from an externally provided properties instance.
[ch=StdSchedulerFactory][sev=INFO][tid=MSC service thread 1-6]: Quartz scheduler version: 2.3.2
[ch=QuartzService][sev=INFO][tid=MSC service thread 1-6]: Skipping starting the scheduler (will not run jobs).
[ch=QuartzService][sev=INFO][tid=MSC service thread 1-6]: QuartzService(Quartz) started.

Below is the quartz properties are set under jboss-service.xml:

   <?xml version="1.0" encoding="UTF-8"?>
<server>

  <mbean code="org.quartz.ee.jmx.jboss.QuartzService" name="com.cisco.cgms:service=QuartzService">
    <attribute name="JndiName">Quartz</attribute>

    <attribute name="StartScheduler">false</attribute>
    <attribute name="Properties">
       org.quartz.scheduler.instanceName=CgnmsQuartz
       org.quartz.scheduler.instanceId=AUTO
       org.quartz.scheduler.rmi.export=false
       org.quartz.scheduler.rmi.proxy=false
       org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool
       org.quartz.threadPool.threadCount=${quartz.threadPool.threadCount}
       org.quartz.threadPool.threadPriority=4
       org.quartz.jobStore.misfireThreshold=60000
       org.quartz.scheduler.dbFailureRetryInterval=60000
       org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreCMT
       org.quartz.jobStore.driverDelegateClass=${quartz.jobstore.driver.delegate.class}
       org.quartz.jobStore.useProperties=false
       org.quartz.jobStore.tablePrefix=QRTZ_

       org.quartz.jobStore.dataSource=myDS
       org.quartz.dataSource.myDS.jndiURL=java:/DefaultDS
       org.quartz.jobStore.isClustered=true
       org.quartz.jobStore.clusterCheckinInterval=20000

       org.quartz.jobStore.nonManagedTXDataSource=myDS1
       org.quartz.jobStore.dontSetAutoCommitFalse=${autocommit.property.value}
       org.quartz.dataSource.myDS1.jndiURL=java:/DefaultDS
    </attribute>

  </mbean>

According to the thread dump collected, the quartz worker threads for instance CgnmsQuartz are  in waiting state:

CgnmsQuartz_QuartzSchedulerThread" #495 prio=5 os_prio=0 tid=0x000000000e7f1800 nid=0x4307 waiting on condition [0x00007f19cda23000]java.lang.Thread.State: TIMED_WAITING (sleeping)at java.lang.Thread.sleep(Native Method)at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:273)

Locked ownable synchronizers:- None

CgnmsQuartz_Worker-320" #494 prio=4 os_prio=0 tid=0x000000000e7ef800 nid=0x4306 in Object.wait() [0x00007f19cdb24000]java.lang.Thread.State: TIMED_WAITING (on object monitor)at java.lang.Object.wait(Native Method)at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:568)- locked <0x00000000d3c1b1c8> (a java.lang.Object)

Locked ownable synchronizers:- None

Moreover, we can see one exception related to quartz during the startup of the application:

 An error occurred while scanning for the next triggers to fire.
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.2/16]: org.quartz.JobPersistenceException: Unexpected runtime exception: interface java.sql.Connection is not visible from class loader [See nested exception: java.lang.IllegalArgumentException: interface java.sql.Connection is not visible from class loader]
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.3/16]:         at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3890)
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.4/16]:         at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTriggers(JobStoreSupport.java:2802)
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.5/16]:         at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:287)
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.6/16]: Caused by: java.lang.IllegalArgumentException: interface java.sql.Connection is not visible from class loader
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.7/16]:         at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:581)
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.8/16]:         at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:557)
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.9/16]:         at java.lang.reflect.WeakCache$Factory.get(WeakCache.java:230)
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.10/16]:         at java.lang.reflect.WeakCache.get(WeakCache.java:127)
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.11/16]:         at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:419)
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.12/16]:         at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:719)
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.13/16]:         at org.quartz.impl.jdbcjobstore.JobStoreSupport.getAttributeRestoringConnection(JobStoreSupport.java:771)
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.14/16]:         at org.quartz.impl.jdbcjobstore.JobStoreCMT.getNonManagedTXConnection(JobStoreCMT.java:186)
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.15/16]:         at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3861)
[tid=CgnmsQuartz_QuartzSchedulerThread][part=41092.16/16]:         ... 2 more

The jobs are not getting trigger due to worker thread issue.
Please help us with your valuable inputs.


来源: stackexchange

问:
comparing json data with number In DB
I have stored the number in JSON column in the database

number

[1245]

[8252]

I want to use greater than and less than on  Json number with sequlize ORM

i have used it on  JSON column in the database

```<code>const result =   await ServiceRecurring.findAll(where : { number : { [Op.or] : { [Op.gte] : +start , [Op.lte] : +end } } } , raw: true});

</code>```

but it returns wrong data;

ContentLicense: CC BY-SA 4.0

Title: comparing json data with number In DB

Body:
I have stored the number in JSON column in the database

number

[1245]

[8252]

I want to use greater than and less than on  Json number with sequlize ORM

i have used it on  JSON column in the database

const result =   await ServiceRecurring.findAll(where : { number : { [Op.or] : { [Op.gte] : +start , [Op.lte] : +end } } } , raw: true});

but it returns wrong data;


问:
React Native errors for flatList after switching between screens
I am new to React Native. I modified the following code to fetch data from API and it works fine. But when I use the component in two screens and I repeatedly switch between the screens, it starts showing this error.

ERROR  TypeError: null is not an object (evaluating 'this.flatList.scrollToOffset')
ERROR  TypeError: undefined is not an object (evaluating 'this.flatList')

Code:

```<code>    import React, { useState, useEffect } from 'react'
import { View, Text, StyleSheet, Dimensions, FlatList, Animated } from 'react-native'
import Slide from '../screens/Slide'

const { width, heigth } = Dimensions.get('window')
let flatList

function infiniteScroll(dataList){
    const numberOfData = dataList.length
    let scrollValue = 0, scrolled = 0

    setInterval(function() {
        scrolled ++
        if(scrolled < numberOfData)
        scrollValue = scrollValue + width

        else{
            scrollValue = 0
            scrolled = 0
        }

        this.flatList.scrollToOffset({ animated: true, offset: scrollValue})

    }, 3000)
}

const Banner = () => {
    const scrollX = new Animated.Value(0)
    let position = Animated.divide(scrollX, width)
    const [data, setData] = useState([])
    const [dataList, setDataList] = useState(data)
    const [isLoading, setLoading] = useState(true);

    const getBanners = async () => {
      try {
       const response = await fetch('http://10.0.2.2:8000/api/banners');
       const json = await response.json();
       setData(json.banners);
     } catch (error) {
       console.error(error);
     } finally {
       setLoading(false);
     }
   }

    useEffect(()=> {
      getBanners()
        setDataList(data)
        infiniteScroll(dataList)
    }, [])

    if (data && data.length) {
        return (
            <View>
                <FlatList data={data}
                ref = {(flatList) => {this.flatList = flatList}}
                    keyExtractor={(item, index) => 'key' + index}
                    horizontal
                    pagingEnabled
                    scrollEnabled
                    snapToAlignment="center"
                    scrollEventThrottle={16}
                    decelerationRate={"fast"}
                    showsHorizontalScrollIndicator={false}
                    renderItem={({ item }) => {
                        return <Slide item={item} />
                    }}
                    onScroll={Animated.event(
                      [{nativeEvent: {contentOffset: {x: scrollX}}}],
                      {useNativeDriver: false}
                      )}
                />

                <View style={styles.dotView}>
                    {data.map((_, i) => {
                        let opacity = position.interpolate({
                            inputRange: [i - 1, i, i + 1],
                            outputRange: [0.3, 1, 0.3],
                            extrapolate: 'clamp'
                        })
                        return (
                            <Animated.View
                                key={i}
                                style={{ opacity, height: 10, width: 10, backgroundColor: '#595959', margin: 8, borderRadius: 5 }}
                            />
                        )
                    })}

                </View>
            </View>
        )
    }

    return null
}

const styles = StyleSheet.create({
    dotView: { flexDirection: 'row', justifyContent: 'center' }
})

export default Banner
</code>```

Body:
I am new to React Native. I modified the following code to fetch data from API and it works fine. But when I use the component in two screens and I repeatedly switch between the screens, it starts showing this error.

ERROR  TypeError: null is not an object (evaluating 'this.flatList.scrollToOffset')
ERROR  TypeError: undefined is not an object (evaluating 'this.flatList')

Code:

    import React, { useState, useEffect } from 'react'
import { View, Text, StyleSheet, Dimensions, FlatList, Animated } from 'react-native'
import Slide from '../screens/Slide'

const { width, heigth } = Dimensions.get('window')
let flatList

function infiniteScroll(dataList){
    const numberOfData = dataList.length
    let scrollValue = 0, scrolled = 0

    setInterval(function() {
        scrolled ++
        if(scrolled < numberOfData)
        scrollValue = scrollValue + width

        else{
            scrollValue = 0
            scrolled = 0
        }

        this.flatList.scrollToOffset({ animated: true, offset: scrollValue})

    }, 3000)
}

const Banner = () => {
    const scrollX = new Animated.Value(0)
    let position = Animated.divide(scrollX, width)
    const [data, setData] = useState([])
    const [dataList, setDataList] = useState(data)
    const [isLoading, setLoading] = useState(true);

    const getBanners = async () => {
      try {
       const response = await fetch('http://10.0.2.2:8000/api/banners');
       const json = await response.json();
       setData(json.banners);
     } catch (error) {
       console.error(error);
     } finally {
       setLoading(false);
     }
   }

    useEffect(()=> {
      getBanners()
        setDataList(data)
        infiniteScroll(dataList)
    }, [])

    if (data && data.length) {
        return (
            <View>
                <FlatList data={data}
                ref = {(flatList) => {this.flatList = flatList}}
                    keyExtractor={(item, index) => 'key' + index}
                    horizontal
                    pagingEnabled
                    scrollEnabled
                    snapToAlignment="center"
                    scrollEventThrottle={16}
                    decelerationRate={"fast"}
                    showsHorizontalScrollIndicator={false}
                    renderItem={({ item }) => {
                        return <Slide item={item} />
                    }}
                    onScroll={Animated.event(
                      [{nativeEvent: {contentOffset: {x: scrollX}}}],
                      {useNativeDriver: false}
                      )}
                />

                <View style={styles.dotView}>
                    {data.map((_, i) => {
                        let opacity = position.interpolate({
                            inputRange: [i - 1, i, i + 1],
                            outputRange: [0.3, 1, 0.3],
                            extrapolate: 'clamp'
                        })
                        return (
                            <Animated.View
                                key={i}
                                style={{ opacity, height: 10, width: 10, backgroundColor: '#595959', margin: 8, borderRadius: 5 }}
                            />
                        )
                    })}

                </View>
            </View>
        )
    }

    return null
}

const styles = StyleSheet.create({
    dotView: { flexDirection: 'row', justifyContent: 'center' }
})

export default Banner


问:
Dynamic RabbitMQ per user request Kubernetes
I have. I have a web application that processes video streams. Users can stream live video / or video file to Receiver Pods, and these Master Pods will spawn new Processing Pods, to handle each user request. It will also create a new queue to store these video frames, and the Processing Pods will read and process these video streams (bytes or frames) and stream back to the Receiver Pod and back to the user. When video live stream is done, the Processing pods should be destroyed. The protocol used for communication will be websocket.

Is this possible with RabbitMQ?

I came across this question, but it was asked almost a decade ago

Dynamic queue creation with RabbitMQ

I am not sure now with Kubernetes, if this is feasible and/or a good idea


问:
Using same angular app in same webpage wrapped with iframe
There is a web page: webpage.com.
I have an angular app hosted on angular.com.

```<code>"@angular/animations": "^13.3.11",
"@angular/cdk": "^12.2.12",
"@angular/common": "^13.3.11",
"@angular/compiler": "^13.3.11",
"@angular/core": "^13.3.11",
"@angular/forms": "^13.3.11",
"@angular/material": "^12.2.12",
"@angular/platform-browser": "^13.3.11",
"@angular/platform-browser-dynamic": "^13.3.11",
"@angular/router": "^13.3.11",
"@ngrx/effects": "^13.2.0",
"@ngrx/store": "^13.2.0",
"@ngrx/store-devtools": "^13.2.0",
</code>```

Use case: I want to use angular.com app inside webpage.com using iframes. I want to add multiple iframes having src="angular.com".

the structure should look like this:

```<code><body>
   <iframe src="angular.com"></iframe>

   <iframe src="angular.com"></iframe>
</body>
</code>```

If the apps load the same data, everything works, if I need different data to be loaded, it's broken.

After debugging, both apps are loading and running correctly, but there are some errors while accessing data from store in components (undefined and null).

Is it possible to achieve this type of functionality using angular and ngrx store?

Body:
There is a web page: webpage.com.
I have an angular app hosted on angular.com.

"@angular/animations": "^13.3.11",
"@angular/cdk": "^12.2.12",
"@angular/common": "^13.3.11",
"@angular/compiler": "^13.3.11",
"@angular/core": "^13.3.11",
"@angular/forms": "^13.3.11",
"@angular/material": "^12.2.12",
"@angular/platform-browser": "^13.3.11",
"@angular/platform-browser-dynamic": "^13.3.11",
"@angular/router": "^13.3.11",
"@ngrx/effects": "^13.2.0",
"@ngrx/store": "^13.2.0",
"@ngrx/store-devtools": "^13.2.0",

Use case: I want to use angular.com app inside webpage.com using iframes. I want to add multiple iframes having src="angular.com".

the structure should look like this:

If the apps load the same data, everything works, if I need different data to be loaded, it's broken.

After debugging, both apps are loading and running correctly, but there are some errors while accessing data from store in components (undefined and null).

Is it possible to achieve this type of functionality using angular and ngrx store?


问:
XMonad toggle window create/close
I have a key bind that create a terminal window floating at the center of the screen.

```<code>runInCenterTerm :: String -> String -> X ()
runInCenterTerm t cmd = do
  r <- fmap (screenRect . W.screenDetail . W.current) (gets windowset)
  spawnAndDo (doRectFloat $ adjust r) $ intercalate " " [ t
                                                        , cmd ]

where
  adjust (Rectangle sx sy sw sh) = W.RationalRect x y w h
    where
      w = min (1200 / (fromIntegral sw)) 1
      h = min (600  / (fromIntegral sh)) 1
      x = (1 - w) / 2
      y = (1 - h) / 2
</code>```

And I want that the same key bind close this window if it exists.

What is the best way to implement this behavior in XMonad?

I was thinking about setting a X property in the window and later query if a window have this property.

Title: XMonad toggle window create/close

Body:
I have a key bind that create a terminal window floating at the center of the screen.

runInCenterTerm :: String -> String -> X ()
runInCenterTerm t cmd = do
  r <- fmap (screenRect . W.screenDetail . W.current) (gets windowset)
  spawnAndDo (doRectFloat $ adjust r) $ intercalate " " [ t
                                                        , cmd ]

where
  adjust (Rectangle sx sy sw sh) = W.RationalRect x y w h
    where
      w = min (1200 / (fromIntegral sw)) 1
      h = min (600  / (fromIntegral sh)) 1
      x = (1 - w) / 2
      y = (1 - h) / 2

And I want that the same key bind close this window if it exists.

What is the best way to implement this behavior in XMonad?

I was thinking about setting a X property in the window and later query if a window have this property.


问:
how to add new page at the start of the pdf while exporting it from html using jspdf
function Convert_HTML_To_PDF() {
const doc = new jsPDF();

```<code>// Source HTMLElement or a string containing HTML.
const elementHTML = document.getElementById("contentToPrint");

doc.html(elementHTML, {
    callback: function(doc) {
         doc.addPage()
        // Save the PDF
        doc.save('document-html.pdf');
    },
    margin: [10, 10, 10, 10],
    autoPaging: 'text',
    x: 0,
    y: 0,
    width: 190, //target width in the PDF document
    windowWidth: 675 //window width in CSS pixels
});
</code>```

}

I know that there is a function in jspdf named "doc.addPage()" but I want the new page to be added at the start of the pdf. When I add this function it always add new page at the end of the pdf.

How can I do that? so, it will add page at the start.

Body:
function Convert_HTML_To_PDF() {
const doc = new jsPDF();

// Source HTMLElement or a string containing HTML.
const elementHTML = document.getElementById("contentToPrint");

doc.html(elementHTML, {
    callback: function(doc) {
         doc.addPage()
        // Save the PDF
        doc.save('document-html.pdf');
    },
    margin: [10, 10, 10, 10],
    autoPaging: 'text',
    x: 0,
    y: 0,
    width: 190, //target width in the PDF document
    windowWidth: 675 //window width in CSS pixels
});

}

I know that there is a function in jspdf named "doc.addPage()" but I want the new page to be added at the start of the pdf. When I add this function it always add new page at the end of the pdf.

How can I do that? so, it will add page at the start.


问:
Kafka-PySpark: "earliest" or "latest" not getting recognized as offests
I have a Kafka-PySpark streaming code that reads the topic.

I have the kafka configuration given in a kafka.yml file where I have specified the startingOffsets:

```<code>checkpointLocation: "/user/aiman/checkpoint/kafka_checkpoint/test_topic"
kafka.bootstrap.servers: "kafka.server.com:9093"
subscribe: "TEST_TOPIC"
startingOffsets: {"TEST_TOPIC": {"0":-2}}
kafka.security.protocol: "SSL"
kafka.ssl.keystore.location: "kafka.keystore.uat.jks"
kafka.ssl.keystore.password: "abc123"
kafka.ssl.key.password: "abc123"
kafka.ssl.truststore.type: "JKS"
kafka.ssl.truststore.location: "kafka.truststore.uat.jks"
kafka.ssl.truststore.password: "abc123"
kafka.ssl.enabled.protocols: "TLSv1"
kafka.ssl.endpoint.identification.algorithm: ""
</code>```

When I set the offset to:

```<code>startingOffsets: "earliest"
</code>```

I get the following error:

```<code>Traceback (most recent call last):
  File "/opt/cloudera/parcels/IMMUTA/python/pyspark/sql/utils.py", line 63, in deco
    return f(*a, **kw)
  File "/opt/cloudera/parcels/IMMUTA/python/lib/py4j-0.10.7-src.zip/py4j/protocol.py", line 328, in get_return_value
py4j.protocol.Py4JJavaError: An error occurred while calling o193.load.
: java.lang.IllegalArgumentException: Expected e.g. {"topicA":{"0":23,"1":-1},"topicB":{"0":-2}}, got "earliest"
        at org.apache.spark.sql.kafka010.JsonUtils$.partitionOffsets(JsonUtils.scala:74)
        at org.apache.spark.sql.kafka010.KafkaSourceProvider$.getKafkaOffsetRangeLimit(KafkaSourceProvider.scala:485)
        at org.apache.spark.sql.kafka010.KafkaSourceProvider.createMicroBatchReader(KafkaSourceProvider.scala:128)
        at org.apache.spark.sql.kafka010.KafkaSourceProvider.createMicroBatchReader(KafkaSourceProvider.scala:48)
        at org.apache.spark.sql.streaming.DataStreamReader.load(DataStreamReader.scala:183)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
        at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
        at py4j.Gateway.invoke(Gateway.java:282)
        at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
        at py4j.commands.CallCommand.execute(CallCommand.java:79)
        at py4j.GatewayConnection.run(GatewayConnection.java:238)
        at java.lang.Thread.run(Thread.java:748)
</code>```

Similarly when I give the offset as:

```<code>startingOffsets: "latest"
</code>```

I get the error:

```<code>Traceback (most recent call last):
  File "/opt/cloudera/parcels/IMMUTA/python/pyspark/sql/utils.py", line 63, in deco
    return f(*a, **kw)
  File "/opt/cloudera/parcels/IMMUTA/python/lib/py4j-0.10.7-src.zip/py4j/protocol.py", line 328, in get_return_value
py4j.protocol.Py4JJavaError: An error occurred while calling o193.load.
: java.lang.IllegalArgumentException: Expected e.g. {"topicA":{"0":23,"1":-1},"topicB":{"0":-2}}, got "latest"
        at org.apache.spark.sql.kafka010.JsonUtils$.partitionOffsets(JsonUtils.scala:74)
        at org.apache.spark.sql.kafka010.KafkaSourceProvider$.getKafkaOffsetRangeLimit(KafkaSourceProvider.scala:485)
        at org.apache.spark.sql.kafka010.KafkaSourceProvider.createMicroBatchReader(KafkaSourceProvider.scala:128)
        at org.apache.spark.sql.kafka010.KafkaSourceProvider.createMicroBatchReader(KafkaSourceProvider.scala:48)
        at org.apache.spark.sql.streaming.DataStreamReader.load(DataStreamReader.scala:183)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
        at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
        at py4j.Gateway.invoke(Gateway.java:282)
        at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
        at py4j.commands.CallCommand.execute(CallCommand.java:79)
        at py4j.GatewayConnection.run(GatewayConnection.java:238)
        at java.lang.Thread.run(Thread.java:748)
</code>```

And when I set the offset as blank:

```<code>startingOffsets: {"TEST_TOPIC": {}}
</code>```

I get the error:

```<code>pyspark.sql.utils.StreamingQueryException: 'Failed to construct kafka consumer\n=== Streaming Query ===\nIdentifier: [id = a8799b99-2040-49f1-a155-58f64bbef78d, runId = 600b728d-bfe5-41fc-90d1-40f6bbc5d35c]\nCurrent Committed Offsets: {}\nCurrent Available Offsets: {}\n\nCurrent State: ACTIVE\nThread State: RUNNABLE\n\nLogical Plan:\nProject [cast(key#7 as string) AS key#21, cast(value#8 as string) AS value#22, offset#11L, timestamp#12, partition#10]\n+- StreamingExecutionRelation KafkaV2[Subscribe["TEST_TOPIC"]], [key#7, value#8, topic#9, partition#10, offset#11L, timestamp#12, timestampType#13]\n'
</code>```

How do I make it work, assuming if there is no data present in a topic (as the error states "Current Committed Offsets: {}\nCurrent Available Offsets: {}")

Body:
I have a Kafka-PySpark streaming code that reads the topic.

I have the kafka configuration given in a kafka.yml file where I have specified the startingOffsets:

checkpointLocation: "/user/aiman/checkpoint/kafka_checkpoint/test_topic"
kafka.bootstrap.servers: "kafka.server.com:9093"
subscribe: "TEST_TOPIC"
startingOffsets: {"TEST_TOPIC": {"0":-2}}
kafka.security.protocol: "SSL"
kafka.ssl.keystore.location: "kafka.keystore.uat.jks"
kafka.ssl.keystore.password: "abc123"
kafka.ssl.key.password: "abc123"
kafka.ssl.truststore.type: "JKS"
kafka.ssl.truststore.location: "kafka.truststore.uat.jks"
kafka.ssl.truststore.password: "abc123"
kafka.ssl.enabled.protocols: "TLSv1"
kafka.ssl.endpoint.identification.algorithm: ""

When I set the offset to:

startingOffsets: "earliest"

I get the following error:

Traceback (most recent call last):
  File "/opt/cloudera/parcels/IMMUTA/python/pyspark/sql/utils.py", line 63, in deco
    return f(*a, **kw)
  File "/opt/cloudera/parcels/IMMUTA/python/lib/py4j-0.10.7-src.zip/py4j/protocol.py", line 328, in get_return_value
py4j.protocol.Py4JJavaError: An error occurred while calling o193.load.
: java.lang.IllegalArgumentException: Expected e.g. {"topicA":{"0":23,"1":-1},"topicB":{"0":-2}}, got "earliest"
        at org.apache.spark.sql.kafka010.JsonUtils$.partitionOffsets(JsonUtils.scala:74)
        at org.apache.spark.sql.kafka010.KafkaSourceProvider$.getKafkaOffsetRangeLimit(KafkaSourceProvider.scala:485)
        at org.apache.spark.sql.kafka010.KafkaSourceProvider.createMicroBatchReader(KafkaSourceProvider.scala:128)
        at org.apache.spark.sql.kafka010.KafkaSourceProvider.createMicroBatchReader(KafkaSourceProvider.scala:48)
        at org.apache.spark.sql.streaming.DataStreamReader.load(DataStreamReader.scala:183)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
        at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
        at py4j.Gateway.invoke(Gateway.java:282)
        at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
        at py4j.commands.CallCommand.execute(CallCommand.java:79)
        at py4j.GatewayConnection.run(GatewayConnection.java:238)
        at java.lang.Thread.run(Thread.java:748)

Similarly when I give the offset as:

startingOffsets: "latest"

I get the error:

Traceback (most recent call last):
  File "/opt/cloudera/parcels/IMMUTA/python/pyspark/sql/utils.py", line 63, in deco
    return f(*a, **kw)
  File "/opt/cloudera/parcels/IMMUTA/python/lib/py4j-0.10.7-src.zip/py4j/protocol.py", line 328, in get_return_value
py4j.protocol.Py4JJavaError: An error occurred while calling o193.load.
: java.lang.IllegalArgumentException: Expected e.g. {"topicA":{"0":23,"1":-1},"topicB":{"0":-2}}, got "latest"
        at org.apache.spark.sql.kafka010.JsonUtils$.partitionOffsets(JsonUtils.scala:74)
        at org.apache.spark.sql.kafka010.KafkaSourceProvider$.getKafkaOffsetRangeLimit(KafkaSourceProvider.scala:485)
        at org.apache.spark.sql.kafka010.KafkaSourceProvider.createMicroBatchReader(KafkaSourceProvider.scala:128)
        at org.apache.spark.sql.kafka010.KafkaSourceProvider.createMicroBatchReader(KafkaSourceProvider.scala:48)
        at org.apache.spark.sql.streaming.DataStreamReader.load(DataStreamReader.scala:183)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
        at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
        at py4j.Gateway.invoke(Gateway.java:282)
        at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
        at py4j.commands.CallCommand.execute(CallCommand.java:79)
        at py4j.GatewayConnection.run(GatewayConnection.java:238)
        at java.lang.Thread.run(Thread.java:748)

And when I set the offset as blank:

startingOffsets: {"TEST_TOPIC": {}}

I get the error:

pyspark.sql.utils.StreamingQueryException: 'Failed to construct kafka consumer\n=== Streaming Query ===\nIdentifier: [id = a8799b99-2040-49f1-a155-58f64bbef78d, runId = 600b728d-bfe5-41fc-90d1-40f6bbc5d35c]\nCurrent Committed Offsets: {}\nCurrent Available Offsets: {}\n\nCurrent State: ACTIVE\nThread State: RUNNABLE\n\nLogical Plan:\nProject [cast(key#7 as string) AS key#21, cast(value#8 as string) AS value#22, offset#11L, timestamp#12, partition#10]\n+- StreamingExecutionRelation KafkaV2[Subscribe["TEST_TOPIC"]], [key#7, value#8, topic#9, partition#10, offset#11L, timestamp#12, timestampType#13]\n'

How do I make it work, assuming if there is no data present in a topic (as the error states "Current Committed Offsets: {}\nCurrent Available Offsets: {}")


问:
Store multiple data before upload in array PHP
I'm trying to get data in the form of an array from a file to upload, but when I try to upload some data at the same time, I only get 1 data.
How can I get all the data from all the files I uploaded?</p>
```<code>foreach($img_desc as $key => $val)
                            {
                                $newname = $getFileName."-".date('YmdHis',time()).mt_rand().'.jpg';

                                $target = 'uploaded/'.$newname;
                                $tmp = $val['tmp_name'];

                                move_uploaded_file($tmp, $target);

                                $qChkLastID = oci_parse($c1, "SELECT * FROM WA_SW_TBL_UPLOAD_RECORD WHERE TO_CHAR(DATE_UPLOADED, 'YYYY-MON') = '$date_codeFormat'");

                                oci_execute($qChkLastID);

                            if(oci_fetch($qChkLastID) > 0)
                            {
                                $qGetLastID = oci_parse($c1, "SELECT * FROM(SELECT * FROM WA_SW_TBL_UPLOAD_RECORD ORDER BY RECORD_ID DESC) WHERE ROWNUM <= 1 AND TO_CHAR(DATE_UPLOADED, 'YYYY-MON') = '$date_codeFormat'");
                                oci_execute($qGetLastID);
                                $dGetLastID = oci_fetch_array($qGetLastID);

                                $getLastID = $dGetLastID['RECORD_ID'];

                            }
                            else
                            {
                                $dateCode = date("Ym");
                                $id_num = 1;
                                $id_num = str_pad($id_num, 6, "0", STR_PAD_LEFT);
                                $new_id = "SW".$dateCode . $id_num;
                            }

                                $qInsertRecord = oci_parse($c1, "INSERT INTO WA_SW_TBL_UPLOAD_RECORD(RECORD_ID, FILE_NAME, UPLOAD_DESTINATION, DATE_UPLOADED, UPLOADED_BY)
                                VALUES('$new_id', '$newname', '$getDestinationFolder', TO_DATE('$date_added', 'dd-MON-yyyy hh24:mi:ss'), '$getUserID')
                            ");
                            oci_execute($qInsertRecord);
                            }

                            $getResult = "swUploadAdded";
                            $data = array(
                            "result" => $getResult,
                            "recordID" => $new_id,
                            "fileName" => $newname,
                            "uploadDestination" => "$getDestinationFolder",
                            "dateUploaded" => $date_added,
                            "uploadedBy" => $getUsername
                            );
                            }
</code>```

Body:
I'm trying to get data in the form of an array from a file to upload, but when I try to upload some data at the same time, I only get 1 data.
How can I get all the data from all the files I uploaded?

foreach($img_desc as $key => $val)
                            {
                                $newname = $getFileName."-".date('YmdHis',time()).mt_rand().'.jpg';

                                $target = 'uploaded/'.$newname;
                                $tmp = $val['tmp_name'];

                                move_uploaded_file($tmp, $target);

                                $qChkLastID = oci_parse($c1, "SELECT * FROM WA_SW_TBL_UPLOAD_RECORD WHERE TO_CHAR(DATE_UPLOADED, 'YYYY-MON') = '$date_codeFormat'");

                                oci_execute($qChkLastID);

                            if(oci_fetch($qChkLastID) > 0)
                            {
                                $qGetLastID = oci_parse($c1, "SELECT * FROM(SELECT * FROM WA_SW_TBL_UPLOAD_RECORD ORDER BY RECORD_ID DESC) WHERE ROWNUM <= 1 AND TO_CHAR(DATE_UPLOADED, 'YYYY-MON') = '$date_codeFormat'");
                                oci_execute($qGetLastID);
                                $dGetLastID = oci_fetch_array($qGetLastID);

                                $getLastID = $dGetLastID['RECORD_ID'];

                            }
                            else
                            {
                                $dateCode = date("Ym");
                                $id_num = 1;
                                $id_num = str_pad($id_num, 6, "0", STR_PAD_LEFT);
                                $new_id = "SW".$dateCode . $id_num;
                            }

                                $qInsertRecord = oci_parse($c1, "INSERT INTO WA_SW_TBL_UPLOAD_RECORD(RECORD_ID, FILE_NAME, UPLOAD_DESTINATION, DATE_UPLOADED, UPLOADED_BY)
                                VALUES('$new_id', '$newname', '$getDestinationFolder', TO_DATE('$date_added', 'dd-MON-yyyy hh24:mi:ss'), '$getUserID')
                            ");
                            oci_execute($qInsertRecord);
                            }

                            $getResult = "swUploadAdded";
                            $data = array(
                            "result" => $getResult,
                            "recordID" => $new_id,
                            "fileName" => $newname,
                            "uploadDestination" => "$getDestinationFolder",
                            "dateUploaded" => $date_added,
                            "uploadedBy" => $getUsername
                            );
                            }


问:
Is it possible to run openfoam from a bash script in an org-mode sourceblock?
I have an org-mode document and would like to run openfoam from a sourceblock. As OS I use Windows 10 where I have openfoam installed in an Ubuntu WSL (Windows subsystem for Linux) environment.

Basically I think that bash scripts are recognized and executed correctly by org, because this example gives correct output:

```<code>#+begin_src bash :results output
  lsb_release -a
#+end_src

#+RESULTS:
: Distributor ID:   Ubuntu
: Description:  Ubuntu 20.04 LTS
: Release:  20.04
: Codename: focal
</code>```

But this code block here returns an error message

```<code>#+begin_src bash :results output
  gmshToFoam geometry.msh
#+end_src

bash: line 1: gmshToFoam: command not found
</code>```

I suspect that an environment variable is missing because the command is not recognized. When I start the Linux shell manually the command is recognized. Is it possible that the $HOME/.bashrc file is not loaded by org?

Body:
I have an org-mode document and would like to run openfoam from a sourceblock. As OS I use Windows 10 where I have openfoam installed in an Ubuntu WSL (Windows subsystem for Linux) environment.

Basically I think that bash scripts are recognized and executed correctly by org, because this example gives correct output:

#+begin_src bash :results output
  lsb_release -a
#+end_src

#+RESULTS:
: Distributor ID:   Ubuntu
: Description:  Ubuntu 20.04 LTS
: Release:  20.04
: Codename: focal

But this code block here returns an error message

#+begin_src bash :results output
  gmshToFoam geometry.msh
#+end_src

bash: line 1: gmshToFoam: command not found

I suspect that an environment variable is missing because the command is not recognized. When I start the Linux shell manually the command is recognized. Is it possible that the $HOME/.bashrc file is not loaded by org?


问:
Running useFetch SSR (Server Side) but I see the XHR request client side
I'm using Nuxt3 in combination of Pinia. In pinia I have a function to authorize a user like:

```<code>async login (credentials: User) {

var requestOptions = {
  method: 'POST',
  body: {
    email: 'test@test.com',
    password: 'testpass'
  }
};
  const { data: user }: any = await useFetch('https://endpoint.com/api/user/create-token', requestOptions)
  console.log(user.value.result.token)

  JwtService.saveToken(user.value.result.token)
},
</code>```

Everything works fine as I get a token from the endpoint. The problem is; I want this fetch POST being fired at the server and not at the client. Currently I see the XHR in my client. How to fix this?

Application is running as SSR.

Body:
I'm using Nuxt3 in combination of Pinia. In pinia I have a function to authorize a user like:

async login (credentials: User) {

var requestOptions = {
  method: 'POST',
  body: {
    email: 'test@test.com',
    password: 'testpass'
  }
};
  const { data: user }: any = await useFetch('https://endpoint.com/api/user/create-token', requestOptions)
  console.log(user.value.result.token)

  JwtService.saveToken(user.value.result.token)
},

Everything works fine as I get a token from the endpoint. The problem is; I want this fetch POST being fired at the server and not at the client. Currently I see the XHR in my client. How to fix this?

Application is running as SSR.


问:
Disable screenshots and video capture
Is there any  plugin for disable screenshots and preventing video capture for flutter WEB

Specifically for flutter web

Title: Disable screenshots and video capture


问:
How to set yaml config for graphql mutations and queries the same as you could write with attributes in API Platform?
For example:
We could have such PHP attributes

#[ApiResource(
    graphQlOperations: [
    new Query(
        normalizationContext: ['groups' => ['user:read']],
        provider: ItemProvider::class,
    ),
    new QueryCollection(
        normalizationContext: ['groups' => ['user:read']],
        provider: CollectionProvider::class,
    ),
    new Mutation(
        resolver: CreateUserMutationResolver::class,
        denormalizationContext: ['groups' => ['user:write']],
        name: 'create',
    ),
    new Mutation(
        denormalizationContext: ['groups' => ['user:write']],
        name: 'update'
    ),
    new Mutation(
        denormalizationContext: ['groups' => ['user:write']],
        name: 'delete'
    ),
    ]
)]
class User {
...
}
```

I need to replace the attribute-like config with yaml config - to separate use ApiResoruce from Entity.

I tried to use \ApiPlatform\Metadata\Extractor\YamlResourceExtractor class, but now I have an error on \ApiPlatform\GraphQl\Type\TypeConverter with Delete Mutation: it has no 'name'.

Body:
For example:
We could have such PHP attributes

#[ApiResource(
    graphQlOperations: [
    new Query(
        normalizationContext: ['groups' => ['user:read']],
        provider: ItemProvider::class,
    ),
    new QueryCollection(
        normalizationContext: ['groups' => ['user:read']],
        provider: CollectionProvider::class,
    ),
    new Mutation(
        resolver: CreateUserMutationResolver::class,
        denormalizationContext: ['groups' => ['user:write']],
        name: 'create',
    ),
    new Mutation(
        denormalizationContext: ['groups' => ['user:write']],
        name: 'update'
    ),
    new Mutation(
        denormalizationContext: ['groups' => ['user:write']],
        name: 'delete'
    ),
    ]
)]
class User {
...
}

I need to replace the attribute-like config with yaml config - to separate use ApiResoruce from Entity.

I tried to use \ApiPlatform\Metadata\Extractor\YamlResourceExtractor class, but now I have an error on \ApiPlatform\GraphQl\Type\TypeConverter with Delete Mutation: it has no 'name'.


问:
Spark Partitions and Tim
I am very new to spark programming and want to understand how many partitions I should have for 400GB file with 16GB ram on 3 executers/2 cores per executor.

I looked at spark documentation and it says to have 3x partitions to each core but do we not have consider the memory available also?

Can someone please help and explain.

Thank you

Title: Spark Partitions and Tim


问:
Polygon Edge migration from POA to POS
I have created a 4 nodes POA network using polygon-edge.

As mentioned ,I have tried out the approach for migration.

I have deployed the staking smart contract in block no 800 .All the validators staking has staked before block no 1500.I have verified the list in staking contract.

I have restarted all the nodes after migration to rebuild the blocks from new genesis.json.

polygon-edge ibft switch --chain ./genesis.json --type PoS --deployment 800 --from 1500

But the blocks are not getting generated from 1500 due to the following error.

failed to get validators when calculation quorum

Please suggest any solutions for the issue.

Title: Polygon Edge migration from POA to POS


问:
why can't I install laravel?
This appears
I followed Youtube tutorial to install Laravel but only in this point it gets error. I can't figure out what to do now.</p>
```<code>
  Problem 1
    - laravel/framework[v9.36.4, ..., 9.x-dev] require league/flysystem ^3.8.0 -> satisfiable by league/flysystem[3.8.0, ..., 3.x-dev].
    - laravel/framework[v9.19.0, ..., v9.36.3] require league/flysystem ^3.0.16 -> satisfiable by league/flysystem[3.0.16, ..., 3.x-dev].
    - league/flysystem[3.0.16, ..., 3.x-dev] require league/mime-type-detection ^1.0.0 -> satisfiable by league/mime-type-detection[1.0.0, ..., 1.11.0].
    - league/mime-type-detection[1.0.0, ..., 1.3.0] require php ^7.2 -> your php version (8.1.13) does not satisfy that requirement.
    - league/mime-type-detection[1.4.0, ..., 1.11.0] require ext-fileinfo * -> it is missing from your system. Install or enable PHP's fileinfo extension.
    - Root composer.json requires laravel/framework ^9.19 -> satisfiable by laravel/framework[v9.19.0, ..., 9.x-dev].

To enable extensions, verify that they are enabled in your .ini files:
    - C:\php-8.1.13\php.ini
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-fileinfo` to temporarily ignore these required extensions.

</code>```

Title: why can't I install laravel?

Body:
This appears
I followed Youtube tutorial to install Laravel but only in this point it gets error. I can't figure out what to do now.

  Problem 1
    - laravel/framework[v9.36.4, ..., 9.x-dev] require league/flysystem ^3.8.0 -> satisfiable by league/flysystem[3.8.0, ..., 3.x-dev].
    - laravel/framework[v9.19.0, ..., v9.36.3] require league/flysystem ^3.0.16 -> satisfiable by league/flysystem[3.0.16, ..., 3.x-dev].
    - league/flysystem[3.0.16, ..., 3.x-dev] require league/mime-type-detection ^1.0.0 -> satisfiable by league/mime-type-detection[1.0.0, ..., 1.11.0].
    - league/mime-type-detection[1.0.0, ..., 1.3.0] require php ^7.2 -> your php version (8.1.13) does not satisfy that requirement.
    - league/mime-type-detection[1.4.0, ..., 1.11.0] require ext-fileinfo * -> it is missing from your system. Install or enable PHP's fileinfo extension.
    - Root composer.json requires laravel/framework ^9.19 -> satisfiable by laravel/framework[v9.19.0, ..., 9.x-dev].

To enable extensions, verify that they are enabled in your .ini files:
    - C:\php-8.1.13\php.ini
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-fileinfo` to temporarily ignore these required extensions.


问:
Can I pass a message in a variable when raising an exception
I am trying to pass a message in a variable when raising an exception.
For example:

```<code>DATA: lv_msg TYPE string,
      lv_filename TYPE string VALUE 'file'.

CASE sy-subrc.
WHEN 0.
 "No error go on
WHEN 1.
 MESSAGE e001(cl_error) WITH lv_filename  INTO lv_msg.
WHEN 2.
 MESSAGE e002(cl_error) WITH lv_filename INTO lv_msg.
WHEN  3.
 MESSAGE e003(cl_error) WITH lv_filename INTO lv_msg.
WHEN OTHERS.
 MESSAGE e004(cl_error) WITH lv_filename INTO lv_msg.
ENDCASE.

RAISE EXCEPTION TYPE cl_base MESSAGE lv_msg.
</code>```

This does not work.
I know i can achieve that using:

```<code>MESSAGE ID sy-msgid
TYPE   sy-msgty
NUMBER sy-msgno
WITH   sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
</code>```

But this does not solve my problem, because i am trying to use a message class.
So my question is, if passing the message trough a variable is possible?

Body:
I am trying to pass a message in a variable when raising an exception.
For example:

DATA: lv_msg TYPE string,
      lv_filename TYPE string VALUE 'file'.

CASE sy-subrc.
WHEN 0.
 "No error go on
WHEN 1.
 MESSAGE e001(cl_error) WITH lv_filename  INTO lv_msg.
WHEN 2.
 MESSAGE e002(cl_error) WITH lv_filename INTO lv_msg.
WHEN  3.
 MESSAGE e003(cl_error) WITH lv_filename INTO lv_msg.
WHEN OTHERS.
 MESSAGE e004(cl_error) WITH lv_filename INTO lv_msg.
ENDCASE.

RAISE EXCEPTION TYPE cl_base MESSAGE lv_msg.

This does not work.
I know i can achieve that using:

MESSAGE ID sy-msgid
TYPE   sy-msgty
NUMBER sy-msgno
WITH   sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4

But this does not solve my problem, because i am trying to use a message class.
So my question is, if passing the message trough a variable is possible?


问:
Rerender angular Datatable , Getting all the records
I have a Angular application with a simple CRUD functionality. I have tested my data with static table and this works. Now I am using a data table framework called Angular data table.

I am reloading getdata() Method After create product. But all the records showing datatable  ?

Is there any solution ? Pls help me on this.

I'm trying to update(rerender) angular datatable with new dtOptions

```<code>import { Component, OnDestroy, OnInit, AfterViewInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Subject } from 'rxjs';
import { MatDialogConfig, MatDialog } from '@angular/material/dialog';
import { ProductCreateComponent } from '../products/product-create/product-create.component';
import {DataTableDirective, DataTablesModule} from 'angular-datatables';

const dialogConfig= new MatDialogConfig();
dialogConfig.disableClose = true;
dialogConfig.autoFocus = true;

@Component({
  selector: 'app-agstatictable',
  templateUrl: './agstatictable.component.html',
  styleUrls: ['./agstatictable.component.css']
})
export class AgstatictableComponent implements AfterViewInit, OnDestroy, OnInit {

  dtOptions: DataTables.Settings = {};
  dtElement: DataTableDirective;
  persons: any[] = [];
  isDtInitialized:boolean = false;
  dtTrigger: Subject<any> = new Subject<any>();

  constructor(
    private httpClient: HttpClient,
    private dialog:MatDialog,
    ) { }

  ngOnInit(): void {
    this.dtOptions = {
      pagingType: 'full_numbers',
      pageLength: 15
    };
   this.getData();
  }

  createProduct()
  {
    dialogConfig.width = "60%";
    dialogConfig.data = {
      // updateProdId: this.updateProductId
    }
    this.dialog.open(ProductCreateComponent, dialogConfig);

    this.dialog.afterAllClosed.subscribe(e=>{
      this.getData();
    });
  }

  getData() {
    this.httpClient.get<any[]>('https://api.npoint.io/73d6b5477838c422e54c')
    .subscribe(data => {
      this.persons = (data as any).data;
      // Calling the DT trigger to manually render the table
      if (this.isDtInitialized) {
        this.dtElement.dtInstance.then((dtInstance: DataTables.Api) => {
          dtInstance.destroy();
          this.dtTrigger.next(this.dtOptions);
        });
      } else {
        this.isDtInitialized = true
        this.dtTrigger.next(this.dtOptions);
      }
    });
  }

  ngOnDestroy(): void {
    // Do not forget to unsubscribe the event
    this.dtTrigger.unsubscribe();
  }

}
</code>```
```<code><button (click)="createProduct()" mat-raised-button>New Product</button>
<table datatable [dtOptions]="dtOptions" [dtTrigger]="dtTrigger" class="row-border hover">
    <thead>
      <tr>
        <th>ID</th>
        <th>First name</th>
        <th>Last name</th>
        <th></th>
      </tr>
    </thead>
    <tbody>
      <tr *ngFor="let person of persons">
        <td>{{ person.id }}</td>
        <td>{{ person.firstName }}</td>
        <td>{{ person.lastName }}</td>
        <td><a href="#" (click)="update(person.firstName)">Edit</a></td>
      </tr>
    </tbody>
  </table>
</code>```

I need to show records based on Page Length.

Body:
I have a Angular application with a simple CRUD functionality. I have tested my data with static table and this works. Now I am using a data table framework called Angular data table.

I am reloading getdata() Method After create product. But all the records showing datatable  ?

Is there any solution ? Pls help me on this.

I'm trying to update(rerender) angular datatable with new dtOptions

import { Component, OnDestroy, OnInit, AfterViewInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Subject } from 'rxjs';
import { MatDialogConfig, MatDialog } from '@angular/material/dialog';
import { ProductCreateComponent } from '../products/product-create/product-create.component';
import {DataTableDirective, DataTablesModule} from 'angular-datatables';

const dialogConfig= new MatDialogConfig();
dialogConfig.disableClose = true;
dialogConfig.autoFocus = true;

@Component({
  selector: 'app-agstatictable',
  templateUrl: './agstatictable.component.html',
  styleUrls: ['./agstatictable.component.css']
})
export class AgstatictableComponent implements AfterViewInit, OnDestroy, OnInit {

  dtOptions: DataTables.Settings = {};
  dtElement: DataTableDirective;
  persons: any[] = [];
  isDtInitialized:boolean = false;
  dtTrigger: Subject<any> = new Subject<any>();

  constructor(
    private httpClient: HttpClient,
    private dialog:MatDialog,
    ) { }

  ngOnInit(): void {
    this.dtOptions = {
      pagingType: 'full_numbers',
      pageLength: 15
    };
   this.getData();
  }

  createProduct()
  {
    dialogConfig.width = "60%";
    dialogConfig.data = {
      // updateProdId: this.updateProductId
    }
    this.dialog.open(ProductCreateComponent, dialogConfig);

    this.dialog.afterAllClosed.subscribe(e=>{
      this.getData();
    });
  }

  getData() {
    this.httpClient.get<any[]>('https://api.npoint.io/73d6b5477838c422e54c')
    .subscribe(data => {
      this.persons = (data as any).data;
      // Calling the DT trigger to manually render the table
      if (this.isDtInitialized) {
        this.dtElement.dtInstance.then((dtInstance: DataTables.Api) => {
          dtInstance.destroy();
          this.dtTrigger.next(this.dtOptions);
        });
      } else {
        this.isDtInitialized = true
        this.dtTrigger.next(this.dtOptions);
      }
    });
  }

  ngOnDestroy(): void {
    // Do not forget to unsubscribe the event
    this.dtTrigger.unsubscribe();
  }

}

<button (click)="createProduct()" mat-raised-button>New Product</button>

        ID
        First name
        Last name

        {{ person.id }}
        {{ person.firstName }}
        {{ person.lastName }}
        Edit

I need to show records based on Page Length.


问:
Get the first element of each month
There is a table with lists of prices. Prices appear every day.
I did the breakdown by month and year, but ... How can I display only the prices of the first day of each month?

For example: in March, the price is available for 2, 3, etc. until March 30.
I only need to take the price for March 2nd.
Then there is the price for April, starting from April 5th until April 30th.
I only need to take the price for April 5th.

That is, always display the first price of each month.

```<code>public function getSharePriceList(): array
{
    $result = [];
    $companyId = $this->id;
    $getList = SharePrice::where('company_id', $companyId)
        ->get()
        ->groupBy([
            function($val){
                return Carbon::parse($val->date)->format('Y');
            },
            function($val) {
                return Carbon::parse($val->date)->format('m');
            }
        ]);

    if($getList) {
        $result = $getList->toArray();
    }

    return $result;
}
</code>```

Title: Get the first element of each month

Body:
There is a table with lists of prices. Prices appear every day.
I did the breakdown by month and year, but ... How can I display only the prices of the first day of each month?

For example: in March, the price is available for 2, 3, etc. until March 30.
I only need to take the price for March 2nd.
Then there is the price for April, starting from April 5th until April 30th.
I only need to take the price for April 5th.

That is, always display the first price of each month.

public function getSharePriceList(): array
{
    $result = [];
    $companyId = $this->id;
    $getList = SharePrice::where('company_id', $companyId)
        ->get()
        ->groupBy([
            function($val){
                return Carbon::parse($val->date)->format('Y');
            },
            function($val) {
                return Carbon::parse($val->date)->format('m');
            }
        ]);

    if($getList) {
        $result = $getList->toArray();
    }

    return $result;
}


问:
Flutter Shared Preference : How to save the Stateful widget to the device (lines are drawn by CustomPainter and stylus)
I'm making a e-book application and user can draw lines on the WorkbookDrawingPage Widget by Stack layer.

I want to make the drawn lines saved to the device and books by using shared preference. I tried to use a Json encoding, but couldn't apply to my code.
How to save List<Object> to SharedPreferences in Flutter?

Here's my code

WorkbookViewPage ( PdfViewer and DrawingPage widget)

```<code>class WorkbookViewPage extends StatefulWidget {
  String downloadedURL;
  String workbookName;

  WorkbookViewPage(this.downloadedURL, this.workbookName, {super.key});

  @override
  State<WorkbookViewPage> createState() => _WorkbookViewPageState();
}

class _WorkbookViewPageState extends State<WorkbookViewPage> {
  /// Widget Key
  GlobalKey _viewKey = GlobalKey();
  final GlobalKey<SfPdfViewerState> _pdfViewerKey = GlobalKey();

  /// Controller
  PdfViewerController _pdfViewerController = PdfViewerController();
  ScrollController _scrollController = ScrollController();

  /// Variables
  int _lastClosedPage = 1;
  int _currentPage = 1;
  bool _memoMode = false;
  int drawingPage = 1;
  bool isPenTouched = false;

  /// pen size control widget Entry
  bool isOverlayVisible = false;
  OverlayEntry? entry;

  /// Hide Overlay Widget
  void hideOverlay() {
    entry?.remove();
    entry = null;
    isOverlayVisible = false;
  }

  /// Count the Total Pages of the Workbook
  int _countTotalPages(){
    int _totalPages = _pdfViewerController.pageCount;
    return _totalPages;
  }

  /// get Last closed page of workbook
  void _loadLastClosedPage() async {
    final pagePrefs = await SharedPreferences.getInstance();
    _lastClosedPage = pagePrefs.getInt('${widget.workbookName}') ?? 1;
  }

  @override
  void initState() {
    super.initState();
    // Load Pdf with landScape Mode
    SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft]);
    _pdfViewerController = PdfViewerController();
    String workbookName = '${widget.workbookName}';
    _loadLastClosedPage();
    _countTotalPages();
    print("======== Loaded workbook name = ${workbookName} ==========");
  }

  @override
  Widget build(BuildContext context) {

    /// Drawing Provider
    var p = context.read<DrawingProvider>();

    /// set _lastClosedPage
    void countLastClosedPage() async {
      final pagePrefs = await SharedPreferences.getInstance();
      setState(() {
        pagePrefs.setInt('${widget.workbookName}', _lastClosedPage);
        _lastClosedPage = (pagePrefs.getInt('${widget.workbookName}') ?? 1);
      });
    }

    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        backgroundColor: Colors.white,
        elevation: 1,
      ),
      body: Stack(
        children: [
          InteractiveViewer(
            panEnabled: _memoMode ? false : true,
            scaleEnabled: _memoMode ? false : true,
            maxScale: 3,
            child: Stack(
              children: [
                IgnorePointer(
                  ignoring: true,
                  child: SfPdfViewer.network(
                    widget.downloadedURL,
                    controller: _pdfViewerController,
                    key: _pdfViewerKey,
                    pageLayoutMode: PdfPageLayoutMode.single,
                    enableDoubleTapZooming: false,
                    // Save the last closed page number
                    onPageChanged: (details) {
                      _lastClosedPage = details.newPageNumber;
                      _currentPage = details.newPageNumber;
                      countLastClosedPage();
                    },
                    onDocumentLoaded: (details) {
                      _pdfViewerController.jumpToPage(_lastClosedPage);
                      _pdfViewerController.zoomLevel = 0;
                      print("totalpages = ${_countTotalPages().toInt()}");

                    },
                    canShowScrollHead: false,
                  ),
                ),
                SingleChildScrollView(
                  physics: NeverScrollableScrollPhysics(),
                  controller: _scrollController,
                  scrollDirection: Axis.horizontal,
                  child: WorkbookDrawingPage(widget.workbookName, _countTotalPages().toInt(),),
                ),
              ],
            ),
          ),
</code>```

WorkbookDawingPage.dart

```<code>class WorkbookDrawingPage extends StatefulWidget {
  String workbookName;
  int countTotalPages;

  WorkbookDrawingPage(this.workbookName, this.countTotalPages,{super.key});

  @override
  State<WorkbookDrawingPage> createState() => _WorkbookDrawingPageState();
}

class _WorkbookDrawingPageState extends State<WorkbookDrawingPage> {
  // OverlayEntry widget key
  GlobalKey _overlayViewKey = GlobalKey();
  Key _viewKey = UniqueKey();

  // pen size control widget Entry
  bool isOverlayVisible = false;
  OverlayEntry? entry;

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    var p = context.read<DrawingProvider>();
    void hideOverlay() {
      entry?.remove();
      entry = null;
      isOverlayVisible = false;
    }

    return Container(
      width: MediaQuery.of(context).size.width * (widget.countTotalPages),
      height: MediaQuery.of(context).size.height * 1,
      child: CustomPaint(
        painter: DrawingPainter(p.lines),
        child: Listener(
          behavior: HitTestBehavior.translucent,
          // Draw lines when stylus hit the screen
          onPointerDown: (s) async {
            if (s.kind == PointerDeviceKind.stylus) {
              setState(() {
                p.penMode ? p.penDrawStart(s.localPosition) : null;
                p.highlighterMode
                    ? p.highlighterDrawStart(s.localPosition)
                    : null;
                p.eraseMode ? p.erase(s.localPosition) : null;
              });
            }
            /// Stylus with button pressed touched the Screen
            else if (s.kind == PointerDeviceKind.stylus ||
                s.buttons == kPrimaryStylusButton) {
              setState(() {
                p.changeEraseModeButtonClicked = true;
              });
            }
          },
          onPointerMove: (s) {
            if (s.kind == PointerDeviceKind.stylus) {
              setState(() {
                p.penMode ? p.penDrawing(s.localPosition) : null;
                p.highlighterMode
                    ? p.highlighterDrawing(s.localPosition)
                    : null;
                p.eraseMode ? p.erase(s.localPosition) : null;
              });
            } else if (s.kind == PointerDeviceKind.stylus ||
                s.buttons == kPrimaryStylusButton) {
              setState(() {
                p.changeEraseModeButtonClicked = true;
              });
            }
          },

        ),
      ),
    );
  }
}
</code>```

The application uses provider for drawing lines and here's provider class

Drawing Provider

```<code>Class DrawingProvider extends ChangeNotifier {

 /// line List  **/
  final lines = <List<DotInfo>>[];

  Color _selectedColor = Colors.black;

  Color get selectedColor => _selectedColor;

  /** function method to change Color **/
  set changeColor(Color color) {
    _selectedColor = color;
    notifyListeners();
  }

  /** Mode Selection  **/
  bool _penMode = false;
  bool get penMode => _penMode;
  bool _highlighterMode = false;
  bool get highlighterMode => _highlighterMode;
  bool _eraseMode = false;
  bool get eraseMode => _eraseMode;
  bool _memoMode = false;
  bool get memoMode => _memoMode;

  set changeEraseModeButtonClicked(bool eraseMode) {
    eraseMode = true;
    _eraseMode = eraseMode;
    print("eraseMode가 On ");
    notifyListeners();
  }

  /** 지우개 선택 모드 **/
  void changeEraseMode() {
    _eraseMode = !_eraseMode;
    print("eraseMode is : ${eraseMode}");
    _penMode = false;
    _highlighterMode = false;
    notifyListeners();
  }

  /** 일반 펜 선택 모드 **/
  void changePenMode() {
    _penMode = !_penMode;
    // _selectedColor = _selectedColor.withOpacity(1);
    print("penMode is called : ${penMode} ");
    _eraseMode = false;
    _highlighterMode = false;
    notifyListeners();
  }

  /** 형광펜 선택 모드 **/
  void changeHighlighterMode() {
    _highlighterMode = !_highlighterMode;
    // _selectedColor = _selectedColor.withOpacity(0.3);
    print("Highlighter Mode : ${highlighterMode}");

    _eraseMode = false;
    _penMode = false;
    _opacity = 0.3;
    notifyListeners();
  }

  /** Pen Draw Start  **/
  void penDrawStart(Offset offset) async {
    var oneLine = <DotInfo>[];
    oneLine.add(DotInfo(offset, penSize, _selectedColor,));
    lines.add(oneLine);
    notifyListeners();
  }

  /** Pen Drawing  **/
  void penDrawing(Offset offset) {
    lines.last.add(DotInfo(offset, penSize, _selectedColor));
    notifyListeners();
  }

  /** highlighter Start  **/
  void highlighterDrawStart(Offset offset) {
    var oneLine = <DotInfo>[];
    oneLine
        .add(DotInfo(offset, highlighterSize, _selectedColor.withOpacity(0.3),));

    lines.add(oneLine);
    notifyListeners();
  }

  /** 터치 후 형광 펜 그리기 **/
  void highlighterDrawing(Offset offset) {
    lines.last
        .add(DotInfo(offset, highlighterSize, _selectedColor.withOpacity(0.3)));

    notifyListeners();
  }

  /** 선 지우기 메서드 **/
  void erase(Offset offset) {
    final eraseRange = 15;
    for (var oneLine in List<List<DotInfo>>.from(lines)) {
      for (var oneDot in oneLine) {
        if (sqrt(pow((offset.dx - oneDot.offset.dx), 2) +
            pow((offset.dy - oneDot.offset.dy), 2)) <
            eraseRange) {
          lines.remove(oneLine);
          break;
        }
      }
    }
    notifyListeners();
  }

}
</code>```

and the Dotinfo save the information of the lines

DotInfo.dart

```<code>class DotInfo {
  final Offset offset;
  final double size;
  final Color color;

  DotInfo(this.offset, this.size, this.color);

}
</code>```

in the WorkbookDrawingPage.dart , CustomPaint.painter method get DrawingPainter Class

DrawingPainter.dart

```<code>class DrawingPainter extends CustomPainter {

  final List<List<DotInfo>> lines;

  DrawingPainter(this.lines);

  @override
  void paint(Canvas canvas, Size size) {

      for (var oneLine in lines) {
        Color? color;
        double? size;
        var path = Path();
        var l = <Offset>[];
        for (var oneDot in oneLine) {
          color ??= oneDot.color;
          size ??= oneDot.size;
          l.add(oneDot.offset);
        }
        path.addPolygon(l, false);

        canvas.drawPath(
            path,
            Paint()
              ..color = color!
              ..strokeWidth = size!
              ..strokeCap = StrokeCap.round
              ..style = PaintingStyle.stroke
              ..isAntiAlias = true
              ..strokeJoin = StrokeJoin.round);
      }

  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) => true;
}
</code>```

The Drawing function is related to the provider.

I have no idea how to save the drawn lines into the device. My idea was saving the WorkbookDrawingPage widget itself to the device by using shared preference but, shared preference only can save Int, String, double... so, I tried to encode the DotInfo Class but it cannot be encoded because constructors value is not initialized in the DotInfo Class.

how to save the drawn lines to the device and make them pair with the book?

is saving the widget to the device is possible?? or can you give me any hint or answer?

Body:
I'm making a e-book application and user can draw lines on the WorkbookDrawingPage Widget by Stack layer.

I want to make the drawn lines saved to the device and books by using shared preference. I tried to use a Json encoding, but couldn't apply to my code.
How to save List<Object> to SharedPreferences in Flutter?

Here's my code

WorkbookViewPage ( PdfViewer and DrawingPage widget)

class WorkbookViewPage extends StatefulWidget {
  String downloadedURL;
  String workbookName;

  WorkbookViewPage(this.downloadedURL, this.workbookName, {super.key});

  @override
  State<WorkbookViewPage> createState() => _WorkbookViewPageState();
}

class _WorkbookViewPageState extends State<WorkbookViewPage> {
  /// Widget Key
  GlobalKey _viewKey = GlobalKey();
  final GlobalKey<SfPdfViewerState> _pdfViewerKey = GlobalKey();

  /// Controller
  PdfViewerController _pdfViewerController = PdfViewerController();
  ScrollController _scrollController = ScrollController();

  /// Variables
  int _lastClosedPage = 1;
  int _currentPage = 1;
  bool _memoMode = false;
  int drawingPage = 1;
  bool isPenTouched = false;

  /// pen size control widget Entry
  bool isOverlayVisible = false;
  OverlayEntry? entry;

  /// Hide Overlay Widget
  void hideOverlay() {
    entry?.remove();
    entry = null;
    isOverlayVisible = false;
  }

  /// Count the Total Pages of the Workbook
  int _countTotalPages(){
    int _totalPages = _pdfViewerController.pageCount;
    return _totalPages;
  }

  /// get Last closed page of workbook
  void _loadLastClosedPage() async {
    final pagePrefs = await SharedPreferences.getInstance();
    _lastClosedPage = pagePrefs.getInt('${widget.workbookName}') ?? 1;
  }

  @override
  void initState() {
    super.initState();
    // Load Pdf with landScape Mode
    SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft]);
    _pdfViewerController = PdfViewerController();
    String workbookName = '${widget.workbookName}';
    _loadLastClosedPage();
    _countTotalPages();
    print("======== Loaded workbook name = ${workbookName} ==========");
  }

  @override
  Widget build(BuildContext context) {

    /// Drawing Provider
    var p = context.read<DrawingProvider>();

    /// set _lastClosedPage
    void countLastClosedPage() async {
      final pagePrefs = await SharedPreferences.getInstance();
      setState(() {
        pagePrefs.setInt('${widget.workbookName}', _lastClosedPage);
        _lastClosedPage = (pagePrefs.getInt('${widget.workbookName}') ?? 1);
      });
    }

    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        backgroundColor: Colors.white,
        elevation: 1,
      ),
      body: Stack(
        children: [
          InteractiveViewer(
            panEnabled: _memoMode ? false : true,
            scaleEnabled: _memoMode ? false : true,
            maxScale: 3,
            child: Stack(
              children: [
                IgnorePointer(
                  ignoring: true,
                  child: SfPdfViewer.network(
                    widget.downloadedURL,
                    controller: _pdfViewerController,
                    key: _pdfViewerKey,
                    pageLayoutMode: PdfPageLayoutMode.single,
                    enableDoubleTapZooming: false,
                    // Save the last closed page number
                    onPageChanged: (details) {
                      _lastClosedPage = details.newPageNumber;
                      _currentPage = details.newPageNumber;
                      countLastClosedPage();
                    },
                    onDocumentLoaded: (details) {
                      _pdfViewerController.jumpToPage(_lastClosedPage);
                      _pdfViewerController.zoomLevel = 0;
                      print("totalpages = ${_countTotalPages().toInt()}");

                    },
                    canShowScrollHead: false,
                  ),
                ),
                SingleChildScrollView(
                  physics: NeverScrollableScrollPhysics(),
                  controller: _scrollController,
                  scrollDirection: Axis.horizontal,
                  child: WorkbookDrawingPage(widget.workbookName, _countTotalPages().toInt(),),
                ),
              ],
            ),
          ),

WorkbookDawingPage.dart

class WorkbookDrawingPage extends StatefulWidget {
  String workbookName;
  int countTotalPages;

  WorkbookDrawingPage(this.workbookName, this.countTotalPages,{super.key});

  @override
  State<WorkbookDrawingPage> createState() => _WorkbookDrawingPageState();
}

class _WorkbookDrawingPageState extends State<WorkbookDrawingPage> {
  // OverlayEntry widget key
  GlobalKey _overlayViewKey = GlobalKey();
  Key _viewKey = UniqueKey();

  // pen size control widget Entry
  bool isOverlayVisible = false;
  OverlayEntry? entry;

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    var p = context.read<DrawingProvider>();
    void hideOverlay() {
      entry?.remove();
      entry = null;
      isOverlayVisible = false;
    }

    return Container(
      width: MediaQuery.of(context).size.width * (widget.countTotalPages),
      height: MediaQuery.of(context).size.height * 1,
      child: CustomPaint(
        painter: DrawingPainter(p.lines),
        child: Listener(
          behavior: HitTestBehavior.translucent,
          // Draw lines when stylus hit the screen
          onPointerDown: (s) async {
            if (s.kind == PointerDeviceKind.stylus) {
              setState(() {
                p.penMode ? p.penDrawStart(s.localPosition) : null;
                p.highlighterMode
                    ? p.highlighterDrawStart(s.localPosition)
                    : null;
                p.eraseMode ? p.erase(s.localPosition) : null;
              });
            }
            /// Stylus with button pressed touched the Screen
            else if (s.kind == PointerDeviceKind.stylus ||
                s.buttons == kPrimaryStylusButton) {
              setState(() {
                p.changeEraseModeButtonClicked = true;
              });
            }
          },
          onPointerMove: (s) {
            if (s.kind == PointerDeviceKind.stylus) {
              setState(() {
                p.penMode ? p.penDrawing(s.localPosition) : null;
                p.highlighterMode
                    ? p.highlighterDrawing(s.localPosition)
                    : null;
                p.eraseMode ? p.erase(s.localPosition) : null;
              });
            } else if (s.kind == PointerDeviceKind.stylus ||
                s.buttons == kPrimaryStylusButton) {
              setState(() {
                p.changeEraseModeButtonClicked = true;
              });
            }
          },

        ),
      ),
    );
  }
}

The application uses provider for drawing lines and here's provider class

Drawing Provider

Class DrawingProvider extends ChangeNotifier {

 /// line List  **/
  final lines = <List<DotInfo>>[];

  Color _selectedColor = Colors.black;

  Color get selectedColor => _selectedColor;

  /** function method to change Color **/
  set changeColor(Color color) {
    _selectedColor = color;
    notifyListeners();
  }

  /** Mode Selection  **/
  bool _penMode = false;
  bool get penMode => _penMode;
  bool _highlighterMode = false;
  bool get highlighterMode => _highlighterMode;
  bool _eraseMode = false;
  bool get eraseMode => _eraseMode;
  bool _memoMode = false;
  bool get memoMode => _memoMode;

  set changeEraseModeButtonClicked(bool eraseMode) {
    eraseMode = true;
    _eraseMode = eraseMode;
    print("eraseMode가 On ");
    notifyListeners();
  }

  /** 지우개 선택 모드 **/
  void changeEraseMode() {
    _eraseMode = !_eraseMode;
    print("eraseMode is : ${eraseMode}");
    _penMode = false;
    _highlighterMode = false;
    notifyListeners();
  }

  /** 일반 펜 선택 모드 **/
  void changePenMode() {
    _penMode = !_penMode;
    // _selectedColor = _selectedColor.withOpacity(1);
    print("penMode is called : ${penMode} ");
    _eraseMode = false;
    _highlighterMode = false;
    notifyListeners();
  }

  /** 형광펜 선택 모드 **/
  void changeHighlighterMode() {
    _highlighterMode = !_highlighterMode;
    // _selectedColor = _selectedColor.withOpacity(0.3);
    print("Highlighter Mode : ${highlighterMode}");

    _eraseMode = false;
    _penMode = false;
    _opacity = 0.3;
    notifyListeners();
  }

  /** Pen Draw Start  **/
  void penDrawStart(Offset offset) async {
    var oneLine = <DotInfo>[];
    oneLine.add(DotInfo(offset, penSize, _selectedColor,));
    lines.add(oneLine);
    notifyListeners();
  }

  /** Pen Drawing  **/
  void penDrawing(Offset offset) {
    lines.last.add(DotInfo(offset, penSize, _selectedColor));
    notifyListeners();
  }

  /** highlighter Start  **/
  void highlighterDrawStart(Offset offset) {
    var oneLine = <DotInfo>[];
    oneLine
        .add(DotInfo(offset, highlighterSize, _selectedColor.withOpacity(0.3),));

    lines.add(oneLine);
    notifyListeners();
  }

  /** 터치 후 형광 펜 그리기 **/
  void highlighterDrawing(Offset offset) {
    lines.last
        .add(DotInfo(offset, highlighterSize, _selectedColor.withOpacity(0.3)));

    notifyListeners();
  }

  /** 선 지우기 메서드 **/
  void erase(Offset offset) {
    final eraseRange = 15;
    for (var oneLine in List<List<DotInfo>>.from(lines)) {
      for (var oneDot in oneLine) {
        if (sqrt(pow((offset.dx - oneDot.offset.dx), 2) +
            pow((offset.dy - oneDot.offset.dy), 2)) <
            eraseRange) {
          lines.remove(oneLine);
          break;
        }
      }
    }
    notifyListeners();
  }

}

and the Dotinfo save the information of the lines

DotInfo.dart

class DotInfo {
  final Offset offset;
  final double size;
  final Color color;

  DotInfo(this.offset, this.size, this.color);

}

in the WorkbookDrawingPage.dart , CustomPaint.painter method get DrawingPainter Class

DrawingPainter.dart

class DrawingPainter extends CustomPainter {

  final List<List<DotInfo>> lines;

  DrawingPainter(this.lines);

  @override
  void paint(Canvas canvas, Size size) {

      for (var oneLine in lines) {
        Color? color;
        double? size;
        var path = Path();
        var l = <Offset>[];
        for (var oneDot in oneLine) {
          color ??= oneDot.color;
          size ??= oneDot.size;
          l.add(oneDot.offset);
        }
        path.addPolygon(l, false);

        canvas.drawPath(
            path,
            Paint()
              ..color = color!
              ..strokeWidth = size!
              ..strokeCap = StrokeCap.round
              ..style = PaintingStyle.stroke
              ..isAntiAlias = true
              ..strokeJoin = StrokeJoin.round);
      }

  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) => true;
}

The Drawing function is related to the provider.

I have no idea how to save the drawn lines into the device. My idea was saving the WorkbookDrawingPage widget itself to the device by using shared preference but, shared preference only can save Int, String, double... so, I tried to encode the DotInfo Class but it cannot be encoded because constructors value is not initialized in the DotInfo Class.

how to save the drawn lines to the device and make them pair with the book?

is saving the widget to the device is possible?? or can you give me any hint or answer?


问:
How to open a new web browser window in the controller in 302 code
Now my code shows 302 code as follows and there is no value in the body, so the web page does not change the page according to the return value. However, I want to automatically open a new page in the web browser by redirecting a different url depending on the return value.
What I use is mysql, thymeleaf, jpa, springboot, spring data jpa.

enter image description here

This is My @Controller code (Not @RestController)

```<code>@RequestMapping(method = RequestMethod.POST, value = "/find_email5")
    public String findEmail5(FindEmailDto findEmailDto) {
        String s = "failed";
        try {
            Optional<Users> users = userService.findEmail(findEmailDto);
            if (users.isPresent()) {
                String email = users.get().getEmail();
                return ("redirect:/alert" + email);
            }
        } catch (Exception e) {
            return ("/alert?value=" + s);
        }
        return ("/alert?value=" + s);
    }

@GetMapping("/alert")
    public String alertPage(@RequestParam("value") String s, Model model) {
        model.addAttribute("string", s);
        return "alert";
    }
</code>```

Body:
Now my code shows 302 code as follows and there is no value in the body, so the web page does not change the page according to the return value. However, I want to automatically open a new page in the web browser by redirecting a different url depending on the return value.
What I use is mysql, thymeleaf, jpa, springboot, spring data jpa.

enter image description here

This is My @Controller code (Not @RestController)

@RequestMapping(method = RequestMethod.POST, value = "/find_email5")
    public String findEmail5(FindEmailDto findEmailDto) {
        String s = "failed";
        try {
            Optional<Users> users = userService.findEmail(findEmailDto);
            if (users.isPresent()) {
                String email = users.get().getEmail();
                return ("redirect:/alert" + email);
            }
        } catch (Exception e) {
            return ("/alert?value=" + s);
        }
        return ("/alert?value=" + s);
    }

@GetMapping("/alert")
    public String alertPage(@RequestParam("value") String s, Model model) {
        model.addAttribute("string", s);
        return "alert";
    }


问:
java not found error when running docker container
I have simple Dockerfile as below :

```<code>FROM centos:centos7

FROM adoptopenjdk/openjdk8:jre8u352-b05-ea-ubuntu-nightly

EXPOSE 8080

WORKDIR /home/centos

COPY ./abc.jar /tmp/abc.jar

CMD ["java" "-jar", "/tmp/abc.jar"]
</code>```

Now, after building the image , trying to run the container using docker run command , but it is giving error

/bin/sh: 1: [java: not found

I simply don't understand what's the issue here. I'm assuming that ,  openjdk image will create the java environment and set all PATHS .

Please suggest

Body:
I have simple Dockerfile as below :

FROM centos:centos7

FROM adoptopenjdk/openjdk8:jre8u352-b05-ea-ubuntu-nightly

EXPOSE 8080

WORKDIR /home/centos

COPY ./abc.jar /tmp/abc.jar

CMD ["java" "-jar", "/tmp/abc.jar"]

Now, after building the image , trying to run the container using docker run command , but it is giving error

/bin/sh: 1: [java: not found

I simply don't understand what's the issue here. I'm assuming that ,  openjdk image will create the java environment and set all PATHS .

Please suggest


Title: java not found error when running docker container


问:
Keycloak can not access when running inside a docker-compose network
I'm trying to use Keycloak quick starts in https://github.com/keycloak/keycloak-quickstarts.

I ran app-nodejs-html5 (https://github.com/keycloak/keycloak-quickstarts/tree/latest/app-nodejs-html5) , Keycloak 20.0.1 & service-nodejs (https://github.com/keycloak/keycloak-quickstarts/tree/latest/service-nodejs) all inside a docker-compose.

The front end app 'app-nodejs-html5' & key cloak server communication happen without an issue. But API service 'service-nodejs' & keycloak server communication not working properly. When I try to access API from frontend it every time return HTTP code 403.

When I move out service from docker-compose to outside all apps are working fine.

I suspect when both service & keycloak are in docker-compose, API service trying to access Keycloak using both http://localhost:3001 & http://keycloak.local:8080 URL's.

I tried using Frontend URL but that didn't work either.

I tried adding aliases & it didn't work too. ref : Keycloak and Spring Boot web app in dockerized environment

Did anyone succeed running keycloak & API service inside a docker compose ?

Extract from docker-compose

```<code>keycloak:
      # keycloak admin console is available at http://localhost:3001/admin
      image: keycloak:20.0.1
      build:
         context: .
         dockerfile: Dockerfile.keycloak
      container_name: keycloak
      hostname: keycloak.local
      ports:
         - "3001:8080"
         - "3002:8443"
      environment:
         KC_HOSTNAME: localhost
         KC_HOSTNAME_STRICT: "false"
         KC_DB: postgres
         KC_DB_USERNAME: dba
         KC_DB_PASSWORD: password
         KC_DB_SCHEMA: public
         KC_DB_URL: jdbc:postgresql://database.local:5432/
         KEYCLOAK_ADMIN: admin
         KEYCLOAK_ADMIN_PASSWORD: password
      entrypoint: /opt/keycloak/bin/kc.sh start-dev
      depends_on:
         - database
</code>```

Body:
I'm trying to use Keycloak quick starts in https://github.com/keycloak/keycloak-quickstarts.

I ran app-nodejs-html5 (https://github.com/keycloak/keycloak-quickstarts/tree/latest/app-nodejs-html5) , Keycloak 20.0.1 & service-nodejs (https://github.com/keycloak/keycloak-quickstarts/tree/latest/service-nodejs) all inside a docker-compose.

The front end app 'app-nodejs-html5' & key cloak server communication happen without an issue. But API service 'service-nodejs' & keycloak server communication not working properly. When I try to access API from frontend it every time return HTTP code 403.

When I move out service from docker-compose to outside all apps are working fine.

I suspect when both service & keycloak are in docker-compose, API service trying to access Keycloak using both http://localhost:3001 & http://keycloak.local:8080 URL's.

I tried using Frontend URL but that didn't work either.

I tried adding aliases & it didn't work too. ref : Keycloak and Spring Boot web app in dockerized environment

Did anyone succeed running keycloak & API service inside a docker compose ?

Extract from docker-compose

keycloak:
      # keycloak admin console is available at http://localhost:3001/admin
      image: keycloak:20.0.1
      build:
         context: .
         dockerfile: Dockerfile.keycloak
      container_name: keycloak
      hostname: keycloak.local
      ports:
         - "3001:8080"
         - "3002:8443"
      environment:
         KC_HOSTNAME: localhost
         KC_HOSTNAME_STRICT: "false"
         KC_DB: postgres
         KC_DB_USERNAME: dba
         KC_DB_PASSWORD: password
         KC_DB_SCHEMA: public
         KC_DB_URL: jdbc:postgresql://database.local:5432/
         KEYCLOAK_ADMIN: admin
         KEYCLOAK_ADMIN_PASSWORD: password
      entrypoint: /opt/keycloak/bin/kc.sh start-dev
      depends_on:
         - database