I use StrutsTestCase2.4 under netbeans7.0 with struts1.3
When running testCase, it shows:
Error initializing action servlet
javax.servlet.UnavailableException: The /WEB-INF/web.xml was not found.
I've googled this problem and it is suggested to be solved by setContextDirectory(new File("../web"));:
protected void setUp() throws Exception
{
super.setUp();
setContextDirectory(new File("../web"));
}
But I am not quite sure what the location of new File() should be.
My File tree is
|───build
│ ├───test
│ │ └───classes
│ │ └───com
│ │ └───stolon
│ │ ├───common
│ │ ├───database
│ │ ├───helpers
│ │ └───struts
│ └───web
│ ├───META-INF
│ └───WEB-INF
│ ├───classes
│ │ └───com
│ │ └───stolon
│ │ ├───algorithm
│ │ ├───database
│ │ ├───helpers
│ │ ├───servlet
│ │ ├───structures
│ │ └───struts
│ └───lib
├───nbproject
│ └───private
├───src
│ ├───conf
│ └───java
│ └───com
│ └───stolon
│ ├───algorithm
│ ├───database
│ ├───helpers
│ ├───servlet
│ ├───structures
│ └───struts
├───test
│ └───com
│ └───stolon
│ ├───common
│ ├───database
│ ├───helpers
│ └───struts
└───web
├───META-INF
└───WEB-INF
My test file is under test-com-stolon-struts.
I just ran in to this. WEB-INF/web.xml (and probably struts-config.xml, etc.) must be on your classpath when the tests are running. Make sure netbeans is putting /build/web/ on the test classpath.
If you were using maven, you would add WEB-INF/*.xml as a test resource.
<testResources>
<testResource>
<directory>WEB-INF</directory>
<targetPath>/WEB-INF</targetPath>
<includes>
<include>*.xml</include>
</includes>
</testResource>
</testResources>
From the directory structure, it seems : setContextDirectory(new File("../../../../web"));
So, based on the tree above, the location of new File() should be "web":
protected void setUp() throws Exception {
super.setUp();
setContextDirectory(new File("web"));
}
Related
I'm trying to share tailwindcss preset between both react and react-native apps in tx monorepo. Preset is stored in .js file located in root nx library named "tailwind".
While importing preset object to tailwind.config.js with:
import { preset } from '#app/tailwind';
module.exports = {
content: ['./src/**/*.tsx', './src/app/**/*.tsx'],
theme: {
extend: {},
},
plugins: [],
presets: [preset],
corePlugins: require('tailwind-rn/unsupported-core-plugins'),
};
and running nx dev:tailwind i get error
SyntaxError: Cannot use import statement outside a module
if I try to use require instead of import
const { preset } = require('#app/tailwind');
I get error:
Error: Cannot find module '#app/tailwind`
And finally when I tried to convert tailwind.config.js to tailwind.config.ts and then use import statement, I did not get any errors, but tailwind-rn does not see tailwind config at all.
And if I import and console.log() preset for test purposes in App.tsx it logs just fine.
Project structure:
app/
├─ apps/
│ ├─ mobile/
│ │ ├─ tailwind.config.js
│ │ ├─ src/
│ │ ├─ android/
│ │ ├─ ios/
│ ├─ web/
├─ libs/
│ ├─ tailwind/
│ │ ├─ src/
│ │ │ ├─ index.ts
│ │ │ ├─ lib/
│ │ │ │ ├─ preset.ts
I'm having issues linking my project together using cmake.
The project consists of a library, "mylib", and an executable, "mybin", which is linked with it. The structure is the following:
.
├── CMakeLists.txt
├── include
│ ├── mylib.h
│ ├── entities
│ │ ├── entities.h
│ │ ├── entityA.h
│ │ └── entityB.h
│ └── shapes
│ ├── shapes.h
│ ├── shapeA.h
│ └── entityB.h
└── src
├── main.cpp
├── entities
│ ├── entityA.cpp
│ └── entityB.cpp
└── shapes
├── shapeA.cpp
└── entityB.cpp
Where mylib uses all .cpp and .h files (except from main.cpp) to create a static library, and mybin uses main.cpp and links with mylib.h. mylib.h pulls the other header files from the include directory.
Right now, my CMakeLists.txt looks like this:
cmake_minimum_required(VERSION 3.13)
project(myproject VERSION 1.1.0 LANGUAGES C CXX)
add_library(mylib
src/entities/entityA.cpp
src/entities/entityB.cpp
src/shapes/shapeA.cpp
src/shapes/shapeB.cpp
include/mylib.h
include/entities/entities.h
include/entities/entitiesA.h
include/entities/entitiesB.h
include/shapes/shapes.h
include/shapes/shapeA.h
include/shapes/shapeB.h
)
target_include_directories(mylib PUBLIC include)
target_link_libraries(mylib PUBLIC)
target_compile_features(mylib PRIVATE cxx_std_11)
add_executable(mybin src/main.cpp)
target_link_libraries(mybin PRIVATE mylib)
target_compile_features(mybin PRIVATE cxx_std_11)
When I try to build my code, with
mkdir build
cd build
cmake ..
make
The library builds fine, but I get linking errors while the executable is building:
/usr/bin/ld: shapeA.cpp:(.text+0x344): undefined reference to `MyLib::Entities::EntityA::normalize_inplace()'
Not sure how to fix this, I tried to follow numeral tutorials and looking at other issues here and examples, but couldn't get to fix it. The actual code is in my github, in the "cmake" branch.
Thank you very much.
EDIT
The linking error I copied above is used in the src/shapes/shapeA.cpp file:
#include "shapes/shapeA.h"
#include <algorithm>
using MyLib::Entities::EntityA;
Mylib::Shapes::ShapeA::ShapeA() {}
Mylib::Shapes::ShapeA::~ShapeA(){}
bool Mylib::Shapes::ShapeA::intersect(const EntityA &entity) const {
const EntityA invdir = (EntityA(1.0, 1.0, 1.0) + entity).normalize_inplace();
return true;
}
It is defined in src/entities/entityA.cpp :
#include "entities/EntityA.h"
using MyLib::Entities::EntityA;
EntityA::EntityA(double a, double b, double c) :
a_(a), b_(b), c_(c) {}
EntityA::~EntityA(){}
EntityA EntityA::normalize_inplace(){
const double tot = std::sqrt(a_*a_ + b_*b_ + c_*c_);
a_ /= tot;
b_ /= tot;
c_ /= tot;
return EntityA(1.0, 1.0, 1.0);
}
EntityA EntityA::operator+(EntityA other) {
return EntiryA(a_ + other.a_, b_ + other.b_, c_ + other.c_);
}
There are many more linking errors like that one, I think nothing gets linked correctly at all.
Also, I used a makefile previously and all linking was being made correctly.
Firstly, I got this message below when running npm audit:
updated 1 package and audited 381 packages in 1.767s
found 1 moderate severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
→ weatherApp npm audit
=== npm audit security report ===
┌────────────────────────────────────────────────────────────────────────────┐
│ Manual Review │
│ Some vulnerabilities require your attention to resolve │
│ │
│ Visit https://go.npm.me/audit-guide for additional guidance │
└────────────────────────────────────────────────────────────────────────────┘
┌───────────────┬────────────────────────────────────────────────────────────┐
│ Moderate │ Denial of Service │
├───────────────┼────────────────────────────────────────────────────────────┤
│ Package │ axios │
├───────────────┼────────────────────────────────────────────────────────────┤
│ Patched in │ >=0.18.1 │
├───────────────┼────────────────────────────────────────────────────────────┤
│ Dependency of │ nominatim-geocoder │
├───────────────┼────────────────────────────────────────────────────────────┤
│ Path │ nominatim-geocoder > axios │
├───────────────┼────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/880 │
└───────────────┴────────────────────────────────────────────────────────────┘
found 1 moderate severity vulnerability in 381 scanned packages
1 vulnerability requires manual review. See the full report for details.
→ weatherApp █
Typing npm audit fix didn't help neither:
fixed 0 of 1 vulnerability in 381 scanned packages
1 vulnerability required manual review and could not be updated
On https://npmjs.com/advisories/880 they recommended to upgrade axios version to >=0.18.1. However, in my package.json the version is ^0.19.0.
package.json:
...
"dependencies": {
"axios": "^0.19.0",
"body-parser": "^1.19.0",
"ejs": "^3.0.1",
"epxress": "0.0.1-security",
"express": "^4.17.1",
"nodemon": "^2.0.1",
"nominatim-geocoder": "^0.1.4",
"request": "^2.88.0"
}
...
So, I tried to manually upgrade the version of axios in the package-lock.json as it still shows 0.16.1.
package-lock.json:
"nominatim-geocoder": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/nominatim-geocoder/-/nominatim-geocoder-0.1.4.tgz",
"integrity": "sha1-7o8I+CZq0tL5zYfdQhzCdmtRF78=",
"requires": {
"axios": "^0.16.1",
"lru": "^3.1.0",
"promise-queue": "^2.2.3",
"sha1": "^1.1.1"
},
"dependencies": {
"axios": {
"version": "0.16.2",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.16.2.tgz",
"integrity": "sha1-uk+S8XFn37q0CYN4VFS5rBScPG0=",
"requires": {
"follow-redirects": "^1.2.3",
"is-buffer": "^1.1.5"
}
... to version 0.19.0. However, that didn't help... Any suggestions?
I am continuously failing to start the nuxt project through pm2.
I created the project today using npx create-nuxt-app arif-app my project structure is initial for testing purpose but still i would like to illustrate -
arif-app (project-dir) -->
.editorconfig
.gitignore
.nuxt <DIR>
assets <DIR>
components <DIR>
ecosystem.config.js
layouts <DIR>
middleware <DIR>
node_modules <DIR>
nuxt.config.js
package-lock.json
package.json
pages <DIR>
plugins <DIR>
README.md
static <DIR>
store <DIR>
pm2 ecosystem config in ecosystem.config.js is -
module.exports = {
apps : [{
name: '.nuxt',
script: 'index.js',
// Options reference: https://pm2.io/doc/en/runtime/reference/ecosystem-file/
args: 'one two',
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: '1G',
env: {
NODE_ENV: 'development'
},
env_production: {
NODE_ENV: 'production'
}
}],
deploy : {
production : {
user : 'momustafa',
host : '127.0.0.1',
ref : 'origin/master',
repo : 'git#github.com:repo.git',
path : 'C:\Users\momustafa\Desktop\Assets\new_test\arif-app',
'post-deploy' : 'npm install && pm2 reload ecosystem.config.js --env production'
}
}
};
and inside the package.json is :
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "pm2 start ./node_modules/nuxt/bin/nuxt -i max --attach",
"generate": "nuxt generate"
},
"dependencies": {
"#nuxtjs/axios": "^5.3.6",
"nuxt": "^2.0.0",
"vue": "^2.6.10",
"vue-awesome": "^3.5.4",
"vue-loader": "^15.7.0"
},
and before the pm2 start, I already have build the project using npm run build,
and now after the build, I passed the following command(s) through pm2 to run nuxt project,
C:\Users\momustafa\Desktop\Assets\new_test\arif-app>pm2 start .nuxt
[PM2] Applying action restartProcessId on app [.nuxt](ids: 0)
[PM2] [.nuxt](0) ✓
[PM2] Process successfully started
┌──────────┬────┬─────────┬──────┬───────┬─────────┬─────────┬────────┬─────┬────────┬───────────┬──────────┐
│ App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │
├──────────┼────┼─────────┼──────┼───────┼─────────┼─────────┼────────┼─────┼────────┼───────────┼──────────┤
│ .nuxt │ 0 │ N/A │ fork │ 11164 │ stopped │ 16 │ 0 │ 0% │ 0 B │ momustafa │ disabled │
└──────────┴────┴─────────┴──────┴───────┴─────────┴─────────┴────────┴─────┴────────┴───────────┴──────────┘
Use `pm2 show <id|name>` to get more details about an app
C:\Users\momustafa\Desktop\Assets\new_test\arif-app>pm2 kill
[PM2] [v] Modules Stopped
[PM2] Applying action deleteProcessId on app [all](ids: 0)
[PM2] [.nuxt](0) ✓
[PM2] [v] All Applications Stopped
[PM2] [v] PM2 Daemon Stopped
C:\Users\momustafa\Desktop\Assets\new_test\arif-app>pm2 start npm --name .nuxt -- start
[PM2] Spawning PM2 daemon with pm2_home=C:\Users\momustafa\.pm2
[PM2] PM2 Successfully daemonized
[PM2] Starting C:\PROGRAM FILES\NODEJS\NPM.CMD in fork_mode (1 instance)
[PM2] Done.
┌──────────┬────┬─────────┬──────┬──────┬─────────┬─────────┬────────┬─────┬────────┬───────────┬──────────┐
│ App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │
├──────────┼────┼─────────┼──────┼──────┼─────────┼─────────┼────────┼─────┼────────┼───────────┼──────────┤
│ .nuxt │ 0 │ N/A │ fork │ 8864 │ stopped │ 1 │ 0 │ 0% │ 0 B │ momustafa │ disabled │
└──────────┴────┴─────────┴──────┴──────┴─────────┴─────────┴────────┴─────┴────────┴───────────┴──────────┘
Use `pm2 show <id|name>` to get more details about an app
and continuously I am getting following pm2 error logs -
C:\Users\momustafa\Desktop\Assets\new_test\arif-app\.nuxt\index.js:1
(function (exports, require, module, __filename, __dirname) { import Vue from 'vue'
^^^
SyntaxError: Unexpected identifier
at new Script (vm.js:80:7)
at createScript (vm.js:274:10)
at Object.runInThisContext (vm.js:326:10)
at Module._compile (internal/modules/cjs/loader.js:664:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Object.<anonymous> (C:\Users\momustafa\AppData\Roaming\npm\node_modules\pm2\lib\ProcessContainerFork.js:27:21)
at Module._compile (internal/modules/cjs/loader.js:701:30)
please help someone.
Note: In nuxt#2.8.1 the module file name is nuxt.js instead of nuxt-start.js
I got a structure
content/
├── applications
│ └── 2017
│ └── 08
│ └── 30
│ ├── article.md
│ └── forecast1.png
I want the img files to be same directories as the md files so that they can be put to:
ARTICLE_SAVE_AS = 'posts/{date:%Y}/{date:%b}/{date:%d}/{slug}/index.html'
I have STATIC_PATHS = ['static_files','content'] however, the
[alt]({attach}applications/2017/08/30/forecast1.png)
gives error:
WARNING: Unable to find `applications/2017/08/30/forecast1.png`, skipping url replacement.
How can I include image into my md file in this simple case?
EDIT
so I changed the config applications is my category to:
PATH = 'content'
STATIC_PATHS = ['static_files','applications/2017/08/30/img', 'applications/2017/09/01/img']
ARTICLE_PATHS = ['applications', 'cat2', 'cat3']
I also added the ! before the [alt]() and still the images are not copied over to output.
EDIT2
iT WORKS WHEN APPLY EDIT ABOVE AND CHANGE ({attach}img/forecast1.png)
This works for me (following this):
content/
├── p001
│ └── myArticle001.md
│ └── img001
│ └── myPic1.png
│ └── myPic2.png
├── p002
│ └── myArticle002.md
│ └── img002
│ └── myPic1.png
│ └── myPic2.png
In pelicanconfig.py set:
PATH = 'content'
STATIC_PATHS = ['p001','p002']
ARTICLE_PATHS = STATIC_PATHS
In the md-files set:
![pic_A1]({attach}img001/myPic1.png)
![pic_A2]({attach}img001/myPic2.png)
and
![pic_B1]({attach}img002/myPic1.png)
![pic_B2]({attach}img002/myPic2.png)
Probabley you missed a ! only at the begin of the command. So you might try this:
![alt]({attach}applications/2017/08/30/forecast1.png)
Or try this:
PATH = 'content'
STATIC_PATHS = ['applications']
ARTICLE_PATHS = STATIC_PATHS
...
![alt]({attach}2017/08/30/forecast1.png)