问:
To-do list application: Why does my code prevent me from deleting the most recently added list element?
I'm trying to create a to-do list application. I'm using JS to dynamically create list elements on the web page when a user clicks on the submit button along with their user input.

Here's what I have so far:

const inputTXT = document.querySelector('.inputText');          //input element
const submitBUTT = document.querySelector('.submitButton');     //button element
const listITEMS = document.querySelector('.items');             //list element

function createListElement(inputString){

    const newListItem = document.createElement("li");
    const newEditButton = document.createElement("button");
    const newDeleteButton = document.createElement("button");

    const listText = document.createTextNode(inputString);
    newListItem.appendChild(listText);
    const editText = document.createTextNode("Edit");
    newEditButton.appendChild(editText);
    const deleteText = document.createTextNode("Delete");
    newDeleteButton.appendChild(deleteText);

    newListItem.appendChild(newEditButton);
    newListItem.appendChild(newDeleteButton);

    //assign class to each list element for line below:
    newDeleteButton.className = "deleteCLASS";
    newEditButton.className = "editCLASS";

    //delete function:
    var deleteButtonArray = document.querySelectorAll(".deleteCLASS");

    for(var i=0; i < deleteButtonArray.length ; ++i){
        deleteButtonArray[i].onclick = function(){
            this.parentNode.remove();
        }
    }

    return newListItem;
}

function addTask(){
    listITEMS.classList.remove('hidden');
    const ITEM = createListElement(inputTXT.value);
    document.getElementsByClassName("items")[0].appendChild(ITEM);
    inputTXT.value = '';    //Resets user input string
}

submitBUTT.addEventListener("click", addTask);```
<pre class="snippet-code-css lang-css prettyprint-override"><code>*{
    margin: 0;
    padding: 0;
}

.container{
    width: 800px;
    margin: 0 auto;
    font-family: sans-serif;
}

.main-header{
    background: #e7e7e7;
    text-align: center;
    margin: 15px;
    padding: 20px;
}

.inputText{
    margin-top: 20px;

}

h1{
    font-size: 35px;
}

ul{
    list-style: square;
    margin-left: 275px;
}

.hidden{
    display: none;
}

.itemLIST{
    margin-bottom: 5px;
}

.editBUTT{
    margin-left: 20px;
}

.deleteBUTT{
    margin-left: 4px;
}</code>```

<!DOCTYPE html>

        <title> "To-do List" </title>
        <link href="style.css" rel="stylesheet"/>
        <meta charset = "UTF-8"/>

My To-do List

                <input type="text" placeholder = "Enter Item"  class= "inputText" required>

                <button class = "submitButton">Submit</button>

```

This works for the most parts, but I cannot delete the last list element for some reason.

The only debugging I've done to figure out what is happening is print out the "deleteButtonArray" variable, which uses the keyword "querySelectorAll". From this, I found out that when the user hits the submit button, an empty NodeList printed. When the user hits the submit button a second time, only then do we get a NodeList with 1 element. When the user hits the submit button a third time, we get a NodeList with 2 elements.

It looked like the problem had something to do with querySelectorAll not properly updating in time when the user hits the submit button. I replaced it with getElementsByClassName, and still the same issue.

Now, I think the problem has something to do with the way I'm trying to implement the delete function within the createListElement function.

The way I think my code works:
Every time a user hits the submit button, a list element is created along with an array (actually a NodeList) that contains all the list elements present so far. This means that if I delete list elements, the array will update with the correct number of list elements.

And, it does update correctly, for the most parts. I just don't know why the array is empty when we first create an element. Shouldn't querySelectorAll or getElementsByClassName return a non-empty NodeList when the user first hits the submit button?

答:
All right, so here's a solution I've tried and tested it, and it seems to be working.

I removed the delete item portion out of the createListElement function, made it its own function, and added an event listener to each delete button that's created, so it will run the now separate delete function when clicked.

No changes were made to the HTML or the CSS.

```<code>const inputTXT = document.querySelector('.inputText');          //input element
const submitBUTT = document.querySelector('.submitButton');     //button element
const listITEMS = document.querySelector('.items');             //list element

function createListElement(inputString){

    const newListItem = document.createElement("li");
    const newEditButton = document.createElement("button");
    const newDeleteButton = document.createElement("button");

    const listText = document.createTextNode(inputString);
    newListItem.appendChild(listText);
    const editText = document.createTextNode("Edit");
    newEditButton.appendChild(editText);
    const deleteText = document.createTextNode("Delete");
    newDeleteButton.appendChild(deleteText);

    newListItem.appendChild(newEditButton);
    newListItem.appendChild(newDeleteButton);

//Here is the new addEventListener
    newDeleteButton.addEventListener("click", deleteStuff);

    //assign class to each list element for line below:
    newDeleteButton.className = "deleteCLASS";
    newEditButton.className = "editCLASS";

    return newListItem;
}

//Here is the new delete function. The onclick function that was there before has been removed because, in this case, it's not needed.
function deleteStuff() {
   //delete function:
    var deleteButtonArray = document.querySelectorAll(".deleteCLASS");

    for(var i=0; i < deleteButtonArray.length ; ++i){
            this.parentNode.remove();
    }
}

function addTask(){
    listITEMS.classList.remove('hidden');
    const ITEM = createListElement(inputTXT.value);
    document.getElementsByClassName("items")[0].appendChild(ITEM);
    inputTXT.value = '';    //Resets user input string
}

submitBUTT.addEventListener("click", addTask);
</code>```

Body:
I'm trying to create a to-do list application. I'm using JS to dynamically create list elements on the web page when a user clicks on the submit button along with their user input.

Here's what I have so far:

const inputTXT = document.querySelector('.inputText');          //input element
const submitBUTT = document.querySelector('.submitButton');     //button element
const listITEMS = document.querySelector('.items');             //list element

function createListElement(inputString){

    const newListItem = document.createElement("li");
    const newEditButton = document.createElement("button");
    const newDeleteButton = document.createElement("button");

    const listText = document.createTextNode(inputString);
    newListItem.appendChild(listText);
    const editText = document.createTextNode("Edit");
    newEditButton.appendChild(editText);
    const deleteText = document.createTextNode("Delete");
    newDeleteButton.appendChild(deleteText);

    newListItem.appendChild(newEditButton);
    newListItem.appendChild(newDeleteButton);

    //assign class to each list element for line below:
    newDeleteButton.className = "deleteCLASS";
    newEditButton.className = "editCLASS";

    //delete function:
    var deleteButtonArray = document.querySelectorAll(".deleteCLASS");

    for(var i=0; i < deleteButtonArray.length ; ++i){
        deleteButtonArray[i].onclick = function(){
            this.parentNode.remove();
        }
    }

    return newListItem;
}

function addTask(){
    listITEMS.classList.remove('hidden');
    const ITEM = createListElement(inputTXT.value);
    document.getElementsByClassName("items")[0].appendChild(ITEM);
    inputTXT.value = '';    //Resets user input string
}

submitBUTT.addEventListener("click", addTask);

*{
    margin: 0;
    padding: 0;
}

.container{
    width: 800px;
    margin: 0 auto;
    font-family: sans-serif;
}

.main-header{
    background: #e7e7e7;
    text-align: center;
    margin: 15px;
    padding: 20px;
}

.inputText{
    margin-top: 20px;

}

h1{
    font-size: 35px;
}

ul{
    list-style: square;
    margin-left: 275px;
}

.hidden{
    display: none;
}

.itemLIST{
    margin-bottom: 5px;
}

.editBUTT{
    margin-left: 20px;
}

.deleteBUTT{
    margin-left: 4px;
}

<!DOCTYPE html>

        <title> "To-do List" </title>
        <link href="style.css" rel="stylesheet"/>
        <meta charset = "UTF-8"/>

My To-do List

                <input type="text" placeholder = "Enter Item"  class= "inputText" required>

                <button class = "submitButton">Submit</button>

This works for the most parts, but I cannot delete the last list element for some reason.

The only debugging I've done to figure out what is happening is print out the "deleteButtonArray" variable, which uses the keyword "querySelectorAll". From this, I found out that when the user hits the submit button, an empty NodeList printed. When the user hits the submit button a second time, only then do we get a NodeList with 1 element. When the user hits the submit button a third time, we get a NodeList with 2 elements.

It looked like the problem had something to do with querySelectorAll not properly updating in time when the user hits the submit button. I replaced it with getElementsByClassName, and still the same issue.

Now, I think the problem has something to do with the way I'm trying to implement the delete function within the createListElement function.

The way I think my code works:
Every time a user hits the submit button, a list element is created along with an array (actually a NodeList) that contains all the list elements present so far. This means that if I delete list elements, the array will update with the correct number of list elements.

And, it does update correctly, for the most parts. I just don't know why the array is empty when we first create an element. Shouldn't querySelectorAll or getElementsByClassName return a non-empty NodeList when the user first hits the submit button?

Body:
All right, so here's a solution I've tried and tested it, and it seems to be working.

I removed the delete item portion out of the createListElement function, made it its own function, and added an event listener to each delete button that's created, so it will run the now separate delete function when clicked.

No changes were made to the HTML or the CSS.

const inputTXT = document.querySelector('.inputText');          //input element
const submitBUTT = document.querySelector('.submitButton');     //button element
const listITEMS = document.querySelector('.items');             //list element

function createListElement(inputString){

    const newListItem = document.createElement("li");
    const newEditButton = document.createElement("button");
    const newDeleteButton = document.createElement("button");

    const listText = document.createTextNode(inputString);
    newListItem.appendChild(listText);
    const editText = document.createTextNode("Edit");
    newEditButton.appendChild(editText);
    const deleteText = document.createTextNode("Delete");
    newDeleteButton.appendChild(deleteText);

    newListItem.appendChild(newEditButton);
    newListItem.appendChild(newDeleteButton);

//Here is the new addEventListener
    newDeleteButton.addEventListener("click", deleteStuff);

    //assign class to each list element for line below:
    newDeleteButton.className = "deleteCLASS";
    newEditButton.className = "editCLASS";

    return newListItem;
}

//Here is the new delete function. The onclick function that was there before has been removed because, in this case, it's not needed.
function deleteStuff() {
   //delete function:
    var deleteButtonArray = document.querySelectorAll(".deleteCLASS");

    for(var i=0; i < deleteButtonArray.length ; ++i){
            this.parentNode.remove();
    }
}

function addTask(){
    listITEMS.classList.remove('hidden');
    const ITEM = createListElement(inputTXT.value);
    document.getElementsByClassName("items")[0].appendChild(ITEM);
    inputTXT.value = '';    //Resets user input string
}

submitBUTT.addEventListener("click", addTask);


来源: stackexchange

问:
What is the keycode for search/next/send button
does anyone know what keycode I have to press for this Send/Search/Next button?
I'm trying to send a chat message and can't find a solution to this one.
Already tried keycode: 66 and 84.

keyboard view

答:
For adding action on click of send/done button of soft keyboard, Need to add setOnEditorActionListener to edittext.

EditText code in xml :

```<code>        <EditText
            android:id="@+id/editText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:imeOptions="actionSend"
            android:singleLine="true"/>
</code>```

In Java class:

```<code>    editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEND) {
                String text = editText.getText().toString();
                Log.e(TAG,"text-----"+text);
                return true;
            }
            return false;
        }
    });
</code>```

You can add any imeOptions to edittext according to your requirement.

For more info related to EditerInfo check official doc.

ContentLicense: CC BY-SA 4.0

Body:
For adding action on click of send/done button of soft keyboard, Need to add setOnEditorActionListener to edittext.

EditText code in xml :

        <EditText
            android:id="@+id/editText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:imeOptions="actionSend"
            android:singleLine="true"/>

In Java class:

    editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEND) {
                String text = editText.getText().toString();
                Log.e(TAG,"text-----"+text);
                return true;
            }
            return false;
        }
    });

You can add any imeOptions to edittext according to your requirement.

For more info related to EditerInfo check official doc.


问:
Deploy war with Spring boot app and react app in Tomcat
I have the backend with Spring Boot and the frontend with React. I'm trying to deploy all in a war to Tomcat 9.0.56.

In the Spring Boot I put in the properties:

```<code>spring.resources.static-locations=classpath:/build/
spring.thymeleaf.prefix=classpath:/build/
</code>```

In the react app in the package.json I have:

```<code>"homepage": "localhost:8080"
</code>```

Then I build the react app and put it in the folder api/src/main/resources/build

I build the war and deploy it as ROOT.war

When I enter to the application it wont load as it don't find the js and css, it looks like a CORS problem of Tomcat:

This only happen with react apps, because if I put a single html page, it works fine.

I try configuring CORS in Tomcat with:

```<code> <filter>
  <filter-name>CorsFilter</filter-name>
  <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
  <init-param>
    <param-name>cors.allowed.origins</param-name>
    <param-value>*</param-value>
  </init-param>
</filter>
<filter-mapping>
  <filter-name>CorsFilter</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>
</code>```

but it doesn't work either.

Any idea?

Thanks!!

Body:
I have the backend with Spring Boot and the frontend with React. I'm trying to deploy all in a war to Tomcat 9.0.56.

In the Spring Boot I put in the properties:

spring.resources.static-locations=classpath:/build/
spring.thymeleaf.prefix=classpath:/build/

In the react app in the package.json I have:

"homepage": "localhost:8080"

Then I build the react app and put it in the folder api/src/main/resources/build

I build the war and deploy it as ROOT.war

When I enter to the application it wont load as it don't find the js and css, it looks like a CORS problem of Tomcat:

This only happen with react apps, because if I put a single html page, it works fine.

I try configuring CORS in Tomcat with:

 <filter>
  <filter-name>CorsFilter</filter-name>
  <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
  <init-param>
    <param-name>cors.allowed.origins</param-name>
    <param-value>*</param-value>
  </init-param>
</filter>
<filter-mapping>
  <filter-name>CorsFilter</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

but it doesn't work either.

Any idea?

Thanks!!

Body: "homepage": "."


问:
TypeScript 4.5: Module not found importing local file
I have a node express based application with the following tsconfig:

```<code>{
  "compilerOptions": {
    "lib": [ "es6", "es2021", "esnext" ],
    "target": "esnext",
    "module": "es2022",
    "composite": true,
    "declaration": true,
    "declarationMap": true,
    "forceConsistentCasingInFileNames": true,
    "importHelpers": true,
    "newLine": "LF",
    "noFallthroughCasesInSwitch": true,
    "noImplicitReturns": true,
    "noUncheckedIndexedAccess": true,
    "noUnusedLocals": false,
    "noUnusedParameters": false,
    "preserveConstEnums": true,
    "removeComments": true,
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "noImplicitAny": true,
    "moduleResolution": "Node",
    "sourceMap": false,
    "rootDir": "./src",
    "outDir": "./dist",
    "baseUrl": "./src",
    "paths": {
      "*": [
        "node_modules/*"
    ]
}
</code>```

},
}

Note: switching my module to commonjs is NOT a soultion, I want it to be built as a module.

I get an error on the very first local file import in my index file, but the file it says it can't find (module not found) does exist, it has a default export and the build output does have a .d.ts file beside it with a type export for it as well.

I can't figure out why it just isn't working.

Error:

```<code>Cannot find module 'workspace\dist\config\csrf' imported from workspace\dist\index.js
</code>```

Note: I replaced the absolute path with a workspace placeholder. In this case, I have a file: src/config/csrf.ts which is being built / transpiled to dist/config/csrf.js, and it all seems to be in check, and yet it doesn't import.

Given this is the very first local file import in the entry file, I'd assume all the others will have the same problem.

What's going on, just how am I supposed to be resolving my local files when building a module?

My exports are like this:

```<code>const csrf = () => {
    // Code ommitted
}
export default csrf;
</code>```

Using Node ^16.13.2 and TypeScript 4.5.6

Edit : I have the following scripts set up

```<code>  "scripts": {
    "clean": "rm -rf dist/",
    "lint": "tslint -c tslint.json -p tsconfig.json --fix",
    "tsc": "tsc",
    "build": "npm run clean && npm run lint && npm run tsc",
    "build:light": "npm run tsc",
    "migrate:dev": "npx prisma migrate dev",
    "migrate:prod": "npm run migrate:prod && npm run prisma:generate",
    "dev:start": "npm run build && npm run start",
    "dev:light": "npm run build:light && npm run start",
    "dev": "nodemon --watch src -e ts,ejs --exec npm run dev:start",
    "light": "nodemon --watch src -e ts,ejs --exec npm run dev:light",
    "start": "node -r dotenv/config .",
    "test": "echo \"Error: no test specified\" && exit 1"
</code>```

},

And the error occurs when using npm run dev or npm run light.

So do note, TypeScript compiles fine, this error is occurring when the actual built JavaScript is run via node.

Edit: I've found out that, if I manually update the built JavaScript import it works

E.g.:

```<code>import csrf from "./config/csrf";
</code>```

updates to:

```<code>import csrf from "./config/csrf.js"
</code>```

it suddenly works,

What the hell? I shouldn't have vto manually update all of my transpiled files, right? What's the proper approach to having your TypeScript imports transpile to compatible JavaScript imports?

This just seems extremely convoluted and unnecessary. What am I missing? It makes zero sense to have ".js" on the imports in the TypeScript just so the built output will actually run

答:
The got package on github has a pretty handy / nifty guide on converting from commonjs to ESM, for both js and TypeScript:

According to this, you do indeed need to add the .js extension to imports on the TypeScript files, so I've done this. it's working and I have encountered a different problem which will raise a new question.

Body:
I have a node express based application with the following tsconfig:

{
  "compilerOptions": {
    "lib": [ "es6", "es2021", "esnext" ],
    "target": "esnext",
    "module": "es2022",
    "composite": true,
    "declaration": true,
    "declarationMap": true,
    "forceConsistentCasingInFileNames": true,
    "importHelpers": true,
    "newLine": "LF",
    "noFallthroughCasesInSwitch": true,
    "noImplicitReturns": true,
    "noUncheckedIndexedAccess": true,
    "noUnusedLocals": false,
    "noUnusedParameters": false,
    "preserveConstEnums": true,
    "removeComments": true,
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "noImplicitAny": true,
    "moduleResolution": "Node",
    "sourceMap": false,
    "rootDir": "./src",
    "outDir": "./dist",
    "baseUrl": "./src",
    "paths": {
      "*": [
        "node_modules/*"
    ]
}

},
}

Note: switching my module to commonjs is NOT a soultion, I want it to be built as a module.

I get an error on the very first local file import in my index file, but the file it says it can't find (module not found) does exist, it has a default export and the build output does have a .d.ts file beside it with a type export for it as well.

I can't figure out why it just isn't working.

Error:

Cannot find module 'workspace\dist\config\csrf' imported from workspace\dist\index.js

Note: I replaced the absolute path with a workspace placeholder. In this case, I have a file: src/config/csrf.ts which is being built / transpiled to dist/config/csrf.js, and it all seems to be in check, and yet it doesn't import.

Given this is the very first local file import in the entry file, I'd assume all the others will have the same problem.

What's going on, just how am I supposed to be resolving my local files when building a module?

My exports are like this:

const csrf = () => {
    // Code ommitted
}
export default csrf;

Using Node ^16.13.2 and TypeScript 4.5.6

Edit : I have the following scripts set up

  "scripts": {
    "clean": "rm -rf dist/",
    "lint": "tslint -c tslint.json -p tsconfig.json --fix",
    "tsc": "tsc",
    "build": "npm run clean && npm run lint && npm run tsc",
    "build:light": "npm run tsc",
    "migrate:dev": "npx prisma migrate dev",
    "migrate:prod": "npm run migrate:prod && npm run prisma:generate",
    "dev:start": "npm run build && npm run start",
    "dev:light": "npm run build:light && npm run start",
    "dev": "nodemon --watch src -e ts,ejs --exec npm run dev:start",
    "light": "nodemon --watch src -e ts,ejs --exec npm run dev:light",
    "start": "node -r dotenv/config .",
    "test": "echo \"Error: no test specified\" && exit 1"

},

And the error occurs when using npm run dev or npm run light.

So do note, TypeScript compiles fine, this error is occurring when the actual built JavaScript is run via node.

Edit: I've found out that, if I manually update the built JavaScript import it works

E.g.:

import csrf from "./config/csrf";

updates to:

import csrf from "./config/csrf.js"

it suddenly works,

What the hell? I shouldn't have vto manually update all of my transpiled files, right? What's the proper approach to having your TypeScript imports transpile to compatible JavaScript imports?

This just seems extremely convoluted and unnecessary. What am I missing? It makes zero sense to have ".js" on the imports in the TypeScript just so the built output will actually run


问:
How to fix the error Error connecting to the KeX server?
When I run the kex, it gives this error</p>
```<code>Error connecting to the KeX server.
Please try "kex start" to start the service.
If the server fails to start, please try "kex kill" or restart your WSL2 session and try again.

</code>```

答:
i solved the same problem</p>
```<code>sudo apt remove -y kali-win-kex && sudo apt install -y kali-win-kex
</code>```

Body:
When I run the kex, it gives this error

Error connecting to the KeX server.
Please try "kex start" to start the service.
If the server fails to start, please try "kex kill" or restart your WSL2 session and try again.

Body:
i solved the same problem

sudo apt remove -y kali-win-kex && sudo apt install -y kali-win-kex


问:
vscode snippets: How to link a position in the snippet to a tabstop?
I want to create a snippet that prints the value of a variable for debugging purposes. this is what I came up with:

{
  "Debug": {
    "prefix": ["db"],
    "body": ["console.log(\"$1 :\", $1)"]
  }
}
```
<p>When I use this snippet cursor goes between the quotes ( | is the cursor position):</p>
<pre class="lang-js prettyprint-override"><code>console.log("| :",)
</code>```

And after I typed the name of a variable it copies the name to the second parameter:

console.log("name :", name)
```
<p>But I can't use autocompletion in strings. sometimes the variable is an object and auto-completion helps me pick a specific key of the object. I want the cursor to stop in the second parameter so I can use autocompletion:</p>
<pre class="lang-js prettyprint-override"><code>console.log(" :", |)
</code>```

And whatever I type should be copied inside the double-quotes:

console.log("name :", name)
```

just like the previous example but backward.

How can I do that?

UPDATE:
I created an issue: https://github.com/microsoft/vscode/issues/142327

答:
I assume you have Editor > Suggest: Snippets Prevent Quick Suggestions disabled and

```<code>"editor.quickSuggestions": {
  "other": true,
  "comments": true,
  "strings": true       // the important one here
},
</code>```

In my testing even with those settings it still doesn't work.  That does look like a bug.  It fails even on the simpler case "\"$1\" $1".  So something about being in a string is preventing intellisense despite the settings above.

But there is a workaround:

```<code>"Debug": {
  "prefix": ["db"],
  "body": [
        // select everything you want to surround with quotes
    "console.log(${2:$1 :}, $1)"   // you will get intellisense
  ]
}
</code>```

The ${2:...} will select the result of tabstop 1 +  : and then you can hit " to surround that selection with quotes.  You just have to hit one more tab then you might be expecting.

Body:
I want to create a snippet that prints the value of a variable for debugging purposes. this is what I came up with:

{
  "Debug": {
    "prefix": ["db"],
    "body": ["console.log(\"$1 :\", $1)"]
  }
}

When I use this snippet cursor goes between the quotes ( | is the cursor position):

console.log("| :",)

And after I typed the name of a variable it copies the name to the second parameter:

console.log("name :", name)

But I can't use autocompletion in strings. sometimes the variable is an object and auto-completion helps me pick a specific key of the object. I want the cursor to stop in the second parameter so I can use autocompletion:

console.log(" :", |)

And whatever I type should be copied inside the double-quotes:

console.log("name :", name)

just like the previous example but backward.

How can I do that?

UPDATE:
I created an issue: https://github.com/microsoft/vscode/issues/142327

Body:
I assume you have Editor > Suggest: Snippets Prevent Quick Suggestions disabled and

"editor.quickSuggestions": {
  "other": true,
  "comments": true,
  "strings": true       // the important one here
},

In my testing even with those settings it still doesn't work.  That does look like a bug.  It fails even on the simpler case "\"$1\" $1".  So something about being in a string is preventing intellisense despite the settings above.

But there is a workaround:

"Debug": {
  "prefix": ["db"],
  "body": [
        // select everything you want to surround with quotes
    "console.log(${2:$1 :}, $1)"   // you will get intellisense
  ]
}

The ${2:...} will select the result of tabstop 1 +  : and then you can hit " to surround that selection with quotes.  You just have to hit one more tab then you might be expecting.


问:
Is there any way to easily make statistics by ten days using DolphinDB?
The semiMonthBegin(X, [dayOfMonth=15], [offset], [n=1]) function works fine with the default dayOfMonth=15 day cycle. However, if I want to calculate on ten-day basis and set dayOfMonth=10, the result is wrong.

Is there any way to fix it?

答:
semiMonthBegin is not suitable for ten-day-based calculation. You can use a user-defined function with a group by clause. For example:

```<code>def f(x) {
    Count = x.size()
    res = array(STRING, Count)
    for (i in 0:Count){
        if(int(x[i].format("dd"))<=10){
            res[i] = x[i].format("yyyy.MM.")+"10"
        }
        else if(int(x[i].format("dd")) <=20){
            res[i] = monthEnd(x[i]).format("yyy.MM.dd")
        }
    return res
}
t1 = select *, date(f(date)) as xun from t1
select avg(price), sum(qty) from t1 group by xun;
</code>```

You can also use dayOfMonth function to calculate by any day.

```<code>select *, date-(dayofMonth(date)-1)%10 as xun from t1
</code>```

Body:
semiMonthBegin is not suitable for ten-day-based calculation. You can use a user-defined function with a group by clause. For example:

def f(x) {
    Count = x.size()
    res = array(STRING, Count)
    for (i in 0:Count){
        if(int(x[i].format("dd"))<=10){
            res[i] = x[i].format("yyyy.MM.")+"10"
        }
        else if(int(x[i].format("dd")) <=20){
            res[i] = monthEnd(x[i]).format("yyy.MM.dd")
        }
    return res
}
t1 = select *, date(f(date)) as xun from t1
select avg(price), sum(qty) from t1 group by xun;

You can also use dayOfMonth function to calculate by any day.

select *, date-(dayofMonth(date)-1)%10 as xun from t1


问:
Why wont the ../ file path work in css and html?
You see, whenever I try to use ../ in CSS or HTML, it doesn't appear to work, It just gives me this error: GET file:///C:/Users/MYUSERNAME/Desktop/Coin%20Clicker/source/coin.png net::ERR_FILE_NOT_FOUND even though I used ../images/. Keep in mind coin.png is in images, not source. However, if I do this in javascript, which is in a different file than the HTML file, it does appear to work. Any idea why this occurs? here is my code:

CSS:

#coin {
  background-image: url("../images/coin.png");
  border: none;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 200px 200px;
  background-color: white;
  border-radius: 50%;
  width: 200px;
  height: 200px;
}
#coin:active {
  background-image: url("../images/coin-pressed-in.png");
}
```
<p>HTML:</p>
<pre class="lang-html prettyprint-override"><code><div>
  <span id="count">0¢</span>
</div>

  <button id="coin" alt="coin" onclick="plusOne()"></button>

<script src="script.js"></script>
</code>```

javascript:

var dollar = 0;
var cents = 0;
var count = document.getElementById("count");

function plusOne() {
  if (cents < 95) {
    cents +=5;
    count.innerHTML = cents + " ¢";
  } else if (cents == 95) {
    dollar = 1;
    cents = 100;
    count.innerHTML = dollar + " $";
  } else if (dollar >= 1) {
    dollar += 0.05;
    count.innerHTML = round(dollar, 2) + " $";
  }
}

function round(value, decimals) {
  return Number(Math.round(value+'e'+decimals)+'e-'+decimals);
}

document.getElementById("favicon").href = "coin.png";

document.addEventListener("visibilitychange", (event) => {
  if (document.visibilityState == "visible") {
    document.getElementById("favicon").href = "../images/coin.png";
  } else {
    document.getElementById("favicon").href = "../images/coin-disabled.png";
  }
});
```
<p>File directory:</p>
<pre class="lang-none prettyprint-override"><code>- images/
    * coin.png
    * coin-disabled.png
    * coin-pressed-in.png
- source/
    * coin.html
    * script.js
</code>```

答: The tag will be href = "/images/coin.png" or href = "images/coin.png".it will work.this will same as url tag  like this url("images/coin.png").

Body:
You see, whenever I try to use ../ in CSS or HTML, it doesn't appear to work, It just gives me this error: GET file:///C:/Users/MYUSERNAME/Desktop/Coin%20Clicker/source/coin.png net::ERR_FILE_NOT_FOUND even though I used ../images/. Keep in mind coin.png is in images, not source. However, if I do this in javascript, which is in a different file than the HTML file, it does appear to work. Any idea why this occurs? here is my code:

CSS:

#coin {
  background-image: url("../images/coin.png");
  border: none;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 200px 200px;
  background-color: white;
  border-radius: 50%;
  width: 200px;
  height: 200px;
}
#coin:active {
  background-image: url("../images/coin-pressed-in.png");
}

HTML:

  0¢

  <button id="coin" alt="coin" onclick="plusOne()"></button>

javascript:

var dollar = 0;
var cents = 0;
var count = document.getElementById("count");

function plusOne() {
  if (cents < 95) {
    cents +=5;
    count.innerHTML = cents + " ¢";
  } else if (cents == 95) {
    dollar = 1;
    cents = 100;
    count.innerHTML = dollar + " $";
  } else if (dollar >= 1) {
    dollar += 0.05;
    count.innerHTML = round(dollar, 2) + " $";
  }
}

function round(value, decimals) {
  return Number(Math.round(value+'e'+decimals)+'e-'+decimals);
}

document.getElementById("favicon").href = "coin.png";

document.addEventListener("visibilitychange", (event) => {
  if (document.visibilityState == "visible") {
    document.getElementById("favicon").href = "../images/coin.png";
  } else {
    document.getElementById("favicon").href = "../images/coin-disabled.png";
  }
});

File directory:

- images/
    * coin.png
    * coin-disabled.png
    * coin-pressed-in.png
- source/
    * coin.html
    * script.js


问:
Pyarrow : Decimal not fitting with precision inferred
I'm currently trying to construct a parquet file using pyarrow.
For that purpose I'm using that piece of code:

def create_dataframe(list_dict: dict) -> pa.table:
    fields = set()
    for d in list_dict:
        fields = fields.union(d.keys())
    dataframe = pa.table({f: [row.get(f) for row in list_dict] for f in fields})
    return dataframe
```
<p>Everything works well for most of the cases. But I have an issue with one particular case where I have the following error:</p>
```pyarrow.lib.ArrowInvalid: Decimal type with precision 7 does not fit into precision inferred from first array element: 8
```
<p>This problem occurs with a nested value as in the following example bellow the <code>lines</code> where the amount and sold price can be a integer or :</p>
<pre class="lang-json prettyprint-override"><code>[{"accounted_at": "2022-01-31T22:55:25.702000+00:00", "booked_at": "2022-01-27T09:24:17.539000+00:00", "booked_by": "7b3ce009-728d-4fbc-9120-00fa8c1c8655", "created_at": "2022-01-27T09:08:22.306000+00:00", "created_by": "7b3ce009-728d-4fbc-9120-00fa8c1c8655", "deleted_at": null, "description": "description of the record", "due_date": "2022-02-10T00:00:00+00:00", "franchise_id": "9a2858c4-5c71-43d3-b28f-2352de47ff9f", "id": "ba3f6d3a-12f4-4d78-acc5-2e59ca384c1e", "internal_code": "A.2022 / 9", "invoice_recipient_id": "7169cef9-9cb2-461f-a38f-a4d1ce3ca1c3", "lines": [{"type": "property", "amount": 7800, "soldPrice": 260000, "commission": 3, "description": "Honoraires de l'agence", "commissionUnit": "PERCENT"}], "parent_id": null, "payment_term": "14-days", "recipient_emails": null, "sent_at": null, "sent_by": null, "status": "booked", "teamleader_id": "xxx-yyy-www-zzz", "type": "out"}, {"accounted_at": null, "booked_at": "2022-01-05T09:23:03.274000+00:00", "booked_by": "8a91a22d-ddb9-491a-bc2d-c06ff3f256b4", "created_at": "2022-01-05T09:21:32.503000+00:00", "created_by": "8a91a22d-ddb9-491a-bc2d-c06ff3f256b4", "deleted_at": null, "description": "Description content", "due_date": "2022-02-04T00:00:00+00:00", "franchise_id": "929d47a3-c30f-404b-aaff-c96cff1bdd10", "id": "828cd056-6aa7-4cea-9c94-ffa2db4498df", "internal_code": "BXC22 / 3", "invoice_recipient_id": "5f90aa24-4c32-401d-927c-db9d4a9f90bf", "lines": [{"type": "property", "amount": 92.55, "soldPrice": 3702.02, "commission": 2.5, "description": "description2", "commissionUnit": "PERCENT"}], "parent_id": null, "payment_term": "30-days", "recipient_emails": null, "sent_at": "2022-01-05T09:27:34.077000+00:00", "sent_by": "8a91a22d-ddb9-491a-bc2d-c06ff3f256b4", "status": "credited", "teamleader_id": "xxx-yzyzy-zzz-www", "type": "out"}]
</code>```

Do you have any idea how this can be solved?

答:
The easiest way to solve this would be to specify a schema with the desired precision and scale for the Decimal column that can accommodate all the values you are passing through (you could also make these value float if that was desired, but I'd guess not since they seem to be dollar values).

This will prevent any issues with Arrow trying to infer the scale and precision which as you've seen can be error prone.

The error message is somewhat out of data (thank you for filing the JIRA).

Body:
I'm currently trying to construct a parquet file using pyarrow.
For that purpose I'm using that piece of code:

def create_dataframe(list_dict: dict) -> pa.table:
    fields = set()
    for d in list_dict:
        fields = fields.union(d.keys())
    dataframe = pa.table({f: [row.get(f) for row in list_dict] for f in fields})
    return dataframe

Everything works well for most of the cases. But I have an issue with one particular case where I have the following error:

pyarrow.lib.ArrowInvalid: Decimal type with precision 7 does not fit into precision inferred from first array element: 8

This problem occurs with a nested value as in the following example bellow the lines where the amount and sold price can be a integer or :

[{"accounted_at": "2022-01-31T22:55:25.702000+00:00", "booked_at": "2022-01-27T09:24:17.539000+00:00", "booked_by": "7b3ce009-728d-4fbc-9120-00fa8c1c8655", "created_at": "2022-01-27T09:08:22.306000+00:00", "created_by": "7b3ce009-728d-4fbc-9120-00fa8c1c8655", "deleted_at": null, "description": "description of the record", "due_date": "2022-02-10T00:00:00+00:00", "franchise_id": "9a2858c4-5c71-43d3-b28f-2352de47ff9f", "id": "ba3f6d3a-12f4-4d78-acc5-2e59ca384c1e", "internal_code": "A.2022 / 9", "invoice_recipient_id": "7169cef9-9cb2-461f-a38f-a4d1ce3ca1c3", "lines": [{"type": "property", "amount": 7800, "soldPrice": 260000, "commission": 3, "description": "Honoraires de l'agence", "commissionUnit": "PERCENT"}], "parent_id": null, "payment_term": "14-days", "recipient_emails": null, "sent_at": null, "sent_by": null, "status": "booked", "teamleader_id": "xxx-yyy-www-zzz", "type": "out"}, {"accounted_at": null, "booked_at": "2022-01-05T09:23:03.274000+00:00", "booked_by": "8a91a22d-ddb9-491a-bc2d-c06ff3f256b4", "created_at": "2022-01-05T09:21:32.503000+00:00", "created_by": "8a91a22d-ddb9-491a-bc2d-c06ff3f256b4", "deleted_at": null, "description": "Description content", "due_date": "2022-02-04T00:00:00+00:00", "franchise_id": "929d47a3-c30f-404b-aaff-c96cff1bdd10", "id": "828cd056-6aa7-4cea-9c94-ffa2db4498df", "internal_code": "BXC22 / 3", "invoice_recipient_id": "5f90aa24-4c32-401d-927c-db9d4a9f90bf", "lines": [{"type": "property", "amount": 92.55, "soldPrice": 3702.02, "commission": 2.5, "description": "description2", "commissionUnit": "PERCENT"}], "parent_id": null, "payment_term": "30-days", "recipient_emails": null, "sent_at": "2022-01-05T09:27:34.077000+00:00", "sent_by": "8a91a22d-ddb9-491a-bc2d-c06ff3f256b4", "status": "credited", "teamleader_id": "xxx-yzyzy-zzz-www", "type": "out"}]

Do you have any idea how this can be solved?


问:
Failed to transform react-native-reanimated-66-jsc.aar
```<code>> Task :app:checkDebugAarMetadata FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings
108 actionable tasks: 78 executed, 30 up-to-date

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Failed to transform react-native-reanimated-66-hermes.aar (project :react-native-reanimated) to match attributes {artifactType=android-aar-metadata}.
      > Execution failed for JetifyTransform: /Users/jinseokkim/Desktop/프로젝트/my-app/node_modules/react-native-reanimated/android/react-native-reanimated-66-hermes.aar.
         > Check failed.

"react": "17.0.2",
"react-native": "0.66.3",
"react-native-reanimated": "^2.2.0",
</code>```

I'm using the m1 macbook air, but the Android build continues to fail for the same reason as above.

I ask for your advice on what the problem is.

答:
I think one the following will give you the solution

add jcenter() in buildscript.repositories and allprojects.repositories

[Solved] Execution failed for task ‘:app:checkDebugAarMetadata’

Body:
> Task :app:checkDebugAarMetadata FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings
108 actionable tasks: 78 executed, 30 up-to-date

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Failed to transform react-native-reanimated-66-hermes.aar (project :react-native-reanimated) to match attributes {artifactType=android-aar-metadata}.
      > Execution failed for JetifyTransform: /Users/jinseokkim/Desktop/프로젝트/my-app/node_modules/react-native-reanimated/android/react-native-reanimated-66-hermes.aar.
         > Check failed.

"react": "17.0.2",
"react-native": "0.66.3",
"react-native-reanimated": "^2.2.0",

I'm using the m1 macbook air, but the Android build continues to fail for the same reason as above.

I ask for your advice on what the problem is.


问:
when i run DropPlot.xcodeproj, the file has been successfully compiled. however, nothing shows up
when i run DropPlot.xcodeproj, the file has been successfully compiled.
however, nothing shows up.
am i supposed to get a plot where the data is loaded from a csv file?? </p>

答: The DropPlot example includes a sample CSV file in the folder named "SampleCSVFiles". The app doesn't open any windows until you open a file. Run the app and open the CSV file using the File menu. You should then see a simple line plot.</p>

ContentLicense: CC BY-SA 3.0


问:
Rename multiple files in a folder, add a line counts as prefix (Powershell)
I'd like to batch rename files in a folder, prefixing the each filename line counts and "_" into the new names.
example

```<code>a.txt
b.txt
c.txt
d.txt
</code>```

to

```<code>1000_a.txt
32_b.txt
199_c.txt
8_d.txt
</code>```

Bonus: pad the line counts with leading zeroes
to

```<code>1000_a.txt
0032_b.txt
0199_c.txt
0008_d.txt
</code>```

what i tried:
from command that add suffix

```<code>Dir | Rename-Item -NewName { $_.basename + "_" + (Get-Content $_).length + "_" + $_.extension}
</code>```

to

```<code>Dir | Rename-Item -NewName { (Get-Content $_).length + "_" + $_.basename + $_.extension}
</code>```

but it give error

```<code>Rename-Item : The input to the script block for parameter 'NewName' failed. Cannot convert value "a" to type "System.Int32". Error: "Input string was not in a correct format."
</code>```

Thanks

答:
What you are doing is almost fine, the error comes from trying to concatenate an int with a string, PowerShell attempts type conversion of all elements to the type of the leftmost object in the operation:

The operation that PowerShell performs is determined by the Microsoft .NET type of the leftmost object in the operation. PowerShell tries to convert all the objects in the operation to the .NET type of the first object. If it succeeds in converting the objects, it performs the operation appropriate to the .NET type of the first object. If it fails to convert any of the objects, the operation fails.

Since the leftmost object in this case (the .Length property) is of the type int PowerShell attempts to convert the rest to int and it fails, for example:

```<code>PS /> 1 + 'A'
InvalidArgument: Cannot convert value "A" to type "System.Int32". Error: "Input string was not in a correct format."
</code>```

This would be easily fixed by type casting the returned value to sring:

```<code>-NewName { [string](Get-Content $_).Length + "_" + $_.BaseName + $_.Extension }
</code>```

Or for example using string formatting or the -f format operator:

```<code>-NewName { '{0}_{1}{2}' -f (Get-Content $_).Length, $_.BaseName, $_.Extension }
</code>```

As for "the bonus", with string formatting see How do I control the number of integral digits?

In this case you can use {0:0000}, as an example:

```<code>(0..1000).ForEach({'{0:0000}' -f $_})
</code>```

On the other hand, if you have many lengthy files, [System.IO.File]::ReadAllLines(...) is likely to be faster than Get-Content:

```<code>-NewName { '{0:0000}_{1}' -f [System.IO.File]::ReadAllLines($_).Length, $_.Name }
# OR
$io = [System.IO.File]
-NewName { '{0:0000}_{1}' -f $io::ReadAllLines($_).Length, $_.Name }
</code>```

Body:
I'd like to batch rename files in a folder, prefixing the each filename line counts and "_" into the new names.
example

a.txt
b.txt
c.txt
d.txt

to

1000_a.txt
32_b.txt
199_c.txt
8_d.txt

Bonus: pad the line counts with leading zeroes
to

1000_a.txt
0032_b.txt
0199_c.txt
0008_d.txt

what i tried:
from command that add suffix

Dir | Rename-Item -NewName { $_.basename + "_" + (Get-Content $_).length + "_" + $_.extension}

to

Dir | Rename-Item -NewName { (Get-Content $_).length + "_" + $_.basename + $_.extension}

but it give error

Rename-Item : The input to the script block for parameter 'NewName' failed. Cannot convert value "a" to type "System.Int32". Error: "Input string was not in a correct format."

Thanks

Body:
What you are doing is almost fine, the error comes from trying to concatenate an int with a string, PowerShell attempts type conversion of all elements to the type of the leftmost object in the operation:

The operation that PowerShell performs is determined by the Microsoft .NET type of the leftmost object in the operation. PowerShell tries to convert all the objects in the operation to the .NET type of the first object. If it succeeds in converting the objects, it performs the operation appropriate to the .NET type of the first object. If it fails to convert any of the objects, the operation fails.

Since the leftmost object in this case (the .Length property) is of the type int PowerShell attempts to convert the rest to int and it fails, for example:

PS /> 1 + 'A'
InvalidArgument: Cannot convert value "A" to type "System.Int32". Error: "Input string was not in a correct format."

This would be easily fixed by type casting the returned value to sring:

-NewName { [string](Get-Content $_).Length + "_" + $_.BaseName + $_.Extension }

Or for example using string formatting or the -f format operator:

-NewName { '{0}_{1}{2}' -f (Get-Content $_).Length, $_.BaseName, $_.Extension }

As for "the bonus", with string formatting see How do I control the number of integral digits?

In this case you can use {0:0000}, as an example:

(0..1000).ForEach({'{0:0000}' -f $_})

On the other hand, if you have many lengthy files, [System.IO.File]::ReadAllLines(...) is likely to be faster than Get-Content:

-NewName { '{0:0000}_{1}' -f [System.IO.File]::ReadAllLines($_).Length, $_.Name }
# OR
$io = [System.IO.File]
-NewName { '{0:0000}_{1}' -f $io::ReadAllLines($_).Length, $_.Name }


问:
How to copy the inferred type of an untyped function (TypeScript) in Visual Studio Code when its very long
(See Screenshot)

I have this function with a really long untyped object returned, I want to copy the inferred type of that object because it's way too long to do manually, and then I want to make class/interface of it, example:

```<code>export class PatientTables {
  emsf: string;
  cadNumber: string;
  // and so on
}
</code>```

is there a way to copy it from somewhere as it seems Visual Studio Code already has it assorted somewhere, as you can see in the picture (48 more), how can I make it show the rest and copy it?
thanks!

答: RMC (Right mouse Click) refactor to named function first, then RMC on new function Refactor shows infer return type option.</p>

Body:
(See Screenshot)

I have this function with a really long untyped object returned, I want to copy the inferred type of that object because it's way too long to do manually, and then I want to make class/interface of it, example:

export class PatientTables {
  emsf: string;
  cadNumber: string;
  // and so on
}

is there a way to copy it from somewhere as it seems Visual Studio Code already has it assorted somewhere, as you can see in the picture (48 more), how can I make it show the rest and copy it?
thanks!


问:
Is it bad practice to reuse GL_TEXTURE0 over again when binding different textures?
In many examples, some are reusing GL_TEXTURE0 over and over for different textures, and in other examples they increment the texture slot like so:

```<code>glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, woodTexture);
...
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, metalTexture);
...
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, plasticTexture);
</code>```

as opposed to

```<code>glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, woodTexture);
...
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, metalTexture);
...
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, plasticTexture);
</code>```

Is one or the other bad practice, or even worse for efficiency, or does it not matter at all?

答:
Multiple texture units are for one geometry who has multiple textures. For instance, some lighting shader requires two lighting maps for diffuse and specular. Then you need to provide two textures for two samplers. In this case, you have to active two textures. See the following structure:

```<code>struct Material {
    sampler2D diffuse;
    sampler2D specular;
    float shininess;
};
</code>```

If geometries only have 1 texture, it is ok to just use the GL_TEXTURE0. You don't need to active it multiple times, it will be automatically actived as the default texture

Body:
In many examples, some are reusing GL_TEXTURE0 over and over for different textures, and in other examples they increment the texture slot like so:

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, woodTexture);
...
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, metalTexture);
...
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, plasticTexture);

as opposed to

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, woodTexture);
...
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, metalTexture);
...
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, plasticTexture);

Is one or the other bad practice, or even worse for efficiency, or does it not matter at all?

Body:
Multiple texture units are for one geometry who has multiple textures. For instance, some lighting shader requires two lighting maps for diffuse and specular. Then you need to provide two textures for two samplers. In this case, you have to active two textures. See the following structure:

struct Material {
    sampler2D diffuse;
    sampler2D specular;
    float shininess;
};

If geometries only have 1 texture, it is ok to just use the GL_TEXTURE0. You don't need to active it multiple times, it will be automatically actived as the default texture


问:
Why does calling this Python method not return anything?
```<code>class Solution:
    def minDepth(self, root: Optional[TreeNode]) -> int:
        if not root:
            return 0

        def DFS(root, depth):
            if (not root.left) and (not root.right):
                return depth
            if root.left:
                DFS(root.left, depth + 1)
            if root.right:
                DFS(root.right, depth + 1)

        DFS(root, 1)
</code>```

Does anyone know why this returns None? How can I create a DFS helper function and return the value depth?

答: At the bottom your recursive function returns depth, but all the other functions do not take the first path and return nothing,  You need return statements on all your paths</p>

Body:
class Solution:
    def minDepth(self, root: Optional[TreeNode]) -> int:
        if not root:
            return 0

        def DFS(root, depth):
            if (not root.left) and (not root.right):
                return depth
            if root.left:
                DFS(root.left, depth + 1)
            if root.right:
                DFS(root.right, depth + 1)

        DFS(root, 1)

Does anyone know why this returns None? How can I create a DFS helper function and return the value depth?


问:
How to use CSS grid to have optional third row span two columns inside an Angular *ngFor
What I am trying to do is best described with an example. I have an Angular application, which has list if items (number of items known until runtime), and has two main display columns, and an optional error element.

I would like to lay these columns out so that the first column just takes up what room it needs, and the second can take up the rest (i.e. label / value).

However, I would also kike to optionally display an error under both columns, if there is an error. Here is a full example which is also here.

TypeScript

```<code>    constructor() {
            for (let i = 0; i < 12; i++) {
                const item: Item = {
                    label: `Item num${i}`,
                    value: i * 1000,
                    error: undefined
                    //error: i === 0 ? 'Item has a long long long error message' : undefined,
                };
                this.items.push(item);
            }
        }

</code>```

HTML

```<code>    <div id="items-container">
        <ng-container *ngFor="let item of items">
            <div class="label-container">
                 <div class="label">{{item.label}}</div>
                 <div class="error">{{item.error}}</div>
            </div>
            <div>{{item.value}}</div>
        </ng-container>
    </div>

</code>```

CSS

```<code>    .error {
        color: red;
        overflow-y: visible;
        white-space: nowrap;
    }

    #items-container {
        display: grid;
        grid-template-columns: min-content auto;
        background: lightblue;
    }

    .label {
        white-space: nowrap;
        display: flex;
        justify-items: flex-start;
        align-items: center;
        margin-right: 20px;
    }
</code>```

Now, if I add the error, the first column will expand way over.

My question is, is there a way to have the error span the two columns, and not push out the first, eg something like

How can I achieve this?

答:
You can add a class with a grid-column: 1/3
to the error label.
This make the error label fill the entire width (two columns)

Body:
What I am trying to do is best described with an example. I have an Angular application, which has list if items (number of items known until runtime), and has two main display columns, and an optional error element.

I would like to lay these columns out so that the first column just takes up what room it needs, and the second can take up the rest (i.e. label / value).

However, I would also kike to optionally display an error under both columns, if there is an error. Here is a full example which is also here.

TypeScript

    constructor() {
            for (let i = 0; i < 12; i++) {
                const item: Item = {
                    label: `Item num${i}`,
                    value: i * 1000,
                    error: undefined
                    //error: i === 0 ? 'Item has a long long long error message' : undefined,
                };
                this.items.push(item);
            }
        }

HTML

        <ng-container *ngFor="let item of items">

{{item.label}}

{{item.error}}

{{item.value}}

        </ng-container>

CSS

    .error {
        color: red;
        overflow-y: visible;
        white-space: nowrap;
    }

    #items-container {
        display: grid;
        grid-template-columns: min-content auto;
        background: lightblue;
    }

    .label {
        white-space: nowrap;
        display: flex;
        justify-items: flex-start;
        align-items: center;
        margin-right: 20px;
    }

Now, if I add the error, the first column will expand way over.

My question is, is there a way to have the error span the two columns, and not push out the first, eg something like

How can I achieve this?


问:
JBoss5: Cannot deploy due to java.util.zip.ZipException: error in opening zip file
I have a web client and a EJB project, which I created with Eclipse 3.4.
When I want to deploy it on Jboss 5.0.1, I receive the error below. I searched a lot but I wasn't able to find a solution to this.

```<code>18:21:21,899 INFO  [ServerImpl] Starting JBoss (Microcontainer)...
18:21:21,900 INFO  [ServerImpl] Release ID: JBoss [Morpheus] 5.0.1.GA (build: SVNTag=JBoss_5_0_1_GA date=200902231221)
18:21:21,900 INFO  [ServerImpl] Bootstrap URL: null
18:21:21,900 INFO  [ServerImpl] Home Dir: /Applications/jboss-5.0.1.GA
18:21:21,900 INFO  [ServerImpl] Home URL: file:/Applications/jboss-5.0.1.GA/
18:21:21,901 INFO  [ServerImpl] Library URL: file:/Applications/jboss-5.0.1.GA/lib/
18:21:21,901 INFO  [ServerImpl] Patch URL: null
18:21:21,901 INFO  [ServerImpl] Common Base URL: file:/Applications/jboss-5.0.1.GA/common/
18:21:21,902 INFO  [ServerImpl] Common Library URL: file:/Applications/jboss-5.0.1.GA/common/lib/
18:21:21,902 INFO  [ServerImpl] Server Name: default
18:21:21,902 INFO  [ServerImpl] Server Base Dir: /Applications/jboss-5.0.1.GA/server
18:21:21,902 INFO  [ServerImpl] Server Base URL: file:/Applications/jboss-5.0.1.GA/server/
18:21:21,902 INFO  [ServerImpl] Server Config URL: file:/Applications/jboss-5.0.1.GA/server/default/conf/
18:21:21,902 INFO  [ServerImpl] Server Home Dir: /Applications/jboss-5.0.1.GA/server/default
18:21:21,902 INFO  [ServerImpl] Server Home URL: file:/Applications/jboss-5.0.1.GA/server/default/
18:21:21,903 INFO  [ServerImpl] Server Data Dir: /Applications/jboss-5.0.1.GA/server/default/data
18:21:21,903 INFO  [ServerImpl] Server Library URL: file:/Applications/jboss-5.0.1.GA/server/default/lib/
18:21:21,903 INFO  [ServerImpl] Server Log Dir: /Applications/jboss-5.0.1.GA/server/default/log
18:21:21,903 INFO  [ServerImpl] Server Native Dir: /Applications/jboss-5.0.1.GA/server/default/tmp/native
18:21:21,903 INFO  [ServerImpl] Server Temp Dir: /Applications/jboss-5.0.1.GA/server/default/tmp
18:21:21,903 INFO  [ServerImpl] Server Temp Deploy Dir: /Applications/jboss-5.0.1.GA/server/default/tmp/deploy
18:21:22,669 INFO  [ServerImpl] Starting Microcontainer, bootstrapURL=file:/Applications/jboss-5.0.1.GA/server/default/conf/bootstrap.xml
18:21:23,535 INFO  [VFSCacheFactory] Initializing VFSCache [org.jboss.virtual.plugins.cache.CombinedVFSCache]
18:21:23,541 INFO  [VFSCacheFactory] Using VFSCache [CombinedVFSCache[real-cache: null]]
18:21:23,942 INFO  [CopyMechanism] VFS temp dir: /Applications/jboss-5.0.1.GA/server/default/tmp
18:21:23,943 INFO  [ZipEntryContext] VFS force nested jars copy-mode is enabled.
18:21:26,263 INFO  [ServerInfo] Java version: 1.5.0_16,Apple Inc.
18:21:26,264 INFO  [ServerInfo] Java Runtime: Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-284)
18:21:26,264 INFO  [ServerInfo] Java VM: Java HotSpot(TM) Server VM 1.5.0_16-133,Apple Inc.
18:21:26,264 INFO  [ServerInfo] OS-System: Mac OS X 10.5.6,i386
18:21:26,336 INFO  [JMXKernel] Legacy JMX core initialized
18:21:30,432 INFO  [ProfileServiceImpl] Loading profile: default from: org.jboss.system.server.profileservice.repository.SerializableDeploymentRepository@e1d5d9(root=/Applications/jboss-5.0.1.GA/server, key=org.jboss.profileservice.spi.ProfileKey@143b82c3[domain=default,server=default,name=default])
18:21:30,436 INFO  [ProfileImpl] Using repository:org.jboss.system.server.profileservice.repository.SerializableDeploymentRepository@e1d5d9(root=/Applications/jboss-5.0.1.GA/server, key=org.jboss.profileservice.spi.ProfileKey@143b82c3[domain=default,server=default,name=default])
18:21:30,436 INFO  [ProfileServiceImpl] Loaded profile: ProfileImpl@ae002e{key=org.jboss.profileservice.spi.ProfileKey@143b82c3[domain=default,server=default,name=default]}
18:21:32,935 INFO  [WebService] Using RMI server codebase: http://localhost:8083/
18:21:42,572 INFO  [NativeServerConfig] JBoss Web Services - Stack Native Core
18:21:42,573 INFO  [NativeServerConfig] 3.0.5.GA
18:21:52,836 ERROR [AbstractKernelController] Error installing to ClassLoader: name=vfsfile:/Applications/jboss-5.0.1.GA/server/default/deploy/TwitterEAR.ear/ state=Describe mode=Manual requiredState=ClassLoader
org.jboss.deployers.spi.DeploymentException: Error creating classloader for vfsfile:/Applications/jboss-5.0.1.GA/server/default/deploy/TwitterEAR.ear/
    at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49)
    at org.jboss.deployers.structure.spi.helpers.AbstractDeploymentContext.createClassLoader(AbstractDeploymentContext.java:576)
    at org.jboss.deployers.structure.spi.helpers.AbstractDeploymentUnit.createClassLoader(AbstractDeploymentUnit.java:159)
    at org.jboss.deployers.spi.deployer.helpers.AbstractClassLoaderDeployer.deploy(AbstractClassLoaderDeployer.java:53)
    at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
    at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
    at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
    at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
    at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
    at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598)
    at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062)
    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
    at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
    at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:698)
    at org.jboss.system.server.profileservice.ProfileServiceBootstrap.loadProfile(ProfileServiceBootstrap.java:304)
    at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:205)
    at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:405)
    at org.jboss.Main.boot(Main.java:209)
    at org.jboss.Main$1.run(Main.java:547)
    at java.lang.Thread.run(Thread.java:613)
Caused by: java.lang.Error: Error visiting FileHandler@5567366[path=TwitterEAR.ear/TwitterPoCEJB.jar context=file:/Applications/jboss-5.0.1.GA/server/default/deploy/ real=file:/Applications/jboss-5.0.1.GA/server/default/deploy/TwitterEAR.ear/TwitterPoCEJB.jar/]
    at org.jboss.classloading.plugins.vfs.PackageVisitor.determineAllPackages(PackageVisitor.java:98)
    at org.jboss.deployers.vfs.plugins.classloader.VFSDeploymentClassLoaderPolicyModule.determineCapabilities(VFSDeploymentClassLoaderPolicyModule.java:108)
    at org.jboss.classloading.spi.dependency.Module.getCapabilities(Module.java:654)
    at org.jboss.classloading.spi.dependency.Module.determinePackageNames(Module.java:713)
    at org.jboss.classloading.spi.dependency.Module.getPackageNames(Module.java:698)
    at org.jboss.deployers.vfs.plugins.classloader.VFSDeploymentClassLoaderPolicyModule.determinePolicy(VFSDeploymentClassLoaderPolicyModule.java:129)
    at org.jboss.deployers.vfs.plugins.classloader.VFSDeploymentClassLoaderPolicyModule.determinePolicy(VFSDeploymentClassLoaderPolicyModule.java:48)
    at org.jboss.classloading.spi.dependency.policy.ClassLoaderPolicyModule.getPolicy(ClassLoaderPolicyModule.java:195)
    at org.jboss.deployers.vfs.plugins.classloader.VFSDeploymentClassLoaderPolicyModule.getPolicy(VFSDeploymentClassLoaderPolicyModule.java:122)
    at org.jboss.deployers.vfs.plugins.classloader.VFSDeploymentClassLoaderPolicyModule.getPolicy(VFSDeploymentClassLoaderPolicyModule.java:48)
    at org.jboss.classloading.spi.dependency.policy.ClassLoaderPolicyModule.registerClassLoaderPolicy(ClassLoaderPolicyModule.java:131)
    at org.jboss.deployers.plugins.classloading.AbstractLevelClassLoaderSystemDeployer.createClassLoader(AbstractLevelClassLoaderSystemDeployer.java:120)
    at org.jboss.deployers.structure.spi.helpers.AbstractDeploymentContext.createClassLoader(AbstractDeploymentContext.java:562)
    ... 21 more
Caused by: java.lang.RuntimeException: java.util.zip.ZipException: error in opening zip file
    at org.jboss.virtual.plugins.context.AbstractExceptionHandler.handleZipEntriesInitException(AbstractExceptionHandler.java:39)
    at org.jboss.virtual.plugins.context.helpers.NamesExceptionHandler.handleZipEntriesInitException(NamesExceptionHandler.java:63)
    at org.jboss.virtual.plugins.context.zip.ZipEntryContext.ensureEntries(ZipEntryContext.java:610)
    at org.jboss.virtual.plugins.context.zip.ZipEntryContext.checkIfModified(ZipEntryContext.java:757)
    at org.jboss.virtual.plugins.context.zip.ZipEntryContext.getChildren(ZipEntryContext.java:829)
    at org.jboss.virtual.plugins.context.zip.ZipEntryHandler.getChildren(ZipEntryHandler.java:159)
    at org.jboss.virtual.plugins.context.DelegatingHandler.getChildren(DelegatingHandler.java:121)
    at org.jboss.virtual.plugins.context.AbstractVFSContext.getChildren(AbstractVFSContext.java:211)
    at org.jboss.virtual.plugins.context.AbstractVFSContext.visit(AbstractVFSContext.java:328)
    at org.jboss.virtual.plugins.context.AbstractVFSContext.visit(AbstractVFSContext.java:298)
    at org.jboss.virtual.VFS.visit(VFS.java:433)
    at org.jboss.virtual.VirtualFile.visit(VirtualFile.java:437)
    at org.jboss.virtual.VirtualFile.getChildren(VirtualFile.java:386)
    at org.jboss.virtual.VirtualFile.getChildren(VirtualFile.java:367)
    at org.jboss.classloading.plugins.vfs.PackageVisitor.visit(PackageVisitor.java:200)
    at org.jboss.virtual.plugins.vfs.helpers.WrappingVirtualFileHandlerVisitor.visit(WrappingVirtualFileHandlerVisitor.java:62)
    at org.jboss.virtual.plugins.context.AbstractVFSContext.visit(AbstractVFSContext.java:353)
    at org.jboss.virtual.plugins.context.AbstractVFSContext.visit(AbstractVFSContext.java:298)
    at org.jboss.virtual.VFS.visit(VFS.java:433)
    at org.jboss.virtual.VirtualFile.visit(VirtualFile.java:437)
    at org.jboss.classloading.plugins.vfs.PackageVisitor.determineAllPackages(PackageVisitor.java:94)
    ... 33 more
Caused by: java.util.zip.ZipException: error in opening zip file
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(ZipFile.java:203)
    at java.util.zip.ZipFile.<init>(ZipFile.java:234)
    at org.jboss.virtual.plugins.context.zip.ZipFileWrapper.ensureZipFile(ZipFileWrapper.java:175)
    at org.jboss.virtual.plugins.context.zip.ZipFileWrapper.acquire(ZipFileWrapper.java:245)
    at org.jboss.virtual.plugins.context.zip.ZipEntryContext.initEntries(ZipEntryContext.java:470)
    at org.jboss.virtual.plugins.context.zip.ZipEntryContext.ensureEntries(ZipEntryContext.java:603)
    ... 51 more
18:21:56,772 INFO  [JMXConnectorServerService] JMX Connector server: service:jmx:rmi://localhost/jndi/rmi://localhost:1090/jmxconnector
18:21:56,959 INFO  [MailService] Mail Service bound to java:/Mail
18:21:59,450 WARN  [JBossASSecurityMetadataStore] WARNING! POTENTIAL SECURITY RISK. It has been detected that the MessageSucker component which sucks messages from one node to another has not had its password changed from the installation default. Please see the JBoss Messaging user guide for instructions on how to do this.
18:21:59,489 WARN  [AnnotationCreator] No ClassLoader provided, using TCCL: org.jboss.managed.api.annotation.ManagementComponent
18:21:59,789 INFO  [TransactionManagerService] JBossTS Transaction Service (JTA version) - JBoss Inc.
18:21:59,789 INFO  [TransactionManagerService] Setting up property manager MBean and JMX layer
18:22:00,040 INFO  [TransactionManagerService] Initializing recovery manager
18:22:00,160 INFO  [TransactionManagerService] Recovery manager configured
18:22:00,160 INFO  [TransactionManagerService] Binding TransactionManager JNDI Reference
18:22:00,184 INFO  [TransactionManagerService] Starting transaction recovery manager
18:22:01,243 INFO  [Http11Protocol] Initializing Coyote HTTP/1.1 on http-localhost%2F127.0.0.1-8080
18:22:01,244 INFO  [AjpProtocol] Initializing Coyote AJP/1.3 on ajp-localhost%2F127.0.0.1-8009
18:22:01,244 INFO  [StandardService] Starting service jboss.web
18:22:01,247 INFO  [StandardEngine] Starting Servlet Engine: JBoss Web/2.1.2.GA
18:22:01,336 INFO  [Catalina] Server startup in 161 ms
18:22:01,360 INFO  [TomcatDeployment] deploy, ctxPath=/invoker
18:22:02,014 INFO  [TomcatDeployment] deploy, ctxPath=/web-console
18:22:02,459 INFO  [TomcatDeployment] deploy, ctxPath=/jbossws
18:22:02,570 INFO  [RARDeployment] Required license terms exist, view vfszip:/Applications/jboss-5.0.1.GA/server/default/deploy/jboss-local-jdbc.rar/META-INF/ra.xml
18:22:02,586 INFO  [RARDeployment] Required license terms exist, view vfszip:/Applications/jboss-5.0.1.GA/server/default/deploy/jboss-xa-jdbc.rar/META-INF/ra.xml
18:22:02,645 INFO  [RARDeployment] Required license terms exist, view vfszip:/Applications/jboss-5.0.1.GA/server/default/deploy/jms-ra.rar/META-INF/ra.xml
18:22:02,663 INFO  [RARDeployment] Required license terms exist, view vfszip:/Applications/jboss-5.0.1.GA/server/default/deploy/mail-ra.rar/META-INF/ra.xml
18:22:02,705 INFO  [RARDeployment] Required license terms exist, view vfszip:/Applications/jboss-5.0.1.GA/server/default/deploy/quartz-ra.rar/META-INF/ra.xml
18:22:02,801 INFO  [SimpleThreadPool] Job execution threads will use class loader of thread: main
18:22:02,850 INFO  [QuartzScheduler] Quartz Scheduler v.1.5.2 created.
18:22:02,857 INFO  [RAMJobStore] RAMJobStore initialized.
18:22:02,858 INFO  [StdSchedulerFactory] Quartz scheduler 'DefaultQuartzScheduler' initialized from default resource file in Quartz package: 'quartz.properties'
18:22:02,858 INFO  [StdSchedulerFactory] Quartz scheduler version: 1.5.2
18:22:02,859 INFO  [QuartzScheduler] Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED started.
18:22:03,888 INFO  [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=DefaultDS' to JNDI name 'java:DefaultDS'
18:22:04,530 INFO  [ServerPeer] JBoss Messaging 1.4.1.GA server [0] started
18:22:04,624 INFO  [QueueService] Queue[/queue/DLQ] started, fullSize=200000, pageSize=2000, downCacheSize=2000
18:22:04,632 WARN  [ConnectionFactoryJNDIMapper] supportsFailover attribute is true on connection factory: jboss.messaging.connectionfactory:service=ClusteredConnectionFactory but post office is non clustered. So connection factory will *not* support failover
18:22:04,632 WARN  [ConnectionFactoryJNDIMapper] supportsLoadBalancing attribute is true on connection factory: jboss.messaging.connectionfactory:service=ClusteredConnectionFactory but post office is non clustered. So connection factory will *not* support load balancing
18:22:04,742 INFO  [ConnectionFactory] Connector bisocket://localhost:4457 has leasing enabled, lease period 10000 milliseconds
18:22:04,742 INFO  [ConnectionFactory] org.jboss.jms.server.connectionfactory.ConnectionFactory@6af9ad started
18:22:04,746 INFO  [QueueService] Queue[/queue/ExpiryQueue] started, fullSize=200000, pageSize=2000, downCacheSize=2000
18:22:04,747 INFO  [ConnectionFactory] Connector bisocket://localhost:4457 has leasing enabled, lease period 10000 milliseconds
18:22:04,747 INFO  [ConnectionFactory] org.jboss.jms.server.connectionfactory.ConnectionFactory@5ac953 started
18:22:04,750 INFO  [ConnectionFactory] Connector bisocket://localhost:4457 has leasing enabled, lease period 10000 milliseconds
18:22:04,750 INFO  [ConnectionFactory] org.jboss.jms.server.connectionfactory.ConnectionFactory@e8fa3a started
18:22:05,050 INFO  [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=JmsXA' to JNDI name 'java:JmsXA'
18:22:05,073 INFO  [TomcatDeployment] deploy, ctxPath=/
18:22:05,178 INFO  [TomcatDeployment] deploy, ctxPath=/jmx-console
18:22:05,290 ERROR [ProfileServiceBootstrap] Failed to load profile: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):

DEPLOYMENTS IN ERROR:
  Deployment "vfsfile:/Applications/jboss-5.0.1.GA/server/default/deploy/TwitterEAR.ear/" is in error due to the following reason(s): java.util.zip.ZipException: error in opening zip file

18:22:05,301 INFO  [Http11Protocol] Starting Coyote HTTP/1.1 on http-localhost%2F127.0.0.1-8080
18:22:05,364 INFO  [AjpProtocol] Starting Coyote AJP/1.3 on ajp-localhost%2F127.0.0.1-8009
18:22:05,373 INFO  [ServerImpl] JBoss (Microcontainer) [5.0.1.GA (build: SVNTag=JBoss_5_0_1_GA date=200902231221)] Started in 43s:467ms
</code>```

The mentioned ear and war file are both in the deploy directory.

Does anybody have hints?

答:
Ok, I finally found the solution to my problem. It seems that there's a bug in Eclipse which prevent the creation of the .settings/org.eclipse.wst.common.component file. This file should be created when setting the EJB3 and Java6 facets in project properties.

Here is an org.eclipse.wst.common.component example file :

```<code><?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
    <wb-module deploy-name="project_name">
        <wb-resource deploy-path="/" source-path="/src/main/java"/>
        <wb-resource deploy-path="/" source-path="/src/main/resources"/>
        <wb-resource deploy-path="/" source-path="/src/test/java"/>
        <wb-resource deploy-path="/" source-path="/src/test/resources"/>
        <property name="java-output-path"/>
    </wb-module>
</project-modules>
</code>```

The deploy paths must be defined in order to be able to create the EJB Jar file used by the server on deployment.
Once created, Jboss publish the EJB module correctly.

OwnerDisplayName: Andreas

ContentLicense: CC BY-SA 2.5

Body:
I have a web client and a EJB project, which I created with Eclipse 3.4.
When I want to deploy it on Jboss 5.0.1, I receive the error below. I searched a lot but I wasn't able to find a solution to this.

18:21:21,899 INFO  [ServerImpl] Starting JBoss (Microcontainer)...
18:21:21,900 INFO  [ServerImpl] Release ID: JBoss [Morpheus] 5.0.1.GA (build: SVNTag=JBoss_5_0_1_GA date=200902231221)
18:21:21,900 INFO  [ServerImpl] Bootstrap URL: null
18:21:21,900 INFO  [ServerImpl] Home Dir: /Applications/jboss-5.0.1.GA
18:21:21,900 INFO  [ServerImpl] Home URL: file:/Applications/jboss-5.0.1.GA/
18:21:21,901 INFO  [ServerImpl] Library URL: file:/Applications/jboss-5.0.1.GA/lib/
18:21:21,901 INFO  [ServerImpl] Patch URL: null
18:21:21,901 INFO  [ServerImpl] Common Base URL: file:/Applications/jboss-5.0.1.GA/common/
18:21:21,902 INFO  [ServerImpl] Common Library URL: file:/Applications/jboss-5.0.1.GA/common/lib/
18:21:21,902 INFO  [ServerImpl] Server Name: default
18:21:21,902 INFO  [ServerImpl] Server Base Dir: /Applications/jboss-5.0.1.GA/server
18:21:21,902 INFO  [ServerImpl] Server Base URL: file:/Applications/jboss-5.0.1.GA/server/
18:21:21,902 INFO  [ServerImpl] Server Config URL: file:/Applications/jboss-5.0.1.GA/server/default/conf/
18:21:21,902 INFO  [ServerImpl] Server Home Dir: /Applications/jboss-5.0.1.GA/server/default
18:21:21,902 INFO  [ServerImpl] Server Home URL: file:/Applications/jboss-5.0.1.GA/server/default/
18:21:21,903 INFO  [ServerImpl] Server Data Dir: /Applications/jboss-5.0.1.GA/server/default/data
18:21:21,903 INFO  [ServerImpl] Server Library URL: file:/Applications/jboss-5.0.1.GA/server/default/lib/
18:21:21,903 INFO  [ServerImpl] Server Log Dir: /Applications/jboss-5.0.1.GA/server/default/log
18:21:21,903 INFO  [ServerImpl] Server Native Dir: /Applications/jboss-5.0.1.GA/server/default/tmp/native
18:21:21,903 INFO  [ServerImpl] Server Temp Dir: /Applications/jboss-5.0.1.GA/server/default/tmp
18:21:21,903 INFO  [ServerImpl] Server Temp Deploy Dir: /Applications/jboss-5.0.1.GA/server/default/tmp/deploy
18:21:22,669 INFO  [ServerImpl] Starting Microcontainer, bootstrapURL=file:/Applications/jboss-5.0.1.GA/server/default/conf/bootstrap.xml
18:21:23,535 INFO  [VFSCacheFactory] Initializing VFSCache [org.jboss.virtual.plugins.cache.CombinedVFSCache]
18:21:23,541 INFO  [VFSCacheFactory] Using VFSCache [CombinedVFSCache[real-cache: null]]
18:21:23,942 INFO  [CopyMechanism] VFS temp dir: /Applications/jboss-5.0.1.GA/server/default/tmp
18:21:23,943 INFO  [ZipEntryContext] VFS force nested jars copy-mode is enabled.
18:21:26,263 INFO  [ServerInfo] Java version: 1.5.0_16,Apple Inc.
18:21:26,264 INFO  [ServerInfo] Java Runtime: Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-284)
18:21:26,264 INFO  [ServerInfo] Java VM: Java HotSpot(TM) Server VM 1.5.0_16-133,Apple Inc.
18:21:26,264 INFO  [ServerInfo] OS-System: Mac OS X 10.5.6,i386
18:21:26,336 INFO  [JMXKernel] Legacy JMX core initialized
18:21:30,432 INFO  [ProfileServiceImpl] Loading profile: default from: org.jboss.system.server.profileservice.repository.SerializableDeploymentRepository@e1d5d9(root=/Applications/jboss-5.0.1.GA/server, key=org.jboss.profileservice.spi.ProfileKey@143b82c3[domain=default,server=default,name=default])
18:21:30,436 INFO  [ProfileImpl] Using repository:org.jboss.system.server.profileservice.repository.SerializableDeploymentRepository@e1d5d9(root=/Applications/jboss-5.0.1.GA/server, key=org.jboss.profileservice.spi.ProfileKey@143b82c3[domain=default,server=default,name=default])
18:21:30,436 INFO  [ProfileServiceImpl] Loaded profile: ProfileImpl@ae002e{key=org.jboss.profileservice.spi.ProfileKey@143b82c3[domain=default,server=default,name=default]}
18:21:32,935 INFO  [WebService] Using RMI server codebase: http://localhost:8083/
18:21:42,572 INFO  [NativeServerConfig] JBoss Web Services - Stack Native Core
18:21:42,573 INFO  [NativeServerConfig] 3.0.5.GA
18:21:52,836 ERROR [AbstractKernelController] Error installing to ClassLoader: name=vfsfile:/Applications/jboss-5.0.1.GA/server/default/deploy/TwitterEAR.ear/ state=Describe mode=Manual requiredState=ClassLoader
org.jboss.deployers.spi.DeploymentException: Error creating classloader for vfsfile:/Applications/jboss-5.0.1.GA/server/default/deploy/TwitterEAR.ear/
    at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49)
    at org.jboss.deployers.structure.spi.helpers.AbstractDeploymentContext.createClassLoader(AbstractDeploymentContext.java:576)
    at org.jboss.deployers.structure.spi.helpers.AbstractDeploymentUnit.createClassLoader(AbstractDeploymentUnit.java:159)
    at org.jboss.deployers.spi.deployer.helpers.AbstractClassLoaderDeployer.deploy(AbstractClassLoaderDeployer.java:53)
    at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
    at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
    at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
    at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
    at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
    at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598)
    at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062)
    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
    at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
    at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:698)
    at org.jboss.system.server.profileservice.ProfileServiceBootstrap.loadProfile(ProfileServiceBootstrap.java:304)
    at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:205)
    at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:405)
    at org.jboss.Main.boot(Main.java:209)
    at org.jboss.Main$1.run(Main.java:547)
    at java.lang.Thread.run(Thread.java:613)
Caused by: java.lang.Error: Error visiting FileHandler@5567366[path=TwitterEAR.ear/TwitterPoCEJB.jar context=file:/Applications/jboss-5.0.1.GA/server/default/deploy/ real=file:/Applications/jboss-5.0.1.GA/server/default/deploy/TwitterEAR.ear/TwitterPoCEJB.jar/]
    at org.jboss.classloading.plugins.vfs.PackageVisitor.determineAllPackages(PackageVisitor.java:98)
    at org.jboss.deployers.vfs.plugins.classloader.VFSDeploymentClassLoaderPolicyModule.determineCapabilities(VFSDeploymentClassLoaderPolicyModule.java:108)
    at org.jboss.classloading.spi.dependency.Module.getCapabilities(Module.java:654)
    at org.jboss.classloading.spi.dependency.Module.determinePackageNames(Module.java:713)
    at org.jboss.classloading.spi.dependency.Module.getPackageNames(Module.java:698)
    at org.jboss.deployers.vfs.plugins.classloader.VFSDeploymentClassLoaderPolicyModule.determinePolicy(VFSDeploymentClassLoaderPolicyModule.java:129)
    at org.jboss.deployers.vfs.plugins.classloader.VFSDeploymentClassLoaderPolicyModule.determinePolicy(VFSDeploymentClassLoaderPolicyModule.java:48)
    at org.jboss.classloading.spi.dependency.policy.ClassLoaderPolicyModule.getPolicy(ClassLoaderPolicyModule.java:195)
    at org.jboss.deployers.vfs.plugins.classloader.VFSDeploymentClassLoaderPolicyModule.getPolicy(VFSDeploymentClassLoaderPolicyModule.java:122)
    at org.jboss.deployers.vfs.plugins.classloader.VFSDeploymentClassLoaderPolicyModule.getPolicy(VFSDeploymentClassLoaderPolicyModule.java:48)
    at org.jboss.classloading.spi.dependency.policy.ClassLoaderPolicyModule.registerClassLoaderPolicy(ClassLoaderPolicyModule.java:131)
    at org.jboss.deployers.plugins.classloading.AbstractLevelClassLoaderSystemDeployer.createClassLoader(AbstractLevelClassLoaderSystemDeployer.java:120)
    at org.jboss.deployers.structure.spi.helpers.AbstractDeploymentContext.createClassLoader(AbstractDeploymentContext.java:562)
    ... 21 more
Caused by: java.lang.RuntimeException: java.util.zip.ZipException: error in opening zip file
    at org.jboss.virtual.plugins.context.AbstractExceptionHandler.handleZipEntriesInitException(AbstractExceptionHandler.java:39)
    at org.jboss.virtual.plugins.context.helpers.NamesExceptionHandler.handleZipEntriesInitException(NamesExceptionHandler.java:63)
    at org.jboss.virtual.plugins.context.zip.ZipEntryContext.ensureEntries(ZipEntryContext.java:610)
    at org.jboss.virtual.plugins.context.zip.ZipEntryContext.checkIfModified(ZipEntryContext.java:757)
    at org.jboss.virtual.plugins.context.zip.ZipEntryContext.getChildren(ZipEntryContext.java:829)
    at org.jboss.virtual.plugins.context.zip.ZipEntryHandler.getChildren(ZipEntryHandler.java:159)
    at org.jboss.virtual.plugins.context.DelegatingHandler.getChildren(DelegatingHandler.java:121)
    at org.jboss.virtual.plugins.context.AbstractVFSContext.getChildren(AbstractVFSContext.java:211)
    at org.jboss.virtual.plugins.context.AbstractVFSContext.visit(AbstractVFSContext.java:328)
    at org.jboss.virtual.plugins.context.AbstractVFSContext.visit(AbstractVFSContext.java:298)
    at org.jboss.virtual.VFS.visit(VFS.java:433)
    at org.jboss.virtual.VirtualFile.visit(VirtualFile.java:437)
    at org.jboss.virtual.VirtualFile.getChildren(VirtualFile.java:386)
    at org.jboss.virtual.VirtualFile.getChildren(VirtualFile.java:367)
    at org.jboss.classloading.plugins.vfs.PackageVisitor.visit(PackageVisitor.java:200)
    at org.jboss.virtual.plugins.vfs.helpers.WrappingVirtualFileHandlerVisitor.visit(WrappingVirtualFileHandlerVisitor.java:62)
    at org.jboss.virtual.plugins.context.AbstractVFSContext.visit(AbstractVFSContext.java:353)
    at org.jboss.virtual.plugins.context.AbstractVFSContext.visit(AbstractVFSContext.java:298)
    at org.jboss.virtual.VFS.visit(VFS.java:433)
    at org.jboss.virtual.VirtualFile.visit(VirtualFile.java:437)
    at org.jboss.classloading.plugins.vfs.PackageVisitor.determineAllPackages(PackageVisitor.java:94)
    ... 33 more
Caused by: java.util.zip.ZipException: error in opening zip file
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(ZipFile.java:203)
    at java.util.zip.ZipFile.<init>(ZipFile.java:234)
    at org.jboss.virtual.plugins.context.zip.ZipFileWrapper.ensureZipFile(ZipFileWrapper.java:175)
    at org.jboss.virtual.plugins.context.zip.ZipFileWrapper.acquire(ZipFileWrapper.java:245)
    at org.jboss.virtual.plugins.context.zip.ZipEntryContext.initEntries(ZipEntryContext.java:470)
    at org.jboss.virtual.plugins.context.zip.ZipEntryContext.ensureEntries(ZipEntryContext.java:603)
    ... 51 more
18:21:56,772 INFO  [JMXConnectorServerService] JMX Connector server: service:jmx:rmi://localhost/jndi/rmi://localhost:1090/jmxconnector
18:21:56,959 INFO  [MailService] Mail Service bound to java:/Mail
18:21:59,450 WARN  [JBossASSecurityMetadataStore] WARNING! POTENTIAL SECURITY RISK. It has been detected that the MessageSucker component which sucks messages from one node to another has not had its password changed from the installation default. Please see the JBoss Messaging user guide for instructions on how to do this.
18:21:59,489 WARN  [AnnotationCreator] No ClassLoader provided, using TCCL: org.jboss.managed.api.annotation.ManagementComponent
18:21:59,789 INFO  [TransactionManagerService] JBossTS Transaction Service (JTA version) - JBoss Inc.
18:21:59,789 INFO  [TransactionManagerService] Setting up property manager MBean and JMX layer
18:22:00,040 INFO  [TransactionManagerService] Initializing recovery manager
18:22:00,160 INFO  [TransactionManagerService] Recovery manager configured
18:22:00,160 INFO  [TransactionManagerService] Binding TransactionManager JNDI Reference
18:22:00,184 INFO  [TransactionManagerService] Starting transaction recovery manager
18:22:01,243 INFO  [Http11Protocol] Initializing Coyote HTTP/1.1 on http-localhost%2F127.0.0.1-8080
18:22:01,244 INFO  [AjpProtocol] Initializing Coyote AJP/1.3 on ajp-localhost%2F127.0.0.1-8009
18:22:01,244 INFO  [StandardService] Starting service jboss.web
18:22:01,247 INFO  [StandardEngine] Starting Servlet Engine: JBoss Web/2.1.2.GA
18:22:01,336 INFO  [Catalina] Server startup in 161 ms
18:22:01,360 INFO  [TomcatDeployment] deploy, ctxPath=/invoker
18:22:02,014 INFO  [TomcatDeployment] deploy, ctxPath=/web-console
18:22:02,459 INFO  [TomcatDeployment] deploy, ctxPath=/jbossws
18:22:02,570 INFO  [RARDeployment] Required license terms exist, view vfszip:/Applications/jboss-5.0.1.GA/server/default/deploy/jboss-local-jdbc.rar/META-INF/ra.xml
18:22:02,586 INFO  [RARDeployment] Required license terms exist, view vfszip:/Applications/jboss-5.0.1.GA/server/default/deploy/jboss-xa-jdbc.rar/META-INF/ra.xml
18:22:02,645 INFO  [RARDeployment] Required license terms exist, view vfszip:/Applications/jboss-5.0.1.GA/server/default/deploy/jms-ra.rar/META-INF/ra.xml
18:22:02,663 INFO  [RARDeployment] Required license terms exist, view vfszip:/Applications/jboss-5.0.1.GA/server/default/deploy/mail-ra.rar/META-INF/ra.xml
18:22:02,705 INFO  [RARDeployment] Required license terms exist, view vfszip:/Applications/jboss-5.0.1.GA/server/default/deploy/quartz-ra.rar/META-INF/ra.xml
18:22:02,801 INFO  [SimpleThreadPool] Job execution threads will use class loader of thread: main
18:22:02,850 INFO  [QuartzScheduler] Quartz Scheduler v.1.5.2 created.
18:22:02,857 INFO  [RAMJobStore] RAMJobStore initialized.
18:22:02,858 INFO  [StdSchedulerFactory] Quartz scheduler 'DefaultQuartzScheduler' initialized from default resource file in Quartz package: 'quartz.properties'
18:22:02,858 INFO  [StdSchedulerFactory] Quartz scheduler version: 1.5.2
18:22:02,859 INFO  [QuartzScheduler] Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED started.
18:22:03,888 INFO  [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=DefaultDS' to JNDI name 'java:DefaultDS'
18:22:04,530 INFO  [ServerPeer] JBoss Messaging 1.4.1.GA server [0] started
18:22:04,624 INFO  [QueueService] Queue[/queue/DLQ] started, fullSize=200000, pageSize=2000, downCacheSize=2000
18:22:04,632 WARN  [ConnectionFactoryJNDIMapper] supportsFailover attribute is true on connection factory: jboss.messaging.connectionfactory:service=ClusteredConnectionFactory but post office is non clustered. So connection factory will *not* support failover
18:22:04,632 WARN  [ConnectionFactoryJNDIMapper] supportsLoadBalancing attribute is true on connection factory: jboss.messaging.connectionfactory:service=ClusteredConnectionFactory but post office is non clustered. So connection factory will *not* support load balancing
18:22:04,742 INFO  [ConnectionFactory] Connector bisocket://localhost:4457 has leasing enabled, lease period 10000 milliseconds
18:22:04,742 INFO  [ConnectionFactory] org.jboss.jms.server.connectionfactory.ConnectionFactory@6af9ad started
18:22:04,746 INFO  [QueueService] Queue[/queue/ExpiryQueue] started, fullSize=200000, pageSize=2000, downCacheSize=2000
18:22:04,747 INFO  [ConnectionFactory] Connector bisocket://localhost:4457 has leasing enabled, lease period 10000 milliseconds
18:22:04,747 INFO  [ConnectionFactory] org.jboss.jms.server.connectionfactory.ConnectionFactory@5ac953 started
18:22:04,750 INFO  [ConnectionFactory] Connector bisocket://localhost:4457 has leasing enabled, lease period 10000 milliseconds
18:22:04,750 INFO  [ConnectionFactory] org.jboss.jms.server.connectionfactory.ConnectionFactory@e8fa3a started
18:22:05,050 INFO  [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=JmsXA' to JNDI name 'java:JmsXA'
18:22:05,073 INFO  [TomcatDeployment] deploy, ctxPath=/
18:22:05,178 INFO  [TomcatDeployment] deploy, ctxPath=/jmx-console
18:22:05,290 ERROR [ProfileServiceBootstrap] Failed to load profile: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):

DEPLOYMENTS IN ERROR:
  Deployment "vfsfile:/Applications/jboss-5.0.1.GA/server/default/deploy/TwitterEAR.ear/" is in error due to the following reason(s): java.util.zip.ZipException: error in opening zip file

18:22:05,301 INFO  [Http11Protocol] Starting Coyote HTTP/1.1 on http-localhost%2F127.0.0.1-8080
18:22:05,364 INFO  [AjpProtocol] Starting Coyote AJP/1.3 on ajp-localhost%2F127.0.0.1-8009
18:22:05,373 INFO  [ServerImpl] JBoss (Microcontainer) [5.0.1.GA (build: SVNTag=JBoss_5_0_1_GA date=200902231221)] Started in 43s:467ms

The mentioned ear and war file are both in the deploy directory.

Does anybody have hints?

LastEditorDisplayName: kgiannakakis

Body:
Ok, I finally found the solution to my problem. It seems that there's a bug in Eclipse which prevent the creation of the .settings/org.eclipse.wst.common.component file. This file should be created when setting the EJB3 and Java6 facets in project properties.

Here is an org.eclipse.wst.common.component example file :

<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
    <wb-module deploy-name="project_name">
        <wb-resource deploy-path="/" source-path="/src/main/java"/>
        <wb-resource deploy-path="/" source-path="/src/main/resources"/>
        <wb-resource deploy-path="/" source-path="/src/test/java"/>
        <wb-resource deploy-path="/" source-path="/src/test/resources"/>
        <property name="java-output-path"/>
    </wb-module>
</project-modules>

The deploy paths must be defined in order to be able to create the EJB Jar file used by the server on deployment.
Once created, Jboss publish the EJB module correctly.

OwnerDisplayName: Jérôme