Open my console as default when running the Eclipse plugin - eclipse-plugin

I am working on Eclipse plugin and for that I have need of communication with the console.
I have developed the console using this:
public void openConsole() {
MyConsole = createConsole1();
}
private IOConsole createConsole1() {
//creating a console with title Welcome to SoC Console.
IOConsole ioconsole = new IOConsole("Welcome to my Console.",null);
//adding created console to console list in console view.
ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] {ioconsole});
ConsolePlugin.getDefault().getConsoleManager().showConsoleView(ioconsole);
IOConsoleOutputStream OPstream = ioconsole.newOutputStream();
try {
OPstream.write("myConsole>");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
But after deploying it none of the console is visible in my plugin and message shows this:
No console to display at this time.
Now I need to open my console when I open the plugin instead of this.
help me if anyone know this.
Least help by you may help me a lot so please help.

Related

VS2022 - Hot reload applying changes successfully but not reflecting in app for a simple console app

I have a simple .net 6.0 console with the following code running on visual studio 2022. I change the Console.WriteLine text while the app is running and I get a log message from hot reload saying "Changes were successfully applied.". But nothing happens on my app. What am I doing wrong? I tried with and without debugger as per suggestions on other stack overflow threads. But no luck it still does not work. Here's my code.
using System;
namespace TestVS2022
{
public static class Program
{
public static void Main(string[] args)
{
while (true)
{
System.Console.WriteLine($"Hello World.");
Thread.Sleep(1000);
}
}
}
}

How to catch org.jboss.weld.context.ContextNotActiveException

I understand that this is a RuntimeException but for my usecase I need to catch it and set some attributes.
Context: I am using JPA EntityListeners for auditing and everything works fine when user accesses the application. The problem occurs when the application is accessed remotely using RemoteEJB. I am using a session object (Credentials which captures the user) in the EntityListener, so when the call is from RemoteEJB and because there is no session it fails as expected. This is the only exception I anticipate so I want to catch it and hardcode the auditing in this RemoteEJB accessing case. But somehow I am not able to catch it. I tried to catch javax.enterprise.context.ContextNotActiveException but to no avail.
public class CreateListener {
#Inject #Named("credentials") private Credentials credentials;
#PrePersist
public void setCreateAttributes(Auditable entity){
try {
entity.setCreateUserName(credentials.getUserName());
} catch (RuntimeException e) {
entity.setCreateUserName("RemoteEJB");
}
entity.setCreateTmstmp(new Date());
}
}
Environment: JDK 1.8, JBOSS EAP 7.1, hibernate-jpa-2.1-api, Hibernate 5.2.12.Final
Any help of alternative approach is appreciated.
TIA
-Avi

Velocity Unable To find Resources

This question is already asked but i am trying the same thing that is in accepted answer
protected static final String RESOURCE_LOADER = classpath.resource.loader.class";
static {
System.out.println("Velocity Initialization Started");
velocityEngine = new VelocityEngine();
velocityEngine.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
velocityEngine.setProperty(RESOURCE_LOADER,ClasspathResourceLoader.class.getName());
try {
velocityEngine.init();
} catch (Exception e) {
LOG.error("Failed to load velocity templates e={}", e);
}
}
my velocity file is in
src/main/resources/velocity/templates/command/name.vm
i am getting templates by following command
template = velocityEngine.getTemplate("velocity/templates/command/GenericState.vm");
It works locally but when bundled in jar it does not work , I have examined the jar it consist of velocity folder
i am using velocity to generated java code
I am having maven project setup and maven is creating jar
try this way it should work.
velocityEngine.setProperty(RuntimeConstants.RESOURCE_LOADER, "class,file");
velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.runtime.log.Log4JLogChute");
velocityEngine.setProperty("runtime.log.logsystem.log4j.logger", "VELLOGGER");
velocityEngine.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
velocityEngine.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
velocityEngine.init();

UWP: Can't load and show Interstitial video ad

I'm trying to monetize my app with Universal Windows. I followed the official tutorials but when I tried to load an interstitial ad, always I'm getting this errors:
Interstitial ad is not ready. With this error code: ClientConfiguration.
Failed to make http requestError. With this error code: NetworkConnectionFailure.
I don't know what I am missing.
This is my code:
public sealed partial class Myclass: Page {
InterstitialAd MyVideoAd;
public MyClass() {
this.InitializeComponent();
var MyAppId = "d25517cb-12d4-4699-8bdc-52040c712cab";
var MyAdUnitId = "11389925";
MyVideoAd = new InterstitialAd();
MyVideoAd.ErrorOccurred += MyVideoAd_ErrorOccurred;
MyVideoAd.RequestAd(AdType.Video, MyAppId, MyAdUnitId);
}
private void MyVideoAd_ErrorOccurred(object sender, AdErrorEventArgs e) {
String errrorMessage = e.ErrorMessage;
String errorCode = e.ErrorCode;
}
private void showInterstitial(object sender, TappedRoutedEventArgs e) {
MyVideoAd.Show();
}
}
When I execute the application, a few seconds after the MyVideoAd_ErrorOccurred method is launched with the values of errorMessage and errorCode as I've said. That happens on my Windows 10 mobile device and in the Desktop machine execution. The codes of adUnit and application id are the provided in the Microsoft page for tests.
I hope that you can help me.
For UWP app, please install Microsoft Universal Ad Client SDK and use AdMediatorControl.
References:
Install the Universal Ad Client SDK
Add and use the ad mediator control
Check my sample: https://github.com/Myfreedom614/UWP-Samples/tree/master/AdClientUWPApp
Be sure to have these 3 Capabilities defined inside your manifest:
<Capabilities>
...
<Capability Name="internetClient"/>
<Capability Name="internetClientServer"/>
<Capability Name="privateNetworkClientServer"/>
...
</Capabilities>
The video hasn't finished loading. you need to give it enough time for that. also you need to make sure it is loaded before calling it with.
if ((InterstitialAdState.Ready) == (MyVideoAd.State))
{
MyVideoAd.Show();
}

SoapUI jetty thread still hanging after MockService stopped [SoapUI API]

I'm using SoapUI 4.0 and i'm starting my mockservices via SoapUI API :
public static void startMockServices(String soapuiProject) throws Exception
{
WsdlProject proj = new WsdlProject(soapuiProject);
List<MockService> mockList = proj.getMockServiceList();
for (MockService mockService : mockList) {
mockService.addMockRunListener(new LogListener());
mockService.start();
}
}
public static void finishMocks() {
SoapUI.getThreadPool().shutdown();
try {
SoapUI.getThreadPool().awaitTermination(5l, TimeUnit.SECONDS);
} catch (InterruptedException e) {
e.printStackTrace();
}
SoapUI.shutdown();
}
The MockServices start well, but when I try to tear them down, the thread where jetty is running is still hanging up and my process does not finish.
I've tried to stop it via MockRunner.stop() as well but the thread still does not stop as well.
Is there any way I can stop the jetty thread so that my process finishes?
I know, better late than never.
On SoapUi 5.x.x, in the setting file, set the
con:setting id="HttpSettings#leave_mockengine to false!
In java, after, on the runner, you can set the settings file :)