how to avoid IO error while running jar as service - java

I want to run a customer script which inturn runs multiple python files from my java programs. the script runs fine when in run the jar manually from the terminal using java -jar jarfilename.jar but fails when i run the same jar as service in background.
I'm getting the following error in my debug log
Site:16 RESULT:False:Vmin test completed with no report! Something went wrong.#_#
Site:9 Traceback (most recent call last):
Site:9   File "pexpect/spawnbase.py", line 166, in read_nonblocking
Site:9 OSError: [Errno 5] Input/output error
Site:9 
Site:9 During handling of the above exception, another exception occurred:
Site:9 
Site:9 Traceback (most recent call last):
Site:9   File "pexpect/expect.py", line 111, in expect_loop
Site:9   File "pexpect/pty_spawn.py", line 485, in read_nonblocking
Site:9   File "pexpect/spawnbase.py", line 171, in read_nonblocking
Site:9 pexpect.exceptions.EOF: End Of File (EOF). Exception style platform.
Site:9 
Site:9 During handling of the above exception, another exception occurred:
Site:9 
Site:9 Traceback (most recent call last):`
The above error shows OSError: [Errno 5] Input/output error which from this link linki found it might be due to the print stattement in py file but unfortunately i don't have access to any customer file how can we handle it from java side or any thing when writing a service might fix it?

Related

IntelliJ AWS SAM UnicodeDecodeError

I'm totally new to AWS and to lambda functions. Currently, I try to start my first "Hello world" program, using IntelliJ and Java. I programmed a Lambda Function in Java using AWS. I want to start it locally with the SAM CLI Builder inside a Maven Container (because I don't have Docker).
After solving some other errors I get this one after hitting start:
SAM Build finished exceptionally: Command did not exist successfully, exit code: 1
Earlier I got a warning, that something is wrong with UTF8 so the code would be somehow platform-dependent, but I have 0 clue honestly.
Java SDK Version
15.0.2
SAM Version
1.18.1
Apache Maven Version
3.6.3
And here is a traceback of the full process:
Traceback (most recent call last):
File "runpy.py", line 194, in _run_module_as_main
File "runpy.py", line 87, in _run_code
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\__main__.py", line 12, in <module>
cli(prog_name="sam")
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 782, in main
rv = self.invoke(ctx)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\decorators.py", line 73, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\telemetry\metric.py", line 152, in wrapped
raise exception # pylint: disable=raising-bad-type
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\telemetry\metric.py", line 121, in wrapped
return_value = func(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\utils\version_checker.py", line 42, in wrapped
actual_result = func(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\build\command.py", line 160, in cli
do_cli(
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\build\command.py", line 250, in do_cli
artifacts = builder.build()
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\build\app_builder.py", line 160, in build
return build_strategy.build()
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\build\build_strategy.py", line 41, in build
result.update(self._build_functions(self._build_graph))
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\build\build_strategy.py", line 52, in _build_functions
function_build_results.update(self.build_single_function_definition(build_definition))
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\build\build_strategy.py", line 116, in build_single_function_definition
result = self._build_function(
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\build\app_builder.py", line 437, in _build_function
return build_method(config, code_dir, artifacts_dir, scratch_dir, manifest_path, runtime, options)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\build\app_builder.py", line 486, in _build_function_in_process
builder.build(
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\aws_lambda_builders\builder.py", line 125, in build
return workflow.run()
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\aws_lambda_builders\workflow.py", line 58, in wrapper
valid_path = binary_checker.validator.validate(executable_path)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\aws_lambda_builders\workflows\java_maven\maven_validator.py", line 33, in validate
jvm_mv = self._get_major_version(maven_path)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\aws_lambda_builders\workflows\java_maven\maven_validator.py", line 51, in _get_major_version
vs = self._get_jvm_string(maven_path)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\aws_lambda_builders\workflows\java_maven\maven_validator.py", line 69, in _get_jvm_string
l_dec = l.decode()
**UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfc in position 25: invalid start byte
SAM Build finished exceptionally: Command did not exist successfully, exit code: 1**
You can write Lambda functions using the Java runtime API and IntelliJ. You can build a JAR file and deploy the Lambda function by using the Lambda console. Once you deploy the Lambda function, you can test it from the Lambda console.
You can log messages to Cloud Watch logs. Using the Lambda java runtime API in the IntelliJ IDE, you will avoid these exceptions. You will code your logic and deploy the JAR file, and it works.
In addition, you can easily use additional AWS Java APIs to invoke AWS services from the Lambda function.
To see a step by step AWS dev article that creates a Lambda function using the Lambda runtime API, see:
Creating scheduled events to invoke Lambda functions

pyjnius "cannot find class" error

I am trying to make a Bluetooth app with Kivy so I need to use java classes, I get this error message when I use Pyjnius
Traceback (most recent call last):
File "C:\Users\Omer Akbas\Desktop\My Apps (Kivy)\First\main.py", line 3, in
<module>
BluetoothAdapter = autoclass('android.bluetooth.BluetoothAdapter')
File "C:\Python27\lib\site-packages\jnius\reflect.py", line 158, in
autoclass
c = find_javaclass(clsname)
File "jnius\jnius_export_func.pxi", line 25, in jnius.find_javaclass
JavaException: Class not found 'android/bluetooth/BluetoothAdapter'
If you're building a Kivy app, pyjnius is installed in the APK automatically as a dependency of Kivy, so you don't have to do anything special beyond the normal Programming Guide » Create a package for Android documentation.

Google cloud endpoints generate Java api HTTP 400 error

Hey im trying to develop a rest API by using this doc go-endpoints
I can test my app locally and on the app engine .
But i cant create a Java client in order to consume it on android device,
for some reason I'm getting an
HTTP 400 No JSON object could be decoded
on this command
GO_SDK/endpointscfg.py gen_client_lib java MY_FILE_NAME
This is the full stack trace
mik#mik-Aspire-S3:~/go-programs/src/cloudEndPoints/app$ $HOME/go_appengine/endpointscfg.py gen_client_lib java ballota_test
Traceback (most recent call last):
File "/home/mik/go_appengine/endpointscfg.py", line 133, in <module>
run_file(__file__, globals())
File "/home/mik/go_appengine/endpointscfg.py", line 129, in run_file
execfile(_PATHS.script_file(script_name), globals_)
File "/home/mik/go_appengine/google/appengine/tools/endpointscfg.py", line 561, in <module>
main(sys.argv)
File "/home/mik/go_appengine/google/appengine/tools/endpointscfg.py", line 557, in main
args.callback(args)
File "/home/mik/go_appengine/google/appengine/tools/endpointscfg.py", line 458, in _GenClientLibCallback
args.build_system)
File "/home/mik/go_appengine/google/appengine/tools/endpointscfg.py", line 335, in _GenClientLib
build_system, client_name)
File "/home/mik/go_appengine/google/appengine/tools/endpointscfg.py", line 366, in _GenClientLibFromContents
raise ServerRequestException(error)
__main__.ServerRequestException: HTTP 400 (Bad Request) error when communicating with URL: https://google-api-client-libraries.appspot.com/generate. Details: ill-formed JSON: No JSON object could be decoded
UPDATE
I tried to built this sample project tictactoe as a Java client and i got the same error
I posted an issue in
crhym3 cloud endpoints example and he helped my to understand my error.
My mistake was that i tried to create the client with the wrong URL address .
This is the wrong address.
https://winged-precept-894.appspot.com this will return 404
And this is the correct discovery api URL.
https://winged-precept-894.appspot.com/_ah/api/discovery/v1/apis/myapp/v1/rpc
So it was a url error and not a Json oriented error .

"No module named _cairo" using Jython 2.7

I am trying to use python's charting library from my java project using jython. In my script I use module cairo.
pythonInterpreter.exec("import sys");
pythonInterpreter.exec("import cairo");
Exception throws on the second line, because cairo's init.py contains string:
from _cairo import *
The exception I get is:
Caused by: Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/cairo/__init__.py", line 1, in <module>
from _cairo import *
ImportError: No module named _cairo
Also, I can use my script from console, so I doubt that it has an error in it. I suppose something is wrong with the way I'm importing cairo in Java.
I got it now. Jython can't execute 'native' libraries, such as cairo (I'm, sure it's native, because _cairo is a .so file, which means it's a C lib)

I need help to set up Reddit API

I tried to set up the Reddit API in Linux Mint 16, so that I can use it in IntelliJ 13.1.2/Java.
So I used this guide: https://github.com/reddit/reddit/wiki/Install-guide
and started with
$ git clone https://github.com/reddit/reddit.git
next I went to r2
$ cd reddit/r2
, but when I tried to do the next 3 lines:
$ python setup.py build
$ sudo python setup.py develop
$ make
my console gave out
Traceback (most recent call last):
File "setup.py", line 35, in <module>
pkg_resources.require("distribute>=0.6.16")
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 696, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 594, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: distribute>=0.6.16
respectively
Traceback (most recent call last):
File "setup.py", line 35, in <module>
pkg_resources.require("distribute>=0.6.16")
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 696, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 594, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: distribute>=0.6.16
and in the end at the "make" command the console gave out:
Traceback (most recent call last):
File "Makefile.py", line 24, in <module>
from r2.lib.translation import I18N_PATH
File "/home/fox/reddit/r2/r2/lib/translation.py", line 28, in <module>
from babel.messages.extract import extract_javascript
ImportError: No module named babel.messages.extract
Makefile:41: *** Makefile.py failed. aborting. Schluss.
And now I don't have any clue what I should do. It's the first time I use a API and have zero experience with this. It would be very nice if someone of you could help me.
I had the same problem and solved it by running :
easy_install distribute

Categories

Resources