Skype4Java via Scala on Mac OS - java

I'm running Mac OS 10.6, Java 1.6_17, Scala 2.8.1 final. I'm attempting to make a simple Skype call using Skype4Java by doing the following:
$>export JAVA_OPTS=-d32
$>scala -classpath .:./skype/release/skype.jar
scala> com.skype.Skype.makeCall("echotest")
I'm getting the error
"invalid attempt to access memory at location 0x0 ... bus error".
Anybody else experience this and find a solution?
Note: I'm able to use this api perfectly fine by invoking one of the samples when I run it using command line java. Attempting to execute the same sample using command line scala fails with the error above.

Try object Test { def main(args:Array[String]) { ... } }

Related

Run compiled scala 3 code give java.lang.NoClassDefFoundError: scala/util/CommandLineParser$ParseError

it may be a silly question from a scala newbie like myself.
I created the simple hello.scala using scala 3 syntax as follow:
#main def hello: Unit =
println("Hello world!")
println(msg)
def msg = "I was compiled by Scala 3. :)"
Then, compile the code using this command $scala3-compiler hello.scala. This give me the .class stuff
>hello.class
>Hello$package.class
>hello.tasty
>Hello$package.tasty
>Hello$package$.class
Finally, I try to run this compiled files using $java -cp . hello which results in the error as follow:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: scala/util/CommandLineParser$ParseError
How can I run this compiled files using java? It seems that the class CommandLineParser$ParseError is missing, but if I create the new project using $sbt new scala/scala3.g8 then $sbt run
it can be run just fine. I wonder why.
P.S. I installed the scala using coursier which give me 2 versions of scala. If I typed $scala --version it returns the 2.13.6 scala versions.

Run Java Jar within Python Google Cloud Function

I'm trying to port over some old Ruby code I used to run on Heroku to a Python-based Google Cloud Function.
This code runs Apple's Reporter tool which is "a command-line tool that you can use to download your Sales and Trends reports and Payments and Financial Reports". Docs can be found here.
The Ruby code worked well for years until yesterday, running on Heroku with a Ruby + Java build pack. A small snippet of this, where options are args received :
options = [
vendor_id,
file_type,
sub_file_type,
'Daily',
trimmed_date,
version
]
Dir.chdir("#{Rails.root}/tmp/") do
stdout, stderr, status = Open3.capture3("java -jar #{Rails.root}/public/jars/Reporter.jar p=Reporter.properties m=Robot.XML Sales.getReport #{options.join(', ')}")
return {:status => status, :error => stderr.to_s, :stdout => stdout.to_s }
end
The error I'm seeing on Heroku after no code or stack updates is Network is available but cannot connect to application. Check your proxy and firewall settings and try again.
Most of our other similar processes have been moved to Google Cloud Functions, so after getting nowhere with the above error I thought I'd move this also.
So a similar snippet this time in Python:
from subprocess import Popen, PIPE
def execute_reporter_jar(vendor_id, trimmed_date, file_type, api_version):
process = Popen(["java -jar Reporter.jar p=Reporter.properties Sales.getReportVersion Sales, Detailed"], stdin=PIPE, stdout=PIPE, shell=True)
out, err = process.communicate()
print("returncode = %s", process.returncode)
print("stdout = %s", out)
print("stderr = %s", err)
This works well locally, but when I deploy to Gooogle Cloud it seemingly runs successfully in a few ms, however, nothing actually happens and when I dig deeper it seems the subprocess is returning a 127 - command not found error. So it seems the cloud function can't access Java.
After a good 24hrs, I've hit a wall with this. Can anyone help? I have zero Java knowledge and I know cloud functions have a Java runtime, but I would prefer to stick with Python.
The ultimate aim is for Apple's reporter to run and save the requested file to Google Cloud Storage.
Thanks in advance!
The execution environment for Cloud Function's with Python runtime (both 3.7 and 3.8) is currently based in Ubuntu 18.04 (check the information in this link).
The runtime only includes the following system packages and running subprocess is usually not a recommended idea as the system packages included are limited.
If it's paramount for you to stick with Python you could try to deploy your function using the BuildPack CLI and extending the builder image to install Java on the Python runtime or if your application can be dockerized consider building an image yourself with Java included and deploying your application in Cloud Run.

How to use other python modules with jep?

I've set up a jep project within IntelliJ-IDEA, and keep getting this error when I run my code:
Exception in thread "main" jep.JepException: <class 'ModuleNotFoundError'>: No module named 'spacy'
at src/main/python\nlq_wrapper.<module>(nlq_wrapper.py:2)
at <string>.<module>(<string>:1)
at jep.Jep.exec(Native Method)
at jep.Jep.exec(Jep.java:478)
at com.siemens.nlqwrapper.NLQWrapper.load(NLQWrapper.java:37)
at com.siemens.nlqwrapper.Main.main(Main.java:9)
Even though spacy is included in my interpreter SDK packages.
Another weird thing is that the Python terminal within IntelliJ-IDEA can find and use spacy.
But when I try and run the program from the terminal or from my system's CLI, it can't find the modules and I get the same error.
Is there some extra configuration for jep that I need to do to be able to use other python modules with it? or is jep just not compatible with other modules?
EDIT
For further clarification here are the run configurations for Java and Python.
Java run configuration:
Python run configuration:
I fixed it thru this code you call before JEP interpreter:
PyConfig pyConfig = new PyConfig();
pyConfig.setPythonHome("/home/user/[NEW_PYTHON_HOME]/");
try {
MainInterpreter.setInitParams(pyConfig);
} catch (JepException e) {
e.printStackTrace();
}
Ali

The Grinder - unknown token 'timedTests'

I'm trying to run some simple tests with Grinder. I'm using the JMSReceiver script from the Script Gallery and trying to add some statistics, but my Agent throws an exception when it starts up.
A trivial example is:
from net.grinder.script.Grinder import grinder
from net.grinder.script import Test
grinder.statistics.registerSummaryExpression("foo","(/ userLong0 timedTests)")
Running this throws an exception:
...Parse exception: Unknown token 'timedTests', at character 23 of '(/ userLong0 timedTests)'
I'm using grinder-3.11, jython-2.5.3, and I'm running the above Grinder script with:
CLASSPATH=lib/jython-standalone-2.5.3.jar:lib/grinder.jar
java -classpath $CLASSPATH net.grinder.Grinder etc/grinder.properties
where grinder.properties specifies the script to run.
Java version is "1.7.0_03-icedtea", which I think is JDK 7u60 on Centos 6.3.
About 5 minutes after posting the question, I found this wiki page. I don't know if it's the version of Grinder that I'm using, but in order to get this to work I have to change
grinder.statistics.registerSummaryExpression("foo","(/ userLong0 timedTests)")
to
grinder.statistics.registerSummaryExpression("foo","(/ userLong0 (count timedTests))")
The important difference being the addition of the "count" token. This solves my problem.

Doubt in Java Service wrapper while running jar application fom window service

I have a jar application which process and converts file into csv file. I have made it to run in windows service using Java Service Wrapper. It got installed my jar application successfully when I run "InstallApp-NT. Bat" file and starts running my application when I run "app" command.
But when I try to start the service in services, its not starting and showing following message in dialog box<
Windows could not start the generic Preprocessor application on Local Computer. For more information, review the System Event Log. If this is a non-microsoft service, contact the service vendor, and refer to service-specific error code1
I have the system log file and it showing the below error message
System Event log:
--> Wrapper Started as Service
Java Service Wrapper Community Edition 3.3.2
Copyright (C) 1999-2009 Tanuki Software, Ltd. All Rights Reserved.
http://wrapper.tanukisoftware.org
Launching a JVM...
WrapperManager: Initializing...
WrapperSimpleApp:
WrapperSimpleApp: Encountered an error running main:
WrapperSimpleApp: java. Lang. NullPointerException
WrapperSimpleApp: at java. Util. Hashtable. Put(Hashtable. Java: 396)
WrapperSimpleApp: at java. Util. Properties. SetProperty(Properties. Java: 128)
WrapperSimpleApp: at java. Lang. System. SetProperty(System. Java: 701)
WrapperSimpleApp: at com. Dnb. Genericpreprocessor. Process. ProcessRunner. Main(Unknown Source)
WrapperSimpleApp: at sun. Reflect. NativeMethodAccessorImpl. Invoke0(Native Method)
WrapperSimpleApp: at sun. Reflect. NativeMethodAccessorImpl. Invoke(NativeMethodAccessorImpl. Java: 39)
WrapperSimpleApp: at sun. Reflect. DelegatingMethodAccessorImpl. Invoke(DelegatingMethodAccessorImpl. Java: 25)
WrapperSimpleApp: at java. Lang. Reflect. Method. Invoke(Method. Java: 585)
WrapperSimpleApp: at org. Tanukisoftware. Wrapper. WrapperSimpleApp. Run(WrapperSimpleApp. Java: 238)
WrapperSimpleApp: at java. Lang. Thread. Run(Thread. Java: 595)
<-- Wrapper Stopped
I don't think any error in application code because it running fine when run "app" command. Please help what I should now. Thanks in advance.
I am using the following code in com.dnb.genericpreprocessor.process.ProcessRunner class.
String projectHome = "D:\BL";
System.setProperty("project.home", projectHome);
System.setProperty("log.home",System.getenv("DBE")); ---> DBE is the envirinment variable I created in user variables.
When I run the application by giving app command... Its running the application by printing the environment value but showing the same error when I start it in service.
Answering your question update that you phrased as an answer, you need to ensure that the variable is in fact set in the specific environment where you are running the application. It appears that it is not. In fact, to avoid the NullPointerException, I would modify your code to something like:
String loghome = System.getenv("DBE");
if (loghome == null) {
// LOG A COMPLAINT that the environment variable is not set
loghome = "some reasonable default value";
}
System.setProperty("log.home", loghome);
so at least your application won't fail with an obtuse NPE if it is executed in the wrong environment.
Check com.dnb.genericpreprocessor.process.ProcessRunner if that is your code and see what data you are setting in System property. NullPointer is telling that the key or the value you passed is Null.
Check your wrapper.config; you need to have all the necessary jars in order, and each with their own index number (for some reason):
wrapper.java.classpath.1=../lib/wrapper.jar
wrapper.java.classpath.2=%JAVA_HOME%/lib/tools.jar
...
Just a first thought.
I am not familiar with the proprietary solution you are using, but it seems you somehow configured it wrong.
Looks like some parameter the wrapper should have is null and is propagating all the way up until the system is trying to set it as property.
Maybe you should put your 'DBE' enviroment in the system variables not user variables.
Windows service starts at system account.

Categories