Euro sign is garbled on some machines - java

We have a web application (Java spring mvc project).
Our server returns jsons via REST API.
here is a response example from our QA env:
{currency: "EURO", symbol: "€", multiplier: 1}
here is the same response from a different enviornment (the Dev):
{currency: "EURO", symbol: "�", multiplier: 1}
Any ideas why this may happen?

OK - so my issue was with the build machine (Jenkins) which is running on ubuntu.
All the envs, that the build machine compiled and deployed our app had the issue.
I had to change the gradle tasks to be compiled with
tasks.withType(JavaCompile) { options.encoding = 'Cp1252' }
(Since we develop on windows env and thats the default).
Cheers

It's because your browser is painting out the font after all the work has been done to it in the background (on the server). This means you could have it encoded correctly at some point, but once the browser gets it, it is no longer encoded, and showing a character the browser doesn't understand.
You need to run one more pass with JavaScript on the browser side. A simple replace on the string with the proper encoding will fix it.

Related

Jmeter and MemCached Sets and Gets

So apologies if what I ask is trivial but I am experimenting with Memcached and Jmeter. I have a Memcached server setup (as far as I can tell) and am able to make telnet requests to it via telnet IP PORT and additionally set and get using commands set and get appropriately.
Now point me to a different application if perhaps this is the wrong choice; but my understanding was that Jmeter should allow me to pound the server with equivalent Set and Get requests.
Unfortunately the experimental platform is a remote linux PC running Rockylinux which is similar to CentOS / RedHat to my understanding (I didn't set this part up); and as a result I do not have a GUI to launch while on the Linux PC. I have however opened Jmeter up on my local PC on windows and understand I should be able to send the test file over and run it.
I followed these instructions to try to setup a TCP sampler and set the "text to send" field as below; after doing the additional step in the link regarding the precompiler.
set tutorialspoint 0 900 9${CR}${LF}
memcached${CR}${LF}
quit${CR}${LF}
Running the above as a headless jmeter session doesn't generate any errors called [./jmeter -n -t "Sample.jmx" -l testresults.jtl"] but when I connect via telnet I'm also not seeing the value for the key "tutorialspoint" get updated. When manually doing the get and set I am seeing updates. Any ideas what I could be doing wrong? Checking the log indicates ResponseCode 200 OK as expected. Is there a good method to debug something in a Headless setup?
Thanks for your time.
I believe the easiest way is using Memcached Java Client library
Download spymemcached-2.12.3.jar and drop it to "lib" folder of your JMeter installation (or any other location in JMeter Classpath)
Restart JMeter to pick the .jar up
Add JSR223 Sampler to your test plan and use the following code snippets:
def client = new net.spy.memcached.MemcachedClient(new InetSocketAddress('your-memcached-host', your-memcached-port)) - for connecting to the server
client.set('tutorialspoint', 900, 'memcached').done to write memcached to the tutorialspoint key for 15 minutes
client.get('tutorialspoint') - to read the value of tutorialspoint key
client.shutdown() - to disconnect
More information on Groovy scripting in JMeter: Apache Groovy - Why and How You Should Use It
Demo:

Cumulocity microservice deployment: access is denied

My goal (background info)
I want to develop a java microservice on cumulocity. It should be able to do the following:
I would send "112233" to the microservice as follows:
https://myTenant.cumulocity.com/service/my-application-name/decode?data=112233
The microservice should then split the data into "11" for the first measurement and "22" for the second measurement etc. These measurements would be POSTed to cumulocity.
My problem
I am now stuck on getting the Hello, microservice tutorial to work. I can't deploy the microservice (zip file) to cumulocity.
"error":"security/Forbidden","info":"https://www.cumulocity.com/guides/reference-guide/#error_reporting","message":"Access is denied"} (I am an admin user.)
I also tried to upload the zip file via the website, this created a HOSTED application instead of a MICROSERVICE. Uploading my zip via a POST request to a HOSTED application actually works (which I obviously don't need).
I suspect that I get the "access denied" error cause cumulocity thinks that I upload a HOSTED application to a MICROSERVICE.
What I've done so far
Code side
I downloaded the hello-world-microservice example from the cumulocity bitbucket development branch. (This code is not available on the default branch).
I changed the cumulocity versions to 9.3.0, only this version seems to exist.
The HelloWorldMain.java is unedited
This is my cumulocity.json manifest file: (the roles make no difference)
{
"apiVersion":"1",
"type":"MICROSERVICE",
"version":"#project.version#",
"availability":"PRIVATE",
"provider":{
"name":"Cumulocity GmbH"
},
"isolation":"MULTI_TENANT",
"requiredRoles":[
"ROLE_APPLICATION_MANAGEMENT_ADMIN",
"ROLE_MEASUREMENT_ADMIN",
"ROLE_INVENTORY_ADMIN"
],
"roles":[
"ROLE_APPLICATION_MANAGEMENT_ADMIN",
"ROLE_MEASUREMENT_ADMIN",
"ROLE_INVENTORY_ADMIN"
],
"livenessProbe":{
"httpGet":{
"path":"/health",
"port":80
},
"initialDelaySeconds":15,
"periodSeconds":10
},
"readinessProbe":{
"httpGet":{
"path":"/health",
"port":80
}
}
}
This is my application.properties file
application.name=my-application-name
server.port=80
C8Y.baseURL=https://myTenant.cumulocity.com
C8Y.bootstrap.tenant=myTenant
C8Y.bootstrap.user=servicebootstrap_my-application-name
C8Y.bootstrap.password={SECRET_BOOTSTRAP_PASSW}
C8Y.user={MY_USERNAME}
C8Y.password={SECRET_PASSW}
C8Y.bootstrap.register=true
C8Y.microservice.isolation=MULTI_TENANT
C8Y.bootstrap.initialDelay=10000
Cumulocity side
I successfully created a microservice application,
GET https://myTenant.cumulocity.com/application/applications/5886 returns:
{
"availability":"PRIVATE",
"id":"5886",
"key":"my-application-key",
"manifest":{
"imports":[
],
"noAppSwitcher":true
},
"name":"my-application-name",
"owner":{
"self":"https://myTenant.cumulocity.com/tenant/tenants/myTenant",
"tenant":{
"id":"myTenant"
}
},
"requiredRoles":[
"ROLE_APPLICATION_MANAGEMENT_ADMIN",
"ROLE_MEASUREMENT_ADMIN",
"ROLE_INVENTORY_ADMIN"
],
"roles":[
"ROLE_APPLICATION_MANAGEMENT_ADMIN",
"ROLE_MEASUREMENT_ADMIN",
"ROLE_INVENTORY_ADMIN"
],
"self":"https://myTenant.cumulocity.com/application/applications/5886",
"type":"MICROSERVICE"
}
I also successfully subscribed to this application.
When I try to upload the zip file to cumulocity, I get this error:
"error":"security/Forbidden","info":"https://www.cumulocity.com/guides/reference-guide/#error_reporting","message":"Access is denied"}
(Uploading to a HOSTED type application works fine, but I don't want that.)
note: I also tried to use the microservice deploy script, this gave the same result as doing everything manually.
Trying to run it locally
Since I couldn't get it to work on the cumulocity platform, I tried to run it locally via docker. I ran it with this command:
docker run -e "C8Y_MICROSERVICE_ISOLATION=MULTI_TENANT" 10aa0b73ddb3
note: I had to add the "C8Y_MICROSERVICE_ISOLATION=MULTI_TENANT" environment variable. if I didn't add this, I'd get credential/permission issues. This seems weird to me, since all other info is read from the application.properties file except for this one.
I have no errors when running this image on a local docker.
According to the Hello, microservice tutorial, I should be able to request curl -H "Authorization: {AUTHORIZATION}" https://myTenant.cumulocity.com/service/my-application-name/hello?who=me
This returns:
{"error":"microservice/Not Found","info":"https://www.cumulocity.com/guides/reference-guide/#error_reporting","message":"Microservice my-application-name not found."}
Back to the questions
Has anyone else had difficulties with setting up a microservice on cumulocity?
Is there something I'm totally overseeing?
The microservice hosting needs to be assigned to your tenant otherwise it won't work and the API in that case will return forbidden. So it might be that it is no issue with your user but that your tenant has the feature not activated.

Nightwatch.js without Java

Is it possible to use Nightwatch.js without installing Java? There are official Selenium JavaScript bindings (WebDriverJS, selenium-webdriver). Is there a reason Java is required?
I am catering to a JavaScript community so I am trying to run nightwatchjs locally without introducing Java myself. I am certain that if you run a remote Selenium Server, that remote instance has to have the Java server running to pass off commands to the remote browser-specific driver. E.g.: ChromeDriver.
That said, I was under the impression that one could connect a standard client directly to a standard WebDriver (ChromeDriver) locally without having to stage the Java selenium-server-standalone-2.xx.0.jar server. With nightwatchJS being the 1st client I have tried, it was very hard to find a configuration where that would work since all the documentation indicates what Nate Stone is saying above. All examples that I have seen indicate that the location of the selenium-server-standalone-2.xx.0.jar needs to be stipulated:
selenium": {
"start_process": true,
"server_path": "lib/selenium-server-standalone-2.53.0.jar",
"cli_args" : {
"webdriver.chrome.driver" : "/Users/greg.kedge/bin/chromedriver"
},
"log_path": "integration/log" }
He's what I can say: if you want nightwatch to start (and stop) the server for you for the duration of the tests ("start_process": true), it does seem to be necessary to run the Java server.
However, through much trial, if you want to start the ChromeDriver on your own on the command line, thereby having it up all the time, I can run the ChromeDriver without the Java Selenium standalone. CAVEAT: Only attempted on OS X so far... So, assuming ChromeDriver is in your $PATH:
% chromedriver --url-base=/wd/hub
Starting ChromeDriver 2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4) on port 9515
Only local connections are allowed.
Now grab that port (9515) and update your nightwatch.json to dictate you want to use Chrome. I am setting the default, but you could set up a Chrome-specific environment. Remove the "selenium" block from your nightwatch.json altogether and now tell nightwatch where it can find a running server AND what type of browser that is serving:
"test_settings": {
"default": {
"launch_url": "http://localhost:8888/",
"selenium_host": "127.0.0.1",
"selenium_port": "9515",
"silent": true,
"firefox_profile": false,
"screenshots": {
"enabled": false,
"path": ""
},
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"__commentOut: chromeOptions" : {
"args" : ["start-fullscreen"]
}
},
}
}
Using it this way works for me; I can run nightwatch to drive Chrome without a Java Selenium standalone server in-play. Again, this is on OS X using a ChromeDriver that is always running. I can't figure out how to get nightwatch to manage starting/stopping the ChromeDriver without adding the Java Selenium standalone server to the mix.
There is now documentation on the official site on how to do it.
I had some trouble with the configuration, so I have created a sample repository with working code:
https://github.com/zeljkofilipin/mediawiki-nightwatch
Well Nightwatch.js runs it's tests against the Selenium server. The Selenium server is a Java-Servlet.
So to use Nightwatch.js you just "indirectly" need Java (it's not needed for Nightwatch.js, but for Selenium).
However you are able to use different languages as Selenium Client, since you are able to download different WebDriver Language bindings here
++++++++++++++++++EDIT++++++++++++++++++
Those WebDrivers/bindings are independent of Nightwatch.js. You can use these WebDrivers/bindings without a Selenium server, if your tests and your browser run on the same machine. In this case you do not need Java, since the WebDriver runs the tests directly against a browser (this is further detailed here)
Nightwatch.js on the other hand definitelly requires java, because it needs the "Selenium-Standalone-Server" which is written in Java. As far as I know there are no other implementations for other languages, which is why it's not possible to run it without java.
Nightwatch sends HTTP requests to the Selenium-Standalone-Server (here comes java) and the server creates a session with the browser.
So to sum up: No Java --> No "Selenium-Standalone-Server" --> No testing with Nightwatch.js
There is:
Specify in global.js file the following:
const chromedriver = require('chromedriver');
module.exports = {
before: function (cb) {
chromedriver.start();
cb();
},
after: function (cb) {
chromedriver.stop();
cb();
},
Go to nightwatch.conf.js specify the global path there
That way you selenium will be diverted via Chromedriver without you needing selenium on your machine.

How to setup AWS Lambda service for a local server

I am trying to setup an application server for AWS Lambda but on a local network so that an application won't have to go out to the internet to execute. I would prefer to use a linux box and my programming environment is Java.
The skill from the echo will execute and then communicate with the local server rather than going out to the internet and communicating with Amazon's application server.
My question is this: How do I setup the application server to handle the skill? I've done the example from Amazon, do I only need to have the linux box run the Java application or is there more to the setup than that? I see there are AMIs (Amazon Machine Images) but can I deploy those locally or are they only for use on the AWS console?
Any insight into this would be great, thank you.
So this is how usual interaction between echo works:
User--->Echo--->Skill--->(Internet)Applicaton server (I'm using Amazon hosted AWS lambda)
I would like to use :
User--->Echo--->Skill--->(LAN)Application server (without ever using the internet).
Currently I have setup echo and a skill but no application server on the LAN. What do I need for the application server? JAWS and something else?
I'm not sure if this question is still relevant or not, but I'm using DEEP Framework to test the code locally and/or deploy it on AWS Lambda. Check this out:
npm install deepify -g
deepify run-lambda --help
run-lambda#1.6.8 - Run Lambda function locally
Usage example: deepify run-lambda path/to/the/lambda -e='{"Name":"John Doe"}'
Arguments:
path: The path to the Lambda (directory of handler itself)
Options:
--event|-e: JSON string used as the Lambda payload
--skip-frontend-build|-f: Skip picking up _build path from the microservices Frontend
--db-server|-l: Local DynamoDB server implementation (ex. LocalDynamo, Dynalite)
--version|-v: Prints command version
--help|-h: Prints command help
Also, you might want consider using the server option:
deepify server --help
server#1.6.9 - Run local development server
Usage example: deepify server path/to/web_app -o
Arguments:
path: The path to the Lambda (directory of handler itself)
Options:
--build-path|-b: The path to the build (in order to pick up config)
--skip-frontend-build|-f: Skip picking up _build path from the microservices Frontend
--skip-backend-build|-s: Skip building backend (dependencies installation in Lambdas and linking aws-sdk)
--skip-build-hook|-h: Skip running build hook (hook.build.js)
--port|-p: Port to listen to
--db-server|-l: Local DynamoDB server implementation (ex. LocalDynamo, Dynalite)
--open-browser|-o: Open browser after the server starts
--version|-v: Prints command version
--help|-h: Prints command help
Disclosure: I am one of the contributors to this framework

Windows service installed with Procrun works in //TS mode, but doesn't start as a Windows service saying it "started and then stopped"

I installed a standard executable jar file as a Windows service by running the following command:
> prunsrv.exe //IS//"My Service" --Install="C:\path-to-prunsrv.exe" --Jvm=auto \
--Startup=auto --StartMode=jvm --Classpath="C:\path-to-MyService.jar" \
--StartClass=com.mydomain.MyService
I can now run my program fine in console mode by running the following command (I'm using Java 1.6):
> prunsrv.exe //TS//"My Service"
When I try to start the service through the standard Windows services interface, I get the following error message:
The MyService service on Local Computer started and then stopped. Some services stop automatically if they are not in use by other services or programs.
There is no output in my application's log file when I attempt to start the service this way. There is also no output in the Window's event log (Windows 7 64-bit). What can I do to try and figure out why this service will not run?
Don't use any white-space in the service name!
After many hours of testing and pulling apart Tomcat and duplicating it's bootstrap process, the fix for my problem ended up being that Apache Commons Daemon (Procrun) does not work properly when there is white-space in the name of the Windows service.
It seemingly correctly installs and registers a service with Windows when there are spaces in the service name. The Windows registry entries even look correct. The service even runs in debug (aka TS or console) mode just fine. When run, however, as an actual service launched by Windows it fails if the service was installed with a white-space in the service name.
I sure wish Procrun had some type of log output when it fails! Good logging can make debugging issues like this a snap.
I did need to have multiple words in my service name, so I named my service with one word and changed the name with the "DisplayName" parameter:
> prunsrv.exe //IS//MyService --Install="C:\path-to-prunsrv.exe" --Jvm=auto \
--Startup=auto --StartMode=jvm --Classpath="C:\path-to-MyService.jar" \
--StartClass=com.mydomain.MyService --DisplayName="My Service"
I wanted to give some additional information about what '11101101b' said above. (This is my first post, so please be gentle!)
I was able to get the service to install correctly with spaces in the service name by changing the //IS//MyService part of his command to instead be the following, which I suspect is what he also did. (I apologize if I'm assuming incorrectly.) Notice that the opening double quote is at the beginning of the string rather than at the beginning of the service name.
"//IS//My Service"
As was the case for him, the service installed correctly and looked correct, but it wouldn't start. I was able to get around that by changing the service's ImagePath value data setting in the registry to have the same change for the //RS//My Service part of the command. Therefore, the registry value instead had the following in its data setting:
"//RS//My Service"
Everything seems to be working without any problems.
This server starts and stops because of reason the task is completed by the service so it would stop automatically. if you have a logic of running long inside it would not stop.
I got same problem ... under my local machine everthing working fine on server the same issue => problem was that Working Path was not set.
May its heps someone ... be the force with you

Categories

Resources