In Wildfly Server 12 having concern with split function used in JavaScript - wildfly

In our project currently we are using wildfly 9 server, so are planning to upgrade wildly server 12.
However, while doing testing we found some error regarding split function using in JavaScript.
Ex:
<script type="text/javascript">
function testSplitFunction(){
var data="input$output";
var variable1 = data.split("\\$")[0];
var variable2 = data.split("\\$")[1];
}
</script>
This above function is working as expected in wildfly server 9 and we are getting the result as bellow
variable1= input;
variable2 = output;
But same function in wildfly server 12 we are getting the following result:
variable1= input$output;
variable2 = undefined;
Is their any solution to overcome this problem in wildfly server 12? In our project we are using this split more times.

Related

Flask response setting is not working in Bluemix Flask Buildpack

I am trying deploying my flask application to the Bluemix where it is configured by Bluemix Python Flask BuildPack and it is not a custom build back.
#app.route('/run', methods=['GET','POST'])
def stockModuleRunner():
stockCode = request.args.get("stock_code","")
# Store the reference, in case you want to show things again in standard output
old_stdout = sys.stdout
# This variable will store everything that is sent to the standard output
result = StringIO()
sys.stdout = result
# Here we can call anything
# Here we can call anything we like, like external modules, and everything that they will send to standard output will be stored on "result"
r = Resilience.Resilience()
r.main(stockCode)
# Redirect again the std output to screen
sys.stdout = old_stdout
# Then, get the stdout like a string and process it!
result_string = result.getvalue()
print(result_string)
#r = Resilience.Resilience()
#r.main(stockCode)
resp = Response("<html><pre>"+result_string+"</pre></html>")
resp.headers['content-type'] = 'text/html; charset=utf-8'
return
I set the content type of my response as a text/html. But it didn't work in the Bluemix, while it worked in my local environment. In the Bluemix, it changed to text/xml automatically. I confirmed it through the network tab of chrome developer tool. I got the error like the followings. As per the result of a google search, I found out that it is a sort of xml parsing error. Do you have any idea of this problem?
This page contains the following errors:
error on line 1 at column 1: Document is empty
Below is a rendering of the page up to the first error.

Debugging a crashing language server

I apologize if I'm a bit low on details here, but the main issue is actually trying to find the problem with my code. I'm updating an older extension of my own that was based on the Language Server example (https://code.visualstudio.com/docs/extensions/example-language-server). I've run into an issue where when I run the client part of my code using F5, and the debug window fires, I get:
The CSSLint Language Client server crashed 5 times in the last 3 minutes. The server will not be restarted.
Ok... so... here's the thing. The problems view in my extension client code shows nothing. DevTools for that Code window shows nothing.
The problems view for my server code shows nothing. DevTools, ditto.
For the Extension Developer Host instance, DevTools does show this:
messageService.ts:126 The CSSLint Language Client server crashed 5 times in the last 3 minutes. The server will not be restarted.e.doShow # messageService.ts:126
But I can't dig into the details to find a bug. So the question is - assuming that my server code is failing, where exactly would the errors be available?
Here is what I usually do to track server crashes down (I assume your server is written in JavaScript / TypeScript).
Use the following server options:
let serverModule = "path to your server"
let debugOptions = { execArgv: ["--nolazy", "--debug=6009"] };
let serverOptions = {
run: { module: serverModule, transport: TransportKind.ipc },
debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions}
};
Key here is to use the TransportKind.ipc. Errors that happen in the server and printed to stdio will then show in the output channel associated to your server (the name of the output channel is the name passed to the LanguageClient)
If you want to debug the server startup / initialize sequence you can change the debugOptions to:
let debugOptions = { execArgv: ["--nolazy", "--debug-brk=6009"] };
If the extension is started in debug mode (e.g. for example launched from VS Code using F5) then the LanguageClient automatically starts the server in debug mode. If the extension is started normally (for example as a real extension in VS Code) then the server is started normally as well.
To make this all work you need a latest version of the LSP node npm module both for server can client (e.g. 2.6.x)

Modifying the Request parameters throws Internal Server Error

When using the Python Eve Database hooks I am trying to modify the request parameters on a post call I am getting the below error
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>500 Internal Server Error</title>
<h1>
Internal Server Error
</h1>
<p>The server encountered an internal error and was unable to complete your
request.Either the server is overloaded or there is an error in the
application.
</p>
And when I remove the code fragment to modify the Request Parameters the resource is created successfully.
Please find the code snippet as :-
__author__ = 'sappal'
from eve import Eve
import time
def insert_people(items):
# retrieve request parameter, if present
print items['userid']
print items['email']
items['userid']= "Tushar_Sappal" + str(int(time.time()))
items['email'] = "sappal.tushar"+str(int(time.time()))+"#gmail.com"
print items
# Creating the instance of the EVE Application
app = Eve()
app.on_insert_people += insert_people
if __name__== '__main__':
app.run(host='0.0.0.0')
items is a list so you should update your code like this:
def insert_people(items):
for item in items:
item['userid']= "Tushar_Sappal" + str(int(time.time()))
item['email'] = "sappal.tushar"+str(int(time.time()))+"#gmail.com"
While in development, you usually want to run your application in debug mode, so you can get a full stack-trace with the error:
app.run(debug=True)
Just make sure to disable the debug mode when running in production.

PHP Fatal error: Class 'MongoDate' not found

I use lithium console (lithium/console/li3) to run some command and I get this error:
PHP Fatal error: Class 'MongoDate' not found
My system details:
mongodb server: 2.6.1
php mongodb client: 1.5.2
apache 2.4.7
php 5.5.9-1ubuntu4
$Requests = Requests::find('all', array('conditions'=>array(
'expired'=>array('<'=>new \MongoDate(time())),
'processed'=>0
)));
I don't have this error while running this code in older version system
PHP Version 5.3.10-1ubuntu3.11
Apache/2.2.22 (Ubuntu) Server
mongodb client: 1.4.5
mongodb server: 2.4.10
Thank you.
One more thing: I try to create just a simple script
$date = new MongoDate();
it runs without problem via webserver (browser) but if I use php command to run this file, I get the same error: Class 'MongoDate' not found
So I believe that it's php command problem.
For people that have come here using PHP7, the classs has been renamed:
MongoDate is now MongoDB\BSON\UTCDateTime
Also I've found that this now wants miliseconds instead of seconds, so make sure you multiple your input by 1000, for example:
$date = new \MongoDB\BSON\UTCDateTime(strtotime('yesterday') * 1000);
Make sure your mongodb extension is loaded.
var_dump(extension_loaded('mongodb'));
If not, you must load it in php.ini.

Eclipse base HTML5 Websocket and GlassFish

Env for project: -
Eclipse 3.6 (Eclipse-jee-helios) + HTML5 + JavaScript + Websocket + (grizzly) Glassfish 3.1.1
I have deployed sample project and able to run using GF.
When i try to connect websocket it always call onClose.
I tried: -
asadmin set configs.config.server-config.network-config.protocols.protocol.http-listener-1.http.websockets-support-enabled=true
GF 3.1.1 supports web socket (Downloaded from http://glassfish.java.net/downloads/3.1.1-final.html)
Browser like safari and Google Chrome supports websocket (i am using latest browser and checked with http://websocket.org/echo.html URL)
Java Script:-
var webSocket;
$(document).ready(
function() {
**var URL = "ws://localhost:8080/SampleGF/WebSocketChatServlet";**
//Tried using and lot of combination of URLS
var URL = "ws://localhost:8080/";
var URL = "ws://localhost:8080/SampleGF";
var URL = "ws://localhost:8080/SampleGF/WebSocketChatServlet";
webSocket = new WebSocket(URL);
//alert("WebSockets are " + (window.WebSocket ? "" : "not ") + "supported");
webSocket.onopen = function(event) {
alert("OPEN")
}
webSocket.onmessage = function(event) {
var $textarea = $('#messages');
$textarea.val($textarea.val() + event.data + "\n");
$textarea.animate({
scrollTop : $textarea.height()
}, 1000);
}
webSocket.onclose = function(event) {
alert("CLOSE")
}
});
function sendMessage() {
var message = $('#username').val() + ":" + $('#message').val();
webSocket.send(message);
$('#message').val('');
}
i have used ChatSocket.java, WebSocketChatServlet.java, ChatApplication.java as it is from below link: -
http://java.dzone.com/articles/creating-websocket-chat
i have added servlet-api.jar in my project library.
Ref. Link: - http://tech.amikelive.com/node-269/eclipse-quick-tip-resolving-error-the-import-javaxservlet-cannot-be-resolved/
Web.xml: -
I have added servlet and servlet-mapping as below:
servlet
description WebSocketChatServlet description
servlet-name WebSocketChatServlet servlet-name
servlet-class org.trivadis.websocket.servlet.WebSocketChatServlet servlet-class
servlet
servlet-mapping
servlet-name WebSocketChatServlet servlet-name
url-pattern /WebSocketChatServlet url-pattern
servlet-mapping
I am not sure what i am doing wrong....
How can i check URL i am using is correct or not for websocket.
GF location is D:\glassfish3\glassfish for my project.
Project location D:\workspace\SampleGF
Another reason: -
Even I tried WAR sample from below link: -
http://jarvana.com/jarvana/search?search_type=project&project=grizzly-websockets-chat
WAR File Name: -grizzly-websockets-chat-1.9.45.war
I have imported above war file in Eclipse and deployed it on glassfish 3.1.1 server. After running it application always call onclose event.
I have executed below command: -
asadmin set configs.config.server-config.network-config.protocols.protocol.http-listener-1.http.websockets-support-enabled=true
and I am using browser like safari and Google Chrome supports websocket (i have tested it with below link http://websocket.org/echo.html URL)
Can anyone help me out…..
It's been months since I tried to run published sample-code against grizzly. I may be out of date, but it didn't work when I tried it. The guy who published the sample eventually admitted problems in the discussion posts below his article. Since I haven't tried it since, I don't know whether it's been fixed yet; i.e. I don't have confirmation that grizzly works yet. (If someone knows of a working sample, I'm as interested as you are.)
In the mean time, you can try this alternative for running your client code. You can even check what you're doing against the free downloadable JavaScript code if you wish.
http://highlevellogic.blogspot.com/2011/09/websocket-server-demonstration_26.html
If you get your code to work against this server, then try again with grizzly. I'll be interested in the results.