How to kill the current process with java 9 - java-9

I have tried with both destroy and destroyForcibly using the below code -
ProcessHandle currentProcess = ProcessHandle.current();
System.out.println("current process id:"+currentProcess.getPid());
currentProcess.destroyForcibly();
but getting an exception in both cases as
Exception in thread "main" java.lang.IllegalStateException: destroy of
current process not allowed at
java.base/java.lang.ProcessHandleImpl.destroyProcess(ProcessHandleImpl.java:308)
at
java.base/java.lang.ProcessHandleImpl.destroyForcibly(ProcessHandleImpl.java:331)
at util.CurrentProcess.main(CurrentProcess.java:18)

Javadoc on ProcessHandle::current says:
Returns a ProcessHandle for the current process. The ProcessHandle cannot be used to destroy the current process, use System.exit instead.

Related

InsightDbProvider.RegisterProvider throwing ReflectionTypeLoadException error

I have a console project running on production server. It is kicked off via a scheduled task. I am using Insight as my ORM and I register it as follows with error I am receiving below it..
'InsightDbProvider.RegisterProvider(new OracleInsightDbProvider()); '
Description: The process was terminated due to an unhandled exception.
Exception Info:
'System.Reflection.ReflectionTypeLoadException
at System.Reflection.RuntimeModule.GetTypes(System.Reflection.RuntimeModule)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at Insight.Database.Providers.InsightDbProvider.LoadProviders()
at
Insight.Database.Providers.InsightDbProvider.RegisterProvider(Insight.Database.Providers.InsightDbProvider)'

How to get better error messaging from nightwatch when running tests in parallel

We have a problem when we run our nightwatch tests in parallel and there is a problem with the setup, for example the selenium grid is not available. The tests execute very quickly and we get no error messages.
Started child process for: folder1/test1
Started child process for: folder1/test2
Started child process for: folder1/test3
Started child process for: folder1/test4
>> folder1/test1 finished.
>> folder1/test2 finished.
>> folder1/test3 finished.
>> folder1/test4 finished.
But when I run the tests serially, I get a good error message like
Error retrieving a new session from the selenium server
Connection refused! Is selenium server started?
{ status: 13,
value: { message: 'Error forwarding the new session Empty pool of VM for setup Capabilities [{acceptSslCerts=true, name=Test1, browserName=chrome, javascriptEnabled=true, uuid=ab54872b-10ee-43a1-bf65-7676262fa647, platform=ANY}]',
class: 'org.openqa.grid.common.exception.GridException' } }
Why don't I get the good error message when running in parallel mode? Is there something I can change so I get the good error message in parallel mode?
By setting
live_output: true
in your nightwatch config file, you'll see logs while running in parallel.
More information: config-basic

AdminTask.listTCPEndPoints('abc(abc)') throws exception: ADMF0007E: target object is required

I'm working on deploying application to WebSphere 7 using python script and the script is throwing exception at this line:-
AdminTask.listTCPEndPoints('abc(abc)')
If I run the above command before I run the python script, it works fine. It gives me an error ADMF0003E: Invalid parameter value. But the same command fails in the python script with this error:
wsadmin>AdminTask.listTCPEndPoints('abc(abc)')
WASX7015E: Exception running command: "AdminTask.listTCPEndPoints('abc(abc)')"; exception information: com.ibm.websphere.management.cmdframework.CommandValidationException: ADMF0007E: target object is required.
I can guess that there something in the python script that is causing this issue, but I don't understand why is the AdminTask.listTCPEndPoints command is not able to see the parameter being passed. I'm new to WebSphere, I have only used it in past but never configured it. Any help/insight would be highly appreciated.
Thanks!
Added stack trace of interactive mode option
wsadmin>print AdminTask.listTCPEndPoints('-interactive')
List NamedEndPoints that can be used by a TCPInboundChannel
Lists all NamedEndPoints that can be associated with a TCPInboundChannel
*TCPInboundChannel: abc(abc)
excludeDistinguished (excludeDistinguished): 0
WASX7435W: Value 0 is converted to a boolean value of false.
unusedOnly (unusedOnly): 0
WASX7435W: Value 0 is converted to a boolean value of false.
List NamedEndPoints that can be used by a TCPInboundChannel
F (Finish)
C (Cancel)
Select [F, C]: [F] F
WASX7278I: Generated command line: AdminTask.listTCPEndPoints('[-excludeDistinguished false -unusedOnly false]')
WASX7015E: Exception running command: "AdminTask.listTCPEndPoints('-interactive')"; exception information:
com.ibm.websphere.management.cmdframework.CommandValidationException: ADMF0007E: target object is required.
Follow this link. It appears that you have not specified the target object that's why that error is coming.
I suggest use the following command as a starter
print AdminTask.listTCPEndPoints('-interactive')
Note: Instead of copying and pasting the command, type it on the command line. sometimes command editor does not take the command after pasting it directly.
Okay, I was able to fix the error. I was getting that error because as part of the application deployment script, I was copying few of my application jars to WebSphere's java/jre/lib/ext directory so that those are available in classpath. In one of those jar, I had bundled an IBM class (Base64Coder.class) which was required by a class in my jar and it was corrupting the WebSphere AdminTask utility. When I removed that Base64Coder.class from my jar, python script worked fine. I believe, the reason it corrupted WebSphere was that there was a duplication of the same class in the JVM as the class comes with IBM WebSphere installation and was present in AppServer/runtimes/com.ibm.ws.webservices.thinclient_7.0.0.jar

Websphere Scripting - Error while SyncNode

Below is the jacl script which I use for syncing the Node in WAS 7.
#Sync Node Changes
puts "Begin SyncNode.."
set Sync1 [$AdminControl completeObjectName type=NodeSync,process=nodeagent,node=Profile01Node600,*]
set Sync2 [$AdminControl completeObjectName type=NodeSync,process=nodeagent,node=Profile02Node601,*]
$AdminControl invoke $Sync1 sync
$AdminControl invoke $Sync2 sync
puts "SyncNode Complete"
The environment is clustered, post deployment of the EAR file, I'm invoking this jacl script to sync the changes to Nodes.
The error I get when running the script:
WASX7209I: Connected to process "dmgr" on node wAMLDmgrNode using SOAP connector; The type of process is: DeploymentManager
Begin SyncNode..
WASX7017E: Exception received while running file "xxx/xxx/xxx.jacl"; exception information: com.ibm.ws.scripting.ScriptingException: WASX7025E: Error found in String ""; cannot create ObjectName.
What is the reason for Sync1 being ''?
Do we need to use process=nodeagent in the command?
What will be the result if the nodeagent is started and stopped?
The error message:
WASX7017E: Exception received while running file "xxx/xxx/xxx.jacl"; exception information: com.ibm.ws.scripting.ScriptingException: WASX7025E: Error found in String ""; cannot create ObjectName.
... tells that the ObjectName was not found. Most likely:
your nodeagent is down
there is a typo in node name (Profile01Node600 & Profile01Node601)
You can check which nodeagents (their NodeSync MBeans) are available by running this command:
$AdminControl queryNames WebSphere:*,type=NodeSync
Based on the output you can fix the typo.
If unavailability of nodeagent is the issue, then you can cater for that in your script by checking if completeObjectName returned an empty string.

"Execution was interrupted, reason: breakpoint" when trying to print something from the Xcode console

I paused my app and tried printing something to the console. (e.g. po foo()). After doing so, I got the following message:
error: Execution was interrupted, reason: breakpoint 2.1.
The process has been returned to the state before execution.
However, there are no breakpoints in that function. Why is it showing me this error and not executing the function?
This is on Xcode 4.6.
It turns out that the breakpoint in question (2.1) was the All Exceptions breakpoint. The method I was calling raised an exception, which caused the All Exceptions breakpoint to be hit. po will stop execution once a breakpoint is reached (see this answer for more info).
If you disable the All Exceptions breakpoint and run it again, it is more clear that there was an exception:
error: Execution was interrupted, reason: signal SIGSTOP.
The process has been returned to the state before execution.
If you always leave the All Exceptions breakpoint enabled, then the message can be ambiguous: did it reach a breakpoint because there really was a breakpoint somewhere along the execution path, or was an exception raised?
An alternative solution (which doesn't require disabling the All Exceptions breakpoint) is to use expr instead of po (see the link above for a description of the following flags).
Running expr -u 0 -o -- foo() produces the following output:
error: Execution was interrupted, reason: breakpoint 2.1 -2.1.
The process has been left at the point where it was interrupted.
* thread #1: tid = [...] libobjc.A.dylib`objc_exception_throw, stop reason = breakpoint 2.1 -2.1
frame #0: [...] libobjc.A.dylib`objc_exception_throw
The objc_exception_throw string is a hint that an exception was raised.

Resources