Create a service GlassFish - glassfish

I have a problem starting glassfishs service in windows 8.1
I got this error :
c:\glassfishv3\bin>asadmin create-service
Found the Windows Service and successfully uninstalled it.
WMI.WmiException: AccessDenied
at WMI.WmiRoot.BaseHandler.CheckError(ManagementBaseObject result)
at WMI.WmiRoot.ClassHandler.Invoke(Object proxy, MethodInfo method, Object[]
args)
at WMI.Win32ServicesProxy.Create(String , String , String , ServiceType , Err
orControl , StartMode , Boolean , String[] )
at winsw.WrapperService.Run(String[] args)
at winsw.WrapperService.Main(String[] args)
Error while trying to install GlassFish as a Windows Service.
The return value was: 2.
STDERR:
STDOUT: WMI.WmiException: AccessDenied
at WMI.WmiRoot.BaseHandler.CheckError(ManagementBaseObject result)
at WMI.WmiRoot.ClassHandler.Invoke(Object proxy, MethodInfo method, Object[]
args)
at WMI.Win32ServicesProxy.Create(String , String , String , ServiceType , Err
orControl , StartMode , Boolean , String[] )
at winsw.WrapperService.Run(String[] args)
at winsw.WrapperService.Main(String[] args)
Usage: asadmin [asadmin-utility-options] create-service [--name <name>]
[--serviceproperties <serviceproperties>]
[--dry-run[=<dry-run(default:false)>]] [--domaindir <domaindir>]
[-?|--help[=<help(default:false)>]] [domain_name]
Command create-service failed.
The user account is administrator.
I dont know what to do,Could you give me a recomendation to solve this error.

Your account may be an administrator however did you launch the cmd/shell "As Administrator"? Good old windows UAC.
I had this problem and had to right click on the cmd.exe/Command Prompt and select "Run as administrator"
Then run the: asadmin create-service --name "Glassfish YourDomainName" YourDomainName

Related

.NET Core issue: System.OperationCanceledException when hosted in IIS

My program.cs file in .NET Core 3.1 is like this I am creating web API in .net core but I am getting this error when hosted on server in IIS. API is working fine when hosted locally.
public class Program
{
public static void Main(string[] args)
{
var logger = NLogBuilder.ConfigureNLog(String.Concat(Directory.GetCurrentDirectory(), "/nlog.config")).GetLogger();
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
}).ConfigureLogging(logging =>
{
logging.ClearProviders();
logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
})
.UseNLog();
}
System.OperationCanceledException: at program.cs error
I am getting this error with stack trace like:
Description: The process was terminated due to an unhandled exception.
Exception Info: System.OperationCanceledException: The operation was canceled.
at System.Threading.CancellationToken.ThrowOperationCanceledException()
at System.Threading.CancellationToken.ThrowIfCancellationRequested()
at Microsoft.Extensions.Hosting.Internal.Host.StopAsync(CancellationToken
cancellationToken)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.WaitForShutdownAsync(IHost
host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost
host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost
host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost
host)
What is wrong here?
I am experiencing the same error, and I was trying to see what might cause it.
I came across this link with the same issue
and the thing that jumped out at me was the "non-graceful shutdown". To test, I recycled the application website on IIS, which did not trigger the error. I then tried turning off the app pool via IIS, and DID trigger the exception.
This leads me to believe it has something to do with a task running inside the application that is cut short when the non-graceful shutdown occurs.
In my case, I have a HostedService running in the background of my application, do you have something similar in yours?

Error in running default Web Application .Net Core 3

I am choosing Empty template while creating a new asp.net core web application (.net core 3) as a option.
When I run project, I face with this error
System.TypeInitializationException: 'The type initializer for 'Microsoft.Extensions.Logging.EventSource.LoggingEventSource' threw an exception.'
Stack Trace:
at Microsoft.Extensions.Hosting.Host.<>c.<CreateDefaultBuilder>b__1_2(HostBuilderContext hostingContext, ILoggingBuilder logging)
at Microsoft.Extensions.Hosting.HostingHostBuilderExtensions.<>c__DisplayClass4_1.<ConfigureLogging>b__1(ILoggingBuilder builder)
at Microsoft.Extensions.DependencyInjection.LoggingServiceCollectionExtensions.AddLogging(IServiceCollection services, Action`1 configure)
at Microsoft.Extensions.Hosting.HostingHostBuilderExtensions.<>c__DisplayClass4_0.<ConfigureLogging>b__0(HostBuilderContext context, IServiceCollection collection)
at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
at Microsoft.Extensions.Hosting.HostBuilder.Build()
at WebApplication2.Program.Main(String[] args) in D:\WebApplication2\WebApplication2\Program.cs:line 16
Stack Trace in Inner Exception:
at System.Globalization.CompareInfo.CompareString(ReadOnlySpan`1 string1, ReadOnlySpan`1 string2, CompareOptions options)
at System.Globalization.CompareInfo.Compare(String string1, String string2, CompareOptions options)
at System.Globalization.TextInfo.PopulateIsAsciiCasingSameAsInvariant()
at System.Globalization.TextInfo.ChangeCaseCommon[TConversion](String source)
at System.Globalization.TextInfo.ToUpper(String str)
at System.String.ToUpperInvariant()
at System.Diagnostics.Tracing.EventSource.GetGuid(Type eventSourceType)
at System.Diagnostics.Tracing.EventSource..ctor(EventSourceSettings settings, String[] traits)
at System.Diagnostics.Tracing.EventSource..ctor(EventSourceSettings settings)
at Microsoft.Extensions.Logging.EventSource.LoggingEventSource..cctor()
What is this and how can I resolve it.
Thanks.
The problem was solved for me when I run the application on IIS instead of IIS Express.

Is the below code correct to connect to a remote Linux host and get few tasks done using Apache Mina?

I want to switch from Jsch to Apache Mina to query remote Linux hosts and to get the few tasks done.
I need to achieve things like list files of a remote host, change directory, get file contents, put a file into the remote host etc.,
I am able to successfully connect and execute a few shell commands using session.executeRemoteCommand().
public byte[] getRemoteFileContent(String argDirectory, String fileName)
throws SftpException, IOException {
ByteArrayOutputStream stdout = new ByteArrayOutputStream();
StringBuilder cmdBuilder = new StringBuilder("cat" + SPACE + remoteHomeDirectory);
cmdBuilder.append(argDirectory);
cmdBuilder.append(fileName);
_session.executeRemoteCommand(cmdBuilder.toString(), stdout, null, null);
return stdout.toByteArray();
}
public void connect()
throws IOException {
_client = SshClient.setUpDefaultClient();
_client.start();
ConnectFuture connectFuture = _client.connect(_username, _host, portNumber);
connectFuture.await();
_session = connectFuture.getSession();
shellChannel = _session.createShellChannel();
_session.addPasswordIdentity(_password);
// TODO : fix timeout
_session.auth().verify(Integer.MAX_VALUE);
_channel.waitFor(ccEvents, 200);
}
I have the following questions,
How can I send a ZIP file to a remote host much easily in API level (not the Shell commands level)? And all other operations in API level.
Can I secure a connection between my localhost and remote through a certificate?
As of now, I am using SSHD-CORE and SSHD-COMMON version 2.2.0. Are these libraries enough or do I need to include any other libraries?
executeRemoteCommand() is stateless how can I maintain a state?
I needed sshd-sftp and its APIs to get the file transfer work.
Below code gets the proper API,
sftpClient = SftpClientFactory.instance().createSftpClient(clientSession);
On sftpClinet I called read() and write() methods get the task done. This answers my question fully.

MPI cannot execute with machine file or hosts from SSH using JSch exec channel [duplicate]

I have a piece of code which connects to a Unix server and executes commands.
I have been trying with simple commands and they work fine.
I am able to login and get the output of the commands.
I need to run an Ab-initio graph through Java.
I am using the air sandbox run graph command for this.
It runs fine, when I login using SSH client and run the command. I am able to run the graph. However, when I try to run the command through Java it gives me a "air not found" error.
Is there any kind of limit on what kind of Unix commands JSch supports?
Any idea why I'm not able to run the command through my Java code?
Here's the code:
public static void connect(){
try{
JSch jsch=new JSch();
String host="*****";
String user="*****";
String config =
"Host foo\n"+
" User "+user+"\n"+
" Hostname "+host+"\n";
ConfigRepository configRepository =
com.jcraft.jsch.OpenSSHConfig.parse(config);
jsch.setConfigRepository(configRepository);
Session session=jsch.getSession("foo");
String passwd ="*****";
session.setPassword(passwd);
UserInfo ui = new MyUserInfo(){
public boolean promptYesNo(String message){
int foo = 0;
return foo==0;
}
};
session.setUserInfo(ui);
session.connect();
String command="air sandbox run <graph-path>";
Channel channel=session.openChannel("exec");
((ChannelExec)channel).setCommand(command);
channel.setInputStream(null);
((ChannelExec)channel).setErrStream(System.err);
InputStream in=channel.getInputStream();
channel.connect();
byte[] tmp=new byte[1024];
while(true){
while(in.available()>0){
int i=in.read(tmp, 0, 1024);
if(i<0)break;
page_message=new String(tmp, 0, i);
System.out.print(page_message);
}
if(channel.isClosed()){
if(in.available()>0) continue;
System.out.println("exit-status: "+channel.getExitStatus());
break;
}
try{Thread.sleep(1000);}catch(Exception ee){}
}
channel.disconnect();
session.disconnect();
}
catch(Exception e){
System.out.println(e);
}
}
public static void main(String arg[]){
connect();
}
public String return_message(){
String ret_message=page_message;
return ret_message;
}
public static abstract class MyUserInfo
implements UserInfo, UIKeyboardInteractive{
public String getPassword(){ return null; }
public boolean promptYesNo(String str){ return false; }
public String getPassphrase(){ return null; }
public boolean promptPassphrase(String message){ return false; }
public boolean promptPassword(String message){ return false; }
public void showMessage(String message){ }
public String[] promptKeyboardInteractive(String destination,
String name,
String instruction,
String[] prompt,
boolean[] echo){
return null;
}
}
The "exec" channel in the JSch (rightfully) does not allocate a pseudo terminal (PTY) for the session. As a consequence a different set of startup scripts is (might be) sourced (particularly for non-interactive sessions, .bash_profile is not sourced). And/or different branches in the scripts are taken, based on absence/presence of the TERM environment variable. So the environment might differ from the interactive session, you use with your SSH client.
So, in your case, the PATH is probably set differently; and consequently the air executable cannot be found.
To verify that this is the root cause, disable the pseudo terminal allocation in your SSH client. For example in PuTTY, it's Connection > SSH > TTY > Don't allocate a pseudo terminal. Then, go to Connection > SSH > Remote command and enter your air ... command. Check Session > Close window on exit > Never and open the session. You should get the same "air not found" error.
Ways to fix this, in preference order:
Fix the command not to rely on a specific environment. Use a full path to air in the command. E.g.:
/bin/air sandbox run <graph-path>
If you do not know the full path, on common *nix systems, you can use which air command in your interactive SSH session.
Fix your startup scripts to set the PATH the same for both interactive and non-interactive sessions.
Try running the script explicitly via login shell (use --login switch with common *nix shells):
bash --login -c "air sandbox run sandbox run <graph-path>"
If the command itself relies on a specific environment setup and you cannot fix the startup scripts, you can change the environment in the command itself. Syntax for that depends on the remote system and/or the shell. In common *nix systems, this works:
String command="PATH=\"$PATH;/path/to/air\" && air sandbox run <graph-path>";
Another (not recommended) approach is to force the pseudo terminal allocation for the "exec" channel using the .setPty method:
Channel channel = session.openChannel("exec");
((ChannelExec)channel).setPty(true);
Using the pseudo terminal to automate a command execution can bring you nasty side effects. See for example Is there a simple way to get rid of junk values that come when you SSH using Python's Paramiko library and fetch output from CLI of a remote machine?
For a similar issues, see
Certain Unix commands fail with "... not found", when executed through Java using JSch even with setPty enabled
Commands executed using JSch behaves differently than in SSH terminal (bypasses confirm prompt message of "yes/"no")
JSch: Is there a way to expose user environment variables to "exec" channel?
Command (.4gl) executed with SSH.NET SshClient.RunCommand fails with "No such file or directory"
you could try to find out where "air" resides with
whereis air
and then use this outcome.
something like
/usr/bin/air sandbox run graph
You can use an ~/.ssh/environment file to set your AB_HOME and PATH variables.

Xaml Designer not loading

today i've installed Visual Studio Community 2015 with Update 1 and when it try to load the Xaml Designer (even of a new project) it throws an exception:
An unhandled exception has occured
System.Runtime.InteropServices.COMException
The app did not start. (Exception from HRESULT: 0x8027025B)
at
Microsoft.VisualStudio.DesignTools.HostUtility.AppPackage.AppPackageNativeMethods.IApplicationActivationManager.ActivateApplication(String appUserModelId, String activationContext, ActivateOptions options, Int32& processId)
at
Microsoft.VisualStudio.DesignTools.HostUtility.AppPackage.DesignerWrtUtility.ActivateApplication(String appUserModelId, String activationContext, Object site, Boolean isRunningElevated)
at
Microsoft.VisualStudio.DesignTools.HostUtility.Platform.AppContainerProcessDomainFactory.ActivateApplicationInternal(String appUserModelId, String activationContext, Object site)
at
Microsoft.VisualStudio.DesignTools.HostUtility.Platform.AppContainerProcessDomainFactory.CreateDesignerProcess(String applicationPath, String clientPort, Uri hostUri, IDictionary environmentVariables, Int32& processId, Object& processData)
at
Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Primitives.ProcessDomainFactory.ProcessIsolationDomain..ctor(ProcessDomainFactory factory, IIsolationBoundary boundary, AppDomainSetup appDomainInfo, IIsolationTarget isolationTarget, String baseDirectory)
at
Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Primitives.ProcessDomainFactory.CreateIsolationDomain(IIsolationBoundary boundary)
at
Microsoft.VisualStudio.DesignTools.HostUtility.Platform.AppContainerProcessDomainFactory.CreateIsolationDomain(IIsolationBoundary boundary)
at
Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Primitives.IsolationBoundary.Initialize()
at
Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Primitives.IsolationBoundary.CreateInstance[T](Type type)
at
Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.IsolatedObjectFactory.Initialize()
at
Microsoft.VisualStudio.DesignTools.DesignerHost.Services.VSIsolationService.CreateObjectFactory(IIsolationTarget isolationTarget, IObjectCatalog catalog)
at
Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.IsolationService.CreateLease(IIsolationTarget isolationTarget)
at
Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.IsolationService.CreateLease(IIsolationTarget isolationTarget)
at
Microsoft.VisualStudio.DesignTools.DesignerContract.IsolatedDesignerService.CreateLease(IIsolationTarget isolationTarget, CancellationToken cancelToken, DesignerServiceEntry& entry, IServiceProvider serviceOverrides)
at
Microsoft.VisualStudio.DesignTools.DesignerContract.IsolatedDesignerService.IsolatedDesignerView.CreateDesignerViewInfo(CancellationToken cancelToken)
at
Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.IsolatedTaskScheduler.InvokeWithCulture[T](CultureInfo culture, Func'2 func, CancellationToken cancelToken)
at
Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.IsolatedTaskScheduler.<>c__DisplayClass10_0'1.b__0()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
I had the same problem, this fixed it:
uninstall Visual Studio
uninstall all Windows SDKs/Emulators
install everything again
After that everything worked fine again.
If you're using an HP:
Delete the "Platform" environment variable in Control Panel > System > Advanced System Settings > Environment Variables [...] =HPD. (source)
If you're not using an HP, try following these steps:
Close any instance of Visual Studio
Open Visual Studio and create a new C# UWP empty project (name it whatever you want)
Run the newly created "useless" project, then close it as Visual Studio
Re-open your previous project. (source)
If you recently upgraded to the Windows 10 SDK from 10240 to 10586, then try setting the project Properties > Application > "Target version" to Windows 10 (10.0; Build 10240). (source)
Let me know if this helps!