Tuesday, November 16, 2021

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


Django execute sql raw

Posted: 16 Nov 2021 09:13 AM PST

I want to print the result by running a mssql query on any page in my postgresql project, how can I do it?

for exam.

SELECT  TOP(11) * FROM dbo.UserObject WITH (NOLOCK) WHERE u_logon_name='cc@gmail.com'  

My default db setting is postgresql but I want to run mssql query;

DATABASES = {      'default': {          'ENGINE': 'django.db.backends.postgresql',          'NAME': 'postgres',          'ALIAS': 'XX',          'USER': 'XX',          'PASSWORD': 'XX',          'HOST': 'XX',          'PORT': 'XX',      }  }  

Petri net unbounded?

Posted: 16 Nov 2021 09:13 AM PST

I came across this example of Petri Net which is declared to be unbounded

According to the definition of Wikipedia,

A place in a Petri net is called k-bounded if it does not contain more than k tokens in all reachable markings, including the initial marking; it is said to be safe if it is 1-bounded; it is bounded if it is k-bounded for some k. A (marked) Petri net is called k-bounded, safe, or bounded when all of its places are.

I would have said that is net is bounded, since every place can have at most 1 token in every possible marking. Why this is stated as unbounded?

SQLLOADER is taking long to load the data. It is taking around 20mins to load 4209 records only

Posted: 16 Nov 2021 09:13 AM PST

CREATE TABLE SQL_LOAD  (col1 varchar2(4000),  Col2  varchar2(4000),  Col3  varchar2(4000),  Col4  varchar2(4000),  Col5  varchar2(4000),  Col6  varchar2(4000),  Col7  varchar2(4000),  Col8  varchar2(4000),  Col9  varchar2(4000),  Col10  varchar2(4000),  Col11  varchar2(4000),  Col12  varchar2(4000),  Col13  varchar2(4000),  Col14  varchar2(4000),  Col15  varchar2(4000),  Col16  varchar2(4000),  Col17  varchar2(4000),  Col18  varchar2(4000),  Col19  varchar2(4000),  Col20  varchar2(4000),  Col21  varchar2(4000),  Col22  varchar2(4000),  Col23  varchar2(4000),  Col24  varchar2(4000));  

Control file :

options (      skip = 2,      DIRECT = TRUE      )  load data  infile 'I:\SQLLOADER\sqlloader.csv'  replace into table sql_load  fields terminated by ","  optionally enclosed by '"'  trailing nullcols  (  Col1,  Col2,  Col3 ,  Col4 ,  Col5 ,  Col6 ,  Col7 ,  Col8 ,  Col9 ,  Col10 ,  Col11,  Col12,  Col13 char(4000) nullif Col13=BLANKS,  Col14,  Col15,  Col16,  Col17,  Col18,  Col19,  Col20,  Col21,  Col22,  Col23,  Col24  )  

CSV file : Sample data https://drive.google.com/file/d/1wKchp3y1Uir2hxuXS29rX5GAQdHU6LUd/view?usp=sharing

Issue : Currently my csv file has 4209 records. When I am running the sqlldr command then it was loading only 3680 records and I checked the log and found the file exceed the limit error for the col13 in my table. So, I have added col13 char(4000) in my control file and then ran the same sqlldr command. Now it is taking around 20mins to load the data. Can someone let me know what went wrong

'PathCollection' object is not iterable (Even after removing the comma)

Posted: 16 Nov 2021 09:13 AM PST

import random  import numpy as np  import matplotlib.pyplot as plt  import matplotlib.animation as animation  n = 10  m = 2*(n**0.5)    def robot(X):      r = random.randint(1,4)      if r ==1:          X[1] += 1      elif r ==2:          X[0] += 1      elif r==3:          X[1] = X[1] -1      else:          X[0] = X[0] -1      return X  def walk(A,n,F):      W= []      for i in range(n):          B =[0,0]          for i in range(len(A)):              B[i] = A[i]          W.append(B)              A = F(A)      return W    fig,ax = plt.subplots()  plt.xlim(-m,m)  plt.ylim(-m,m)    W = walk([0,0],n,robot)  print(W)    Q=[]  for i in range(1,len(W)):      print(i)      P = W[:i]      X=[]      Y=[]      for j in P:          X.append(j[0])          Y.append(j[1])      print(X,Y)      scat = ax.scatter(X,Y)      plt.show()      Q.append(scat)        ani = animation.ArtistAnimation(fig, Q, interval = 200)  plt.show()  

I couldn't get my random walk algorithm to animate with FuncAnimation so I've been trying to use ArtistAnimation. I have put all my individual scatter plots into a list to be displayed but i keep getting the same message. Here is the extended error message if it helps!

Output from spyder call 'get_namespace_view': Traceback (most recent call last): File "C:\Users\anon\AppData\Local\Programs\Spyder\pkgs\matplotlib\cbook_init_.py", line 270, in process func(*args, **kwargs) File "C:\Users\anon\AppData\Local\Programs\Spyder\pkgs\matplotlib\animation.py", line 991, in _start self._init_draw() File "C:\Users\anon\AppData\Local\Programs\Spyder\pkgs\matplotlib\animation.py", line 1533, in _init_draw for artist in f: TypeError: 'PathCollection' object is not iterable

python slice a string and use .find to get last three letters to determine the type of file

Posted: 16 Nov 2021 09:13 AM PST

what i am asking is how can i correct my if statement, essentially i have a file attachment called 'fileName' and i am trying to get the last 3 letters from that file to determine if that type of file is in my config (csv, txt).

valid_filename = myconfig file (csv, txt)

def load_file():      try:          # get file from read email and assign a directory path (attachments/file)          for fileName in os.listdir(config['files']['folder_path']):              # validate the file extension per config              # if valid_filename:  else send email failure              valid_filename = config['valid_files']['valid']              if fileName[-3:].find(valid_filename):                  file_path = os.path.join(config['files']['folder_path'], fileName)                  # open file path and read it as csv file using csv.reader                  with open(file_path, "r") as csv_file:                      csvReader = csv.reader(csv_file, delimiter=',')                      first_row = True  

let me know if i can clarify anything better

Does WHEN clause in an insert all query when loading into multiple tables in Snowflake add a virtual field over each row and then load in bulk?

Posted: 16 Nov 2021 09:13 AM PST

How WHEN clause evaluate values of columns in order to insert only new values and skip existing ones when using the following query:

INSERT ALL  WHEN (SELECT COUNT(*) FROM DEST WHERE DEST.ID = NEW_ID) = 0 THEN  INSERT INTO DEST (ID) VALUES (NEW_ID)  SELECT NEW_ID FROM SRC  

I tried with WHEN NEW_ID NOT IN (SELECT...) THEN

But it didn't work and threw an error of unsupported.

Does it create a virtual column in all rows with values of true or false and then add all rows having true as a result?

Why is this C++ code which uses decltype and remove_reference with the goal of getting the value type of a pointer working unexpectedly

Posted: 16 Nov 2021 09:13 AM PST

When I run the snippet below, it prints out:

int&  int __cdecl(void)   

I was expecting the second line to just be int

Why is this happening? What could I do to fix it if it were inside a templated function that takes pointers or iterators so I couldn't use std::remove_pointer.

#include <type_traits>  #include <iostream>  int main()  {      int r = 4;      int* rp = &r;      using return_type = decltype(*rp);      using no_ref_type = std::remove_reference<return_type>::type();      std::cout << typeid(return_type).name() << '&' << std::endl;      std::cout << typeid(no_ref_type).name();  }  

how to immediately driver.quit() in selenium?

Posted: 16 Nov 2021 09:13 AM PST

whenever I call driver.quit() it waits for the website to first complete loading then it closes the browser, is there any way I can force close the browser immediately?

Blank in RLS means visible or not visible?

Posted: 16 Nov 2021 09:13 AM PST

I have this legacy cube, in roles I see the ReadAll_Admin role, where we have full access to the data:

Screenshot: enter image description here

I have a few questions:

  • It says "Only rows that match the specified filters are visible to users in this role", what if it remains blank like above?! What's the default "visible" or "not visible"?!
  • I tested the role above and I can read all data, how is it possible?
  • What could be a reasonable case as the above: that is, where you leave all tables blank, and =FALSE() in one?

How does Idris know where to insert Force and Delay?

Posted: 16 Nov 2021 09:12 AM PST

According to the Idris tutorial:

The Idris type checker knows about the Lazy type, and inserts conversions where necessary between Lazy a and a, and vice versa.

For example, b1 && b2 is converted into b1 && Delay b2. What are the specific rules that Idris uses when deciding where to place these implicit conversions?

GluonFX, native image and java.lang.ClassNotFoundException: javafx.scene.web.WebView

Posted: 16 Nov 2021 09:12 AM PST

I am trying to convert my javaFX program into native image, under windows, using the GluonFX plugin and Maven. Since I use javafx webview, the exe file generated, at the time of its execution, tells me the error: *java.lang.ClassNotFoundException: javafx.scene.web.WebView. *
I am trying to convert my javaFX program into native image, under windows, using the GluonFX plugin and Maven. Since I use javafx WebView, the exe file generated, at the time of its execution, tells me the error: java.lang.ClassNotFoundException: javafx.scene.web.WebView.
Mine is a simple program that uses WebView and WebEngine, fully functional under JVM, in NetBeans.
Is there an example of a program that uses WebView and is transformed into a native image with GluonFX?
The problem seems insurmountable for me and I ask for help. The following is the error message:

[lun nov 15 18:41:08 CET 2021][INFO] [SUB] WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @3722c145' [lun nov 15 18:41:09 CET 2021][INFO] [SUB] Exception in Application start method [lun nov 15 18:41:09 CET 2021][INFO] [SUB] Exception in thread "main" java.lang.RuntimeException: Exception in Application start method [lun nov 15 18:41:09 CET 2021][INFO] [SUB]
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:901) [lun nov 15 18:41:09 CET 2021][INFO] [SUB] at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:196) [lun nov 15 18:41:09 CET 2021][INFO] [SUB] at java.lang.Thread.run(Thread.java:829) [lun nov 15 18:41:09 CET 2021][INFO] [SUB] at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:552) [lun nov 15 18:41:09 CET 2021][INFO] [SUB] at com.oracle.svm.core.windows.WindowsJavaThreads.osThreadStartRoutine(WindowsJavaThreads.java:138) [lun nov 15 18:41:09 CET 2021][INFO] [SUB] Caused by: java.lang.AssertionError: java.lang.ClassNotFoundException: javafx.scene.web.WebView

The pom file was generated by NetBeans, while the compilation was done via the terminal: x64 Native Tools Prompt for VS 2019

My java program:

 package com.gluonapplication;  import com.gluonhq.charm.glisten.application.MobileApplication;  import com.gluonhq.charm.glisten.visual.Swatch;  import javafx.scene.Scene;  import javafx.scene.image.Image;  import javafx.stage.Stage;  import java.io.IOException;  import javafx.scene.web.WebHistory;  import javafx.scene.web.WebHistory.Entry;    import javafx.scene.web.WebView;  import javafx.stage.Stage;  import javafx.application.Application;  import javafx.scene.Scene;  import javafx.scene.layout.StackPane;  import javafx.scene.web.WebEngine;    public class GluonApplication extends Application {// MobileApplication      @Override      public void start(Stage stage) throws Exception {          StackPane root = new StackPane();                  WebView view = new WebView();          WebEngine engine = view.getEngine();          engine.load("https://stackoverflow.com");          root.getChildren().add(view);           Scene scene = new Scene(root, 800, 600);          stage.setScene(scene);          stage.show();      }      public static void main(String args[]) {          launch(args);      }  }  

The pom:

<?xml version="1.0" encoding="UTF-8"?>  <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">      <modelVersion>4.0.0</modelVersion>        <groupId>com.gluonapplication</groupId>      <artifactId>gluonapplication</artifactId>      <version>1.0-SNAPSHOT</version>      <packaging>jar</packaging>      <name>GluonApplication</name>        <properties>          <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>          <maven.compiler.release>11</maven.compiler.release>          <javafx.version>16</javafx.version>          <attach.version>4.0.11</attach.version>          <gluonfx.plugin.version>1.0.3</gluonfx.plugin.version>          <javafx.plugin.version>0.0.6</javafx.plugin.version>          <mainClassName>com.gluonapplication.GluonApplication</mainClassName>      </properties>        <dependencies>          <dependency>              <groupId>org.openjfx</groupId>              <artifactId>javafx-controls</artifactId>              <version>${javafx.version}</version>          </dependency>                <dependency>              <groupId>org.openjfx</groupId>              <artifactId>javafx-web</artifactId>              <version>${javafx.version}</version>          </dependency>          <dependency>              <groupId>com.gluonhq</groupId>              <artifactId>charm-glisten</artifactId>              <version>6.0.6</version>          </dependency>          <dependency>              <groupId>com.gluonhq.attach</groupId>              <artifactId>display</artifactId>              <version>${attach.version}</version>          </dependency>          <dependency>              <groupId>com.gluonhq.attach</groupId>              <artifactId>lifecycle</artifactId>              <version>${attach.version}</version>          </dependency>          <dependency>              <groupId>com.gluonhq.attach</groupId>              <artifactId>statusbar</artifactId>              <version>${attach.version}</version>          </dependency>          <dependency>              <groupId>com.gluonhq.attach</groupId>              <artifactId>storage</artifactId>              <version>${attach.version}</version>          </dependency>          <dependency>              <groupId>com.gluonhq.attach</groupId>              <artifactId>util</artifactId>              <version>${attach.version}</version>          </dependency>      </dependencies>        <repositories>          <repository>              <id>Gluon</id>              <url>https://nexus.gluonhq.com/nexus/content/repositories/releases</url>          </repository>      </repositories>        <build>          <plugins>              <plugin>                  <groupId>org.apache.maven.plugins</groupId>                  <artifactId>maven-compiler-plugin</artifactId>                  <version>3.8.1</version>              </plugin>                <plugin>                  <groupId>org.openjfx</groupId>                  <artifactId>javafx-maven-plugin</artifactId>                  <version>${javafx.plugin.version}</version>                  <configuration>                      <mainClass>${mainClassName}</mainClass>                  </configuration>                  <executions>                      <execution>                          <!-- Default configuration for running -->                          <!-- Usage: mvn clean javafx:run -->                          <id>default-cli</id>                      </execution>                      <execution>                          <!-- Configuration for manual attach debugging -->                          <!-- Usage: mvn clean javafx:run@debug -->                          <id>debug</id>                          <configuration>                              <options>                                  <option>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:8000  </option>                              </options>                          </configuration>                      </execution>                      <execution>                          <!-- Configuration for automatic IDE debugging -->                          <id>ide-debug</id>                          <configuration>                              <options>                                  <option>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}</option>                              </options>                          </configuration>                      </execution>                      <execution>                          <!-- Configuration for automatic IDE profiling -->                          <id>ide-profile</id>                          <configuration>                              <options>                                  <option>${profiler.jvmargs.arg1}</option>                                  <option>${profiler.jvmargs.arg2}</option>                                  <option>${profiler.jvmargs.arg3}</option>                                  <option>${profiler.jvmargs.arg4}</option>                                  <option>${profiler.jvmargs.arg5}</option>                              </options>                          </configuration>                      </execution>                  </executions>              </plugin>                <plugin>                  <groupId>com.gluonhq</groupId>                  <artifactId>gluonfx-maven-plugin</artifactId>                  <version>${gluonfx.plugin.version}</version>                  <configuration>                      <target>${gluonfx.target}</target>                      <attachList>                          <list>display</list>                          <list>lifecycle</list>                          <list>statusbar</list>                          <list>storage</list>                      </attachList>                      <mainClass>${mainClassName}</mainClass>                  </configuration>              </plugin>          </plugins>      </build>        <profiles>          <profile>              <id>ios</id>              <properties>                  <gluonfx.target>ios</gluonfx.target>              </properties>          </profile>          <profile>              <id>android</id>              <properties>                  <gluonfx.target>android</gluonfx.target>              </properties>          </profile>      </profiles>  </project>  

Multi-table Row-level Security in Power BI

Posted: 16 Nov 2021 09:12 AM PST

I know the "Email = USERPRINCIPLENAME()" trick. I'm trying to take it a few steps further and integrate linked information from other tables.

In my model, there's an Employee table with Employee ID, Name, and Email. Example Employee Table

Every employee at my company belongs to some number of groups. Each group has an Employee Group Code, Description, and Type. Right now, I'm only interested in the Management type. Example Groups Table

Each management type group has employees who are assigned to Roles: one Primary Supervisor and any number of Backup Supervisors and Workers. These are linked on the Employee Roles table, which contains Employee ID, Employee Group Code, and Functional Role. Example Employee Roles Table

It's all linked together like this. One Employee to many Employee Roles, one Group to many Employee Roles, and several employee detail tables with a many to one relationship with Employee.

I want Primary Supervisors and Backup Supervisors to be able to view information about the Workers in groups to which they are assigned, but I do not want Supervisors to see each other or Workers to see information about Supervisors. (Bonus points if I can allow any user to see information about themselves, though!). Example Viewing Permissions

I've tried separating the Employee Roles table into Workers vs Supervisors, but I'm still stumped on how exactly to make this security work. I know the logic I need is something like:

Find Groups where Current User's Role is Primary Supervisor or Backup Supervisor Current User can see details about Workers who belong to these Groups (Bonus) Current User can see details about Current User

Any direction for me?

Paramiko reconnection

Posted: 16 Nov 2021 09:12 AM PST

To connect via ssh, I use paramiko. How to set a condition if the connection with the username and password admin1 password1 has an error, need to connect using the username and password admin2 password2?

import a function multiple times with different params

Posted: 16 Nov 2021 09:12 AM PST

I have the following function on file_a.js:

export fetchData = (active = true) => {    if (active) {       // fetch active data from API    else {      // fetch expired data    }  }  

And I'm trying to use it like this:

import { fetchData } from 'file_a.js'  ...    const activeData = fetchData(true);  const expiredData = fetchdata(false);  

But whenever I do this, both consts end up with the same data. How can I use the same imported method to get two different sets of data?

Grails 4: Not reading environment variables in Elastic Beanstalk

Posted: 16 Nov 2021 09:11 AM PST

In my Grails application running on Elastic Beanstalk, the DataSource URL is not defined in the app even though I've defined dataSource.url as an Environment Property in the software configuration in Elastic Beanstalk.

I'm running on Corretto 11 running on 64bit Amazon Linux 2/3.2.7 using the embedded Tomcat Container.

enter image description here

Order taxonomy by most recent post

Posted: 16 Nov 2021 09:11 AM PST

I have a custom taxonomy 'Series' and a page showing all the series. I would like to order the series by their cpt post date. So if we have series 1,2,3,4 and Series 3 just had a post from today the order would be Series 3,1,2,4.

Here is what I have so far but I'm stuck.

<?php       $s_tax = 'series';            $series_terms = get_terms( $s_tax, $args = array(      'hide_empty' => false,      'taxonomy' => 'series',      ));            foreach($series_terms as $s => $series_term){          $most_recent = get_posts( array(              'post_type' => 'sermon',              'post_status' => 'publish',              'numberposts' => 1          ));          if( !empty($most_recent)){              $series_term->sermon_date = $most_recent[0]->post_date;          }      }            // //THERE IS WHERE YOU RUN YOUR USORT TO SORT THE SERIES TERMS BY THE POST DATE      usort($most_recent, function($a, $b) {          return strtotime($a['post_date']) - strtotime($b['post_date']);      });                foreach( $series_terms as $s => $series_term ):                $term_link = get_term_link( $series_term );          $img = pk_get_acf_image(get_field('series_image', 'series_' .$series_term->term_id),'medium_large');          $id = get_the_ID();          $date = get_the_date( 'F d, Y', $id );          $title = get_the_title($id);          $sfields = get_fields($id);          $subtitle = pkav($sfields,'subtitle');          $speaker = get_the_terms($id,'speaker');          $series = get_the_terms($id,'series');          $link = get_permalink();                ?>  

How do I update a column only if a different column's value is false, null or doesn't match the incoming value and the incoming value is set to true?

Posted: 16 Nov 2021 09:13 AM PST

In my table I have two columns

ClosedDate DateTime null  IsClosed bit null  

If the incoming value of @IsClosed is true and the current value of IsClosed either null or false then I would like to update the value of ClosedDate to GetDate() like this

ClosedDate = GETDATE()  

Here is what I have tried but it is not working.

ALTER PROCEDURE[dbo].someProcedure  @IsClosed   bit,  Update dbo.Foo  SET  //Other fields to be set   ClosedDate = CASE WHEN IsClosed = 0 OR IsClosed = NULL AND IsClosed <> @IsClosed THEN GETDATE() END,      IsClosed = @IsClosed  WHERE myId = @myId  

Where am I going wrong?

I need someone to explain for me this java code

Posted: 16 Nov 2021 09:11 AM PST

I'm solving an exercise for my university and there is this code in my pdf that my supposed to use to delay the change of the colour of the text on a button, i don't understand how it exactly works so please can someone explain it

HandlerThread handlerThread = new HandlerThread("showText");      handlerThread.start();      Handler handler = new Handler(handlerThread.getLooper());        Runnable runnable = new Runnable() {          int i = 0;          @Override          public void run() {              i++;              handler.postDelayed(this, 1000);              if (i > 1)                   button.setTextColor(getResources().getColor(android.R.color.transparent));          }      };      handler.post(runnable);  

It is possible to using flowbite (or any UI component libraries) for tailwindCSS on angular 12?

Posted: 16 Nov 2021 09:12 AM PST

I'm trying to use tailwindCSS on angular 12, and it's works fine.

My question is about using flowbite or tailwindui for UI component - is it support on angular too? because i'm trying to flow the instructions of flowbite and it's not working https://flowbite.com/docs/getting-started/quickstart/ the css work's fine but not the script.

For example I try to build a dropdowns like this - and it's not working (i'm not getting any error on console) https://flowbite.com/docs/components/dropdowns/#

What is wrong ?

Why do we need proxy in create react app?

Posted: 16 Nov 2021 09:11 AM PST

In some of projects I encountered in create-react-app people use file setuProxy.js which has content like this inside:

const proxy = require("http-proxy-middleware");    module.exports = function (app) {    app.use(      proxy("/api/mobile-activity/ws", {        target: "http://localhost:3001/socket.io",        pathRewrite: { "^/api/mobile-activity/ws": "" },        ws: true,      })    );      app.use(      proxy("/api/vehicle-accident-protocols", {        target: "http://10.1.1.24:7071",        pathRewrite: { "^/api/vehicle-accident-protocols": "" },      })    );  };  

I have tried reading about why we need this but most explanations I find online are about how to do this, rarely they explain clearly why we need this. Can someone in easily understandable way explain why we need this file? I am beginner as far as network infrastructure etc is concerned, that's why maybe I am failing to grasp why we need it.

What PODs files I need to add on GIT

Posted: 16 Nov 2021 09:12 AM PST

Function to check whether all the element in a list are numbers

Posted: 16 Nov 2021 09:13 AM PST

I need a function that checks whether an input list is made all of number. I am aware of other solutions but what I am looking for is a bit different. The input of the function is a tuple provided using *args, and I need the function to work with lists, as well as with numbers. Furthermore it must catch also numbers written as string.

this means it must works for the following inputs:

 - instance = CheckNumbersType([1,2,3,4,5,...])   - instance = CheckNumbersType(['1','2','3','4','5',...])   - instance = CheckNumbersType(1,2,3,4,5,...)   - instance = CheckNumbersType('1','2','3','4','5',...)  

Here is my code, it works but I do not think it is very efficient and it looks also a bit pedantic to me. Is there any library or oyu have any other idea to avoid nesting all the if...else and try...except?

class CheckNumbersType:      def __init__(self, *args):          self.values = args        def isfloat(self):          var = None          check = True          for item in self.values:              if type(item) == list:                  for value in item:                      try:                          float(value)                          var = True                      except ValueError:                          var = False                          print(var)              else:                  try:                      float(item)                      var = True                  except ValueError:                      var = False                check = check and var          return check  

Excel VBA copying specified set of worksheets to new workbook/excluding sheet from copy

Posted: 16 Nov 2021 09:12 AM PST

I am trying to copy only data from one workbook into a new one, but with only four of the existing worksheets. The code below allows me to successfully copy all worksheets to a new workbook. This worked fine before, but now I only want to copy sheet 2-7, thus excluding sheet 1.

This is done by a user copying data into sheet 1 and the data will be populated to sheets 2-5. Sheet 6 & 7 contains metadata which will be the same for all new workbooks. To be able to import the copied data, I need a new workbook with sheets 2-7.

Sub Button1_Click()    Dim Output As Workbook  Dim Current As String  Dim FileName As String      Set Output = ThisWorkbook  Current = ThisWorkbook.FullName    Application.DisplayAlerts = False    Dim SH As Worksheet  For Each SH In Output.Worksheets      SH.UsedRange.Copy      SH.UsedRange.PasteSpecial xlPasteValuesAndNumberFormats, _          Operation:=xlNone, SkipBlanks:=True, Transpose:=False  Next        FileName = ThisWorkbook.Path & "\" & "Generic name.xlsx" 'Change name as needed  Output.SaveAs FileName, XlFileFormat.xlOpenXMLWorkbook  Workbooks.Open Current  Output.Close  Application.DisplayAlerts = True    End Sub  

Any suggestions on how improve the code to only copy specified sheets, or to exclude sheet 1?

React ChakraUI ForwardRef child ignoring variant prop

Posted: 16 Nov 2021 09:12 AM PST

I'm having an issue with forwardRef and Input from ChakraUI.

I tried to do a generic input component which has always flushed variant. My problem is Chakra does reset variant to default.

ModalInput Component

import { forwardRef, InputProps, Input } from '@chakra-ui/react';    const ModalInput = forwardRef<InputProps, 'input'>((props, ref) => (      <Input ref={ref} color="gray.600" variant="flushed" {...props}>          {props.children}      </Input>  ));    export default ModalInput;  

ModalInput Component

<ModalInput placeholder="ex: Entreprise Dupont" />  

This way, all my ModalInput should have variant flushed, but you can see on the screenshot below it is outline.

screenshot outline

Thanks for help !

VHDL - looping through an array

Posted: 16 Nov 2021 09:13 AM PST

I wanted to loop through an array elements and later output them.

I don't think that the for loop is correct.

Could someone help with this, please ?

enter image description here

error defining env variables using jenkins pipeline

Posted: 16 Nov 2021 09:11 AM PST

So I have a jenkins pipeline which connects to the server and I would like it to define some env variables that are referencing some env variables from jenkins.

To connect to the server I am using sshCommand plugin:

def remote = [name: 'something', host : '${HOST}', password: '${PASSWORD}']  pipeline {      agent any      stages {          stage('env var'){              steps {                 sshCommand remote: remote, command: 'export ENV1=${env.ENV1}'              }          }      }   }  

However it outputs constantly the following error:

groovy.lang.MissingPropertyException: No such property: remote for class:   groovy.lang.Binding at groovy.lang.Binding.getVariable(Binding.java:63)  

Any ideas on where is this error coming from?

Interactive SendKeys PowerShell script

Posted: 16 Nov 2021 09:13 AM PST

Not by choice I had to port a Sendkeys script to run with PowerShell. We use this application that's backed up daily and the only way is to do it manually through the application. So to avoid having to sit there and do it manually every day, I created a Sendkeys script and it works without a hitch when I run it manually. However, the problem is when I schedule it. It does not open the application so the Sendkeys command are worthless. In Task Scheduler I have "powershell.exe" under Program/script and then under Add arguments (optional) I have "-ExecutionPolicy Bypass c:\users\User1\desktop\MIP_Backup_NpsSqlSys.ps1". I also added the folder and the exec to the windows 10 path and verified it is there. Any help whatsoever would be welcome. This is the Sendkeys script. It opens the application, clicks on the Menu and selects backup then the DB to backup. When it is done, it sends me an email. I do have start-sleep command in between but removed them to make now to make it shorter.

    'Start-Process "C:\Program Files (x86)\MIP\Progs\AcctAdv.exe"      $wshell = New-Object -ComObject wscript.shell      $wshell.AppActivate('Open Organization')      Add-Type -AssemblyName System.Windows.Forms      [System.Windows.Forms.SendKeys]::SendWait('admin{TAB}')      [System.Windows.Forms.SendKeys]::SendWait('PASSWORD{TAB}')      [System.Windows.Forms.SendKeys]::SendWait('DATABASE{ENTER}')      [System.Windows.Forms.SendKeys]::SendWait('%F{DOWN 2}{ENTER}')      [System.Windows.Forms.SendKeys]::SendWait('{ENTER}')      [System.Windows.Forms.SendKeys]::SendWait('{ENTER}')      [System.Windows.Forms.SendKeys]::SendWait('admin{TAB}')      [System.Windows.Forms.SendKeys]::SendWait('%{F4}')      $line1 = "MIP Backup."      $line2 = "Check the MIP backup to ensure it ran."      $line3 = "\\Server\d$\1-backups "      $line4 = "Name."      Send-MailMessage -smtpServer IP_ADDRESS_HERE -To MyEmailAddressHere.com -From MIP_Backup@One.local -Subject $line1 -Body  $line2`n`n$line3`n`n$line4  

Change Woocommerce order status programmatically

Posted: 16 Nov 2021 09:11 AM PST

I am trying to change order status by some conditionals by using woocommerce_thankyou action.

I created some custom order statuses with plugin: enter image description here

By using this function - nothing happen, the status remain "in hold" and not changed as wishes:

/*after order done*/  function check_and_change_status($order_id){      if ( is_checkout() && is_order_received_page() )  {                   $order = wc_get_order( $order_id );         $order_status = $order->get_status();         $product_in_order = false;         $items = $order->get_items();          $count = 0;           foreach ( $items as $item ) {                   $product_id = $item->get_product_id();               $is_start_from_product = the_feild('get_an_offer',  $product_id);                 $the_startFromPrice = the_feild('startFromPrice',  $product_id);             $the_winningPrice = the_feild('winningPrice',  $product_id);               if ($is_start_from_product && $count == 0) {                 $count++;                   $price_that_paid = $item->get_total();                 if($price_that_paid > $the_startFromPrice && $price_that_paid < $the_winningPrice){                     $order->update_status('auctionpending');                 }elseif($price_that_paid > $the_winningPrice){                      $order->update_status('auctionwon');                 }             }elseif ($is_start_from_product && $count > 0) {                 /*Do it later*/             }         }      }     }  add_action('woocommerce_thankyou','check_and_change_status');  

What i am missing? The conditional are work well (I have been debugged that), but the order status not changed.

Keycloak crashes when trying to start up in a Kubernetes Pod using helm

Posted: 16 Nov 2021 09:12 AM PST

Trying to run Keycloak as a standalone pod in Kubernetes. I ran helm create and here's what my values.yaml and service.yaml look like:

values.yaml

service:    type: NodePort    port: 30010    ingress:    enabled: false    annotations: {}    hosts:      - host: chart-example.local        paths: []    tls: []    resources: {}    nodeSelector: {}    tolerations: []    affinity: {}  

service.yaml

apiVersion: v1  kind: Service  metadata:    name: {{ include "keycloak.fullname" . }}    labels:      {{- include "keycloak.labels" . | nindent 4 }}  spec:    type: {{ .Values.service.type }}    ports:      - port: {{ .Values.service.port }}        targetPort: http        protocol: TCP        name: http    selector:      {{- include "keycloak.selectorLabels" . | nindent 4 }}  

For this install I just want to use the H2 embedded database.

When I run helm install keycloak . -f values.yaml and check the pod logs - I see the following logs in RED:

00:10:09,549 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (ServerService Thread Pool -- 68) javax.resource.ResourceException: IJ000470: You are trying to use a connection factory that has been shut down: java:jboss/datasources/KeycloakDS  00:10:09,560 ERROR [org.keycloak.connections.jpa.updater.liquibase.lock.CustomLockService] (ServerService Thread Pool -- 68) Database error during release lock: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: java.sql.SQLException: IJ031040: Connection is not associated with a managed connection: org.jboss.jca.adapters.jdbc.jdk8.WrappedConnectionJDK8@33fbc61f      at org.liquibase//liquibase.database.AbstractJdbcDatabase.commit(AbstractJdbcDatabase.java:1159)      at org.keycloak.keycloak-model-jpa@12.0.2//org.keycloak.connections.jpa.updater.liquibase.lock.CustomLockService.releaseLock(CustomLockService.java:241)      at org.keycloak.keycloak-model-jpa@12.0.2//org.keycloak.connections.jpa.updater.liquibase.lock.LiquibaseDBLockProvider.lambda$releaseLock$3(LiquibaseDBLockProvider.java:136)      at org.keycloak.keycloak-server-spi-private@12.0.2//org.keycloak.models.utils.KeycloakModelUtils.suspendJtaTransaction(KeycloakModelUtils.java:654)      at org.keycloak.keycloak-model-jpa@12.0.2//org.keycloak.connections.jpa.updater.liquibase.lock.LiquibaseDBLockProvider.releaseLock(LiquibaseDBLockProvider.java:131)      at org.keycloak.keycloak-services@12.0.2//org.keycloak.services.resources.KeycloakApplication$1.run(KeycloakApplication.java:140)      at org.keycloak.keycloak-server-spi-private@12.0.2//org.keycloak.models.utils.KeycloakModelUtils.runJobInTransaction(KeycloakModelUtils.java:228)      at org.keycloak.keycloak-services@12.0.2//org.keycloak.services.resources.KeycloakApplication.startup(KeycloakApplication.java:129)      at org.keycloak.keycloak-wildfly-extensions@12.0.2//org.keycloak.provider.wildfly.WildflyPlatform.onStartup(WildflyPlatform.java:29)      at org.keycloak.keycloak-services@12.0.2//org.keycloak.services.resources.KeycloakApplication.<init>(KeycloakApplication.java:115)      at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)      at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)      at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)      at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)      at org.jboss.resteasy.resteasy-jaxrs@3.13.2.Final//org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:152)      at org.jboss.resteasy.resteasy-jaxrs@3.13.2.Final//org.jboss.resteasy.spi.ResteasyProviderFactory.createProviderInstance(ResteasyProviderFactory.java:2815)      at org.jboss.resteasy.resteasy-jaxrs@3.13.2.Final//org.jboss.resteasy.spi.ResteasyDeployment.createApplication(ResteasyDeployment.java:371)      at org.jboss.resteasy.resteasy-jaxrs@3.13.2.Final//org.jboss.resteasy.spi.ResteasyDeployment.startInternal(ResteasyDeployment.java:283)      at org.jboss.resteasy.resteasy-jaxrs@3.13.2.Final//org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:93)      at org.jboss.resteasy.resteasy-jaxrs@3.13.2.Final//org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:140)      at org.jboss.resteasy.resteasy-jaxrs@3.13.2.Final//org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:42)      at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)      at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:78)      at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103)      at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:305)      at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:145)      at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:588)      at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:559)      at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)      at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)      at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)      at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)      at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)      at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)      at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)      at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:601)      at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:97)      at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:78)      at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)      at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)      at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)      at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)      at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)      at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)      at java.base/java.lang.Thread.run(Thread.java:834)      at org.jboss.threads@2.4.0.Final//org.jboss.threads.JBossThread.run(JBossThread.java:513)  Caused by: liquibase.exception.DatabaseException: java.sql.SQLException: IJ031040: Connection is not associated with a managed connection: org.jboss.jca.adapters.jdbc.jdk8.WrappedConnectionJDK8@33fbc61f      at org.liquibase//liquibase.database.jvm.JdbcConnection.commit(JdbcConnection.java:126)      at org.liquibase//liquibase.database.AbstractJdbcDatabase.commit(AbstractJdbcDatabase.java:1157)      ... 45 more  Caused by: java.sql.SQLException: IJ031040: Connection is not associated with a managed connection: org.jboss.jca.adapters.jdbc.jdk8.WrappedConnectionJDK8@33fbc61f      at org.jboss.ironjacamar.jdbcadapters@1.4.23.Final//org.jboss.jca.adapters.jdbc.WrappedConnection.lock(WrappedConnection.java:176)      at org.jboss.ironjacamar.jdbcadapters@1.4.23.Final//org.jboss.jca.adapters.jdbc.WrappedConnection.getAutoCommit(WrappedConnection.java:868)      at org.liquibase//liquibase.database.jvm.JdbcConnection.commit(JdbcConnection.java:122)      ... 46 more    00:10:09,563 FATAL [org.keycloak.services] (ServerService Thread Pool -- 68) Error during startup: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection      at org.hibernate@5.3.20.Final//org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154)      at org.hibernate@5.3.20.Final//org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1575)      at org.hibernate@5.3.20.Final//org.hibernate.query.Query.getResultList(Query.java:132)      at org.keycloak.keycloak-model-jpa@12.0.2//org.keycloak.models.jpa.MigrationModelAdapter.init(MigrationModelAdapter.java:58)      at org.keycloak.keycloak-model-jpa@12.0.2//org.keycloak.models.jpa.MigrationModelAdapter.<init>(MigrationModelAdapter.java:42)      at org.keycloak.keycloak-model-jpa@12.0.2//org.keycloak.models.jpa.JpaRealmProvider.getMigrationModel(JpaRealmProvider.java:79)      at org.keycloak.keycloak-model-infinispan@12.0.2//org.keycloak.models.cache.infinispan.RealmCacheSession.getMigrationModel(RealmCacheSession.java:145)      at org.keycloak.keycloak-server-spi-private@12.0.2//org.keycloak.migration.MigrationModelManager.migrate(MigrationModelManager.java:99)      at org.keycloak.keycloak-services@12.0.2//org.keycloak.services.resources.KeycloakApplication.migrateModel(KeycloakApplication.java:234)      at org.keycloak.keycloak-services@12.0.2//org.keycloak.services.resources.KeycloakApplication.migrateAndBootstrap(KeycloakApplication.java:175)      at org.keycloak.keycloak-services@12.0.2//org.keycloak.services.resources.KeycloakApplication$1.run(KeycloakApplication.java:138)      at org.keycloak.keycloak-server-spi-private@12.0.2//org.keycloak.models.utils.KeycloakModelUtils.runJobInTransaction(KeycloakModelUtils.java:228)      at org.keycloak.keycloak-services@12.0.2//org.keycloak.services.resources.KeycloakApplication.startup(KeycloakApplication.java:129)      at org.keycloak.keycloak-wildfly-extensions@12.0.2//org.keycloak.provider.wildfly.WildflyPlatform.onStartup(WildflyPlatform.java:29)      at org.keycloak.keycloak-services@12.0.2//org.keycloak.services.resources.KeycloakApplication.<init>(KeycloakApplication.java:115)      at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)      at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)      at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)      at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)      at org.jboss.resteasy.resteasy-jaxrs@3.13.2.Final//org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:152)      at org.jboss.resteasy.resteasy-jaxrs@3.13.2.Final//org.jboss.resteasy.spi.ResteasyProviderFactory.createProviderInstance(ResteasyProviderFactory.java:2815)      at org.jboss.resteasy.resteasy-jaxrs@3.13.2.Final//org.jboss.resteasy.spi.ResteasyDeployment.createApplication(ResteasyDeployment.java:371)      at org.jboss.resteasy.resteasy-jaxrs@3.13.2.Final//org.jboss.resteasy.spi.ResteasyDeployment.startInternal(ResteasyDeployment.java:283)      at org.jboss.resteasy.resteasy-jaxrs@3.13.2.Final//org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:93)      at org.jboss.resteasy.resteasy-jaxrs@3.13.2.Final//org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:140)      at org.jboss.resteasy.resteasy-jaxrs@3.13.2.Final//org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:42)      at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)      at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:78)      at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103)      at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:305)      at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:145)      at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:588)      at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:559)      at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)      at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)      at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)      at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)      at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)      at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)      at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)      at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:601)      at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:97)      at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:78)      at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)      at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)      at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)      at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)      at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)      at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)      at java.base/java.lang.Thread.run(Thread.java:834)      at org.jboss.threads@2.4.0.Final//org.jboss.threads.JBossThread.run(JBossThread.java:513)  Caused by: org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection      at org.hibernate@5.3.20.Final//org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47)      at org.hibernate@5.3.20.Final//org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)      at org.hibernate@5.3.20.Final//org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99)      at org.hibernate@5.3.20.Final//org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:109)      at org.hibernate@5.3.20.Final//org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:136)      at org.hibernate@5.3.20.Final//org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:50)      at org.hibernate@5.3.20.Final//org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149)      at org.hibernate@5.3.20.Final//org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176)      at org.hibernate@5.3.20.Final//org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151)      at org.hibernate@5.3.20.Final//org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2082)      at org.hibernate@5.3.20.Final//org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2012)      at org.hibernate@5.3.20.Final//org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1990)      at org.hibernate@5.3.20.Final//org.hibernate.loader.Loader.doQuery(Loader.java:949)      at org.hibernate@5.3.20.Final//org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:351)      at org.hibernate@5.3.20.Final//org.hibernate.loader.Loader.doList(Loader.java:2787)      at org.hibernate@5.3.20.Final//org.hibernate.loader.Loader.doList(Loader.java:2770)      at org.hibernate@5.3.20.Final//org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2604)      at org.hibernate@5.3.20.Final//org.hibernate.loader.Loader.list(Loader.java:2599)      at org.hibernate@5.3.20.Final//org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:505)      at org.hibernate@5.3.20.Final//org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:395)      at org.hibernate@5.3.20.Final//org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:220)      at org.hibernate@5.3.20.Final//org.hibernate.internal.SessionImpl.list(SessionImpl.java:1526)      at org.hibernate@5.3.20.Final//org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1598)      at org.hibernate@5.3.20.Final//org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1566)      ... 49 more  Caused by: java.sql.SQLException: javax.resource.ResourceException: IJ000470: You are trying to use a connection factory that has been shut down: java:jboss/datasources/KeycloakDS      at org.jboss.ironjacamar.jdbcadapters@1.4.23.Final//org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:159)      at org.jboss.as.connector@21.0.2.Final//org.jboss.as.connector.subsystems.datasources.WildFlyDataSource.getConnection(WildFlyDataSource.java:64)      at org.hibernate@5.3.20.Final//org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122)      at org.hibernate@5.3.20.Final//org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:35)      at org.hibernate@5.3.20.Final//org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:106)      ... 69 more  Caused by: javax.resource.ResourceException: IJ000470: You are trying to use a connection factory that has been shut down: java:jboss/datasources/KeycloakDS      at org.jboss.ironjacamar.impl@1.4.23.Final//org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:777)      at org.jboss.ironjacamar.jdbcadapters@1.4.23.Final//org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:151)      ... 73 more  

It seems like there's some issue with starting up it's own H2 db - it's unable to acquire database connection - what more can I do here?

Unable to load AWS credentials from any provider in the chain: WebIdentityTokenCredentialsProvider: Unable to locate specified web identity token file

Posted: 16 Nov 2021 09:11 AM PST

I am deploying my service using aws eks fargate deployment.yaml file and my service will connnect to dynamodb and while loading the id it throws the error. Even though I have web token file by following command.

kubectl exec -n first-namespace first-deployment-fhghgj567kkk-257xq env | grep AWS    AWS_REGION=us-east-1  AWS_ROLE_ARN=arn:aws:iam::263011912432:role/firstRole  AWS_WEB_IDENTITY_TOKEN_FILE=/var/run/secrets/eks.amazonaws.com/serviceaccount/token  

But still it throws the following error.

Caused by: com.amazonaws.SdkClientException: Unable to load AWS credentials from any provider in the chain:   [EnvironmentVariableCredentialsProvider:   Unable to load AWS credentials from environment variables (AWS_ACCESS_KEY_ID (or AWS_ACCESS_KEY)   and AWS_SECRET_KEY (or AWS_SECRET_ACCESS_KEY)),   SystemPropertiesCredentialsProvider: Unable to load AWS credentials from Java system properties (aws.accessKeyId and aws.secretKey),   WebIdentityTokenCredentialsProvider: Unable to locate specified web identity token file:   /var/run/secrets/eks.amazonaws.com/serviceaccount/token,   com.amazonaws.auth.profile.ProfileCredentialsProvider@7b58e085: profile file cannot be null,   com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper@39cb0014: Failed to connect to service endpoint: ]  

I ssh into container and checked the token appears there its still present.

Can anyone please help? Thanks

No comments:

Post a Comment