#StackBounty: #javascript #java #jms #mqtt #decode How to send a jms message to activeMQ and decode it in javascript with mqttJS properly

Bounty: 50

I have a java backend, where I can send messages to topics via

jmsTemplate.convertAndSend("topic", "Hello World!");

In my javascript frontend I use mqttJS to connect to activeMQ and recieve the massage:

    let mqtt = require('mqtt')
    let options ={
        clientId:"test",
        username:"username",
        useSSL: true,
        password:"password",
        clean:true};
    let client  = mqtt.connect(
        'wss://someUrl.com:61619',
        options);

    client.on('connect', function () {
        client.subscribe('myTopic', function (err) {
            if (!err) {
                console.log("successfully connected to myTopic'");
            }
        })
    });

    client.on('message', function (topic, message) {
        console.log(message.toString());
    });

The message I recieve from the backend is something like this:

S�A S�)�x-opt-jms-destQ�x-opt-jms-msg-typeQ Ss�   f    
�/ID:myID@�topic://myTopic@@@@�  j��< St�
e Sw�  Hello World!

My message “Hello World!” is there. But also a bunch of unreadable into, I would guess from the header.

I tried different MessageConverters on the backend side and different parsers on the frontend side. Nothing works.

What do I need to do, to get just “Hello World!” as message? Or is there a better way to send the message, using jms, which is required.


Get this bounty!!!

#StackBounty: #java #mouse #games #debian Invisible mouse pointer in Java application window

Bounty: 100

I have played a Java-based game (salem the game) on Windows 7 with the Java 8 Runtime Environment, and it works properly.

However, on Debian Linux, I can launch the game, but the mouse pointer is invisible. It only blinks if I move the mouse over the login button. It works, but I can’t see it.

How do I fix it?

I tried these things:

  • Updated and upgraded system
  • Installed video firmware
  • Reinstalled Java
  • Tried emulate Java via Wine
  • Upgraded Debian to latest version (9.9)
  • Tried all possible game video settings

System Specs:

  • Debian 9.4.0 (Stretch)

  • Java version:
    • openjdk version “1.8.0_212”;
    • OpenJDK Runtime Environment (build 1.8.0_212-8u212-b01-1~deb9u1-b01);
    • OpenJDK 64-Bit Server VM (build 25.212-b01, mixed mode).

lscpi

00:00.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Device 1576
00:00.2 IOMMU: Advanced Micro Devices, Inc. [AMD] Device 1577
00:01.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Carrizo (rev e3)
00:01.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Kabini HDMI/DP Audio
00:02.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Device 157b
00:02.4 PCI bridge: Advanced Micro Devices, Inc. [AMD] Device 157c
00:03.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Device 157b
00:08.0 Encryption controller: Advanced Micro Devices, Inc. [AMD] Device 1578
00:09.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Device 157d
00:09.2 Audio device: Advanced Micro Devices, Inc. [AMD] Device 157a
00:10.0 USB controller: Advanced Micro Devices, Inc. [AMD] FCH USB XHCI Controller (rev 20)
00:11.0 SATA controller: Advanced Micro Devices, Inc. [AMD] FCH SATA Controller [AHCI mode] (rev 49)
00:14.0 SMBus: Advanced Micro Devices, Inc. [AMD] FCH SMBus Controller (rev 4a)
00:14.3 ISA bridge: Advanced Micro Devices, Inc. [AMD] FCH LPC Bridge (rev 11)
00:18.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Device 1570
00:18.1 Host bridge: Advanced Micro Devices, Inc. [AMD] Device 1571
00:18.2 Host bridge: Advanced Micro Devices, Inc. [AMD] Device 1572
00:18.3 Host bridge: Advanced Micro Devices, Inc. [AMD] Device 1573
00:18.4 Host bridge: Advanced Micro Devices, Inc. [AMD] Device 1574
00:18.5 Host bridge: Advanced Micro Devices, Inc. [AMD] Device 1575
01:00.0 USB controller: Advanced Micro Devices, Inc. [AMD] Device 43bc (rev 02)
01:00.1 SATA controller: Advanced Micro Devices, Inc. [AMD] Device 43b8 (rev 02)
01:00.2 PCI bridge: Advanced Micro Devices, Inc. [AMD] Device 43b3 (rev 02)
02:04.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] Device 43b4 (rev 02)
02:05.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] Device 43b4 (rev 02)
02:06.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] Device 43b4 (rev 02)
02:07.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] Device 43b4 (rev 02)
05:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 15)

dmesg output
https://pastebin.com/nXYtBj7Q


Get this bounty!!!

#StackBounty: #java #web-services #jersey #jersey-2.0 org.glassfish.jersey.server.ContainerException: java.lang.NoClassDefFoundError: o…

Bounty: 50

I have project in eclipse it’s an WebService Project REST API’s and i have also added another project in Configure Build path -> Add Project and i have added one another Project in my API method i am calling TestNGCreator class look below.

Basically this project uses jersey framework in java creating REST API and when i am calling any perticular method i.e. execute it will call another class which resides in another project i have added project in Build path of this project my other methods are working fine but when i am calling method from different project i having this error.

Do i need to declare some where that i am using this class and this method in POM.xml or some where else

I need to run the automation by calling this TestNGCreator.main(null);
my another project is automation project in java TestNGCreator class resides in automation project.By calling this method i need to call above class and when i am doing it i am getting error.

Error :

    May 17, 2019 4:20:51 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [Jersey Web Application] in context with path [/webservices] threw exception [org.glassfish.jersey.server.ContainerException: java.lang.NoClassDefFoundError: org/testng/TestNG] with root cause
java.lang.ClassNotFoundException: org.testng.TestNG
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1955)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1798)
    at testDrivers.TestNGCreator.runTestNGTest(TestNGCreator.java:44)
    at testDrivers.TestNGCreator.main(TestNGCreator.java:165)
    at com.xyz.webservices.Resource.executeScript(Resource.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
    at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:143)
    at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:160)
    at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:158)
    at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:97)
    at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
    at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
    at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
    at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:303)
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
    at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:286)
    at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1072)
    at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:399)
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:381)
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:344)
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:221)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:1025)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1137)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:317)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)

File : Resource.java

      @POST
      @Path("/execute")
      @Consumes(MediaType.APPLICATION_JSON)
      @Produces(MediaType.APPLICATION_JSON)
      public Response executeScript(String data) throws JSONException
        {   
            ArrayList<Object> testCases = new ArrayList<Object>();
            JSONArray jsonArray = new JSONArray();
            JSONObject json = new JSONObject(data);
            String configFile = (String) json.get("ConfigFiles");
            String sheetName = (String) json.get("Sheetname");
            jsonArray = (JSONArray) json.get("testCases");

            for (int i = 0 ; i < jsonArray.length() ; i++)
            {
                testCases.add(jsonArray.get(i));
            }

            try {
                TestNGCreator.main(null); //here  i am calling that class main method
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            Response response = null;
            System.out.println(jsonArray);
            System.out.println(testCases);
            return response;
        }

File : TestNGCreator.java

package testDrivers;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.testng.TestNG;
import org.testng.xml.XmlClass;
import org.testng.xml.XmlSuite;
import org.testng.xml.XmlTest;

import projlib.Globals;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.Iterator;

import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;

import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;

import org.apache.poi.xssf.usermodel.XSSFWorkbook;




public class TestNGCreator 
{

    public void runTestNGTest() throws IOException 
    {

            System.out.println("Print this line in console");
            //Create an instance on TestNG
            TestNG myTestNG = new TestNG();

            //Create an instance of XML Suite and assign a name for it.
            XmlSuite mySuite = new XmlSuite();
            mySuite.setName(Globals.SUITE_NAME);

            //Create a list of XmlTests and add the Xmltest you created earlier to it.
            List<XmlTest> myTests = new ArrayList<XmlTest>();

            XSSFSheet excelWSheet = null;
            XSSFWorkbook excelWBook = null;
            XSSFCell cell = null;
            XSSFRow row = null;

            Double dblCellVal;
            String strCellVal = null;
            Boolean blnCellVal;

            FileInputStream excelFile = new FileInputStream(Globals.CONFIG_FILE_DIR+"/CropRecordConfig.xlsx");
            excelWBook = new XSSFWorkbook(excelFile);
            excelWSheet = excelWBook.getSheet("CropAdd");


            Iterator <Row> rowIterator = excelWSheet.iterator(); 
            //Iterator <Cell> cellIterator = row.cellIterator();
            String testName = null;
            int colCount;

            if (rowIterator.hasNext())
            {
                row = (XSSFRow) rowIterator.next();
                colCount = row.getPhysicalNumberOfCells();
            }
            while (rowIterator.hasNext())
            {
                row = (XSSFRow) rowIterator.next();
                Iterator <Cell> cellIterator = row.cellIterator();
                int curCell = 0;
                while (cellIterator.hasNext())
                {
                    cell = (XSSFCell) cellIterator.next();
                    curCell++;
                    switch (cell.getCellType())
                    {
                    case Cell.CELL_TYPE_NUMERIC:
                        dblCellVal = cell.getNumericCellValue();
                        strCellVal = dblCellVal.toString();
                        break;
                    case Cell.CELL_TYPE_STRING:
                        strCellVal = cell.getStringCellValue();
                        break;
                    case Cell.CELL_TYPE_BOOLEAN:
                        blnCellVal = cell.getBooleanCellValue();
                        strCellVal = blnCellVal.toString();
                        break;
                    }

                    //If it is first cell then store the Test Name
                    if (cell.getColumnIndex()== 0)
                    {
                        testName = strCellVal;
                    }

                    if (curCell == 5) {
                        if (strCellVal.equals("1.0")) {
                            //Adding to suite
                            //Create an instance of XmlTest and assign a name for it.
                            XmlTest myTest = new XmlTest(mySuite);
                            myTest.setName(testName);

                            //Add any parameters that you want to set to the Test.
                            Map<String, String> testngParams = new HashMap<String,String> ();
                            testngParams.put("testId", testName);
                            myTest.setParameters(testngParams);

                            //Create a list which can contain the classes that you want to run.
                            List<XmlClass> myClasses = new ArrayList<XmlClass> ();
                            myClasses.add(new XmlClass("TestDriver"));

                            //Assign that to the XmlTest Object created earlier.
                            myTest.setXmlClasses(myClasses);

                            //Adding the test to test list created earlier
                            myTests.add(myTest);
                            break;

                        }
                    }
                }

            }

            excelWBook.close();

            //add the list of tests to your Suite.
            mySuite.setTests(myTests);

            //Add the suite to the list of suites.
            List<XmlSuite> mySuites = new ArrayList<XmlSuite>();
            mySuites.add(mySuite);

            //Set the list of Suites to the testNG object you created earlier.
            myTestNG.setXmlSuites(mySuites);

            File file = new File(Globals.TESTNG_FILE_NAME);
            System.out.println("File is: " + file);

            FileWriter writer = new FileWriter(file);
            writer.write(mySuite.toXml());
            writer.close();

            //invoke run() - this will run your class.
            //myTestNG.run();




    }
    public static void main(String args[]) throws IOException
    {
        TestNGCreator testDriver = new TestNGCreator();
        testDriver.runTestNGTest();
    }
}

File : POM.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.xyz</groupId>
    <artifactId>webservices</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>webservices</name>

    <build>
        <finalName>webservices</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <inherited>true</inherited>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.glassfish.jersey</groupId>
                <artifactId>jersey-bom</artifactId>
                <version>${jersey.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet</artifactId>
            <!-- use the following artifactId if you don't need servlet 2.x compatibility -->
            <!-- artifactId>jersey-container-servlet</artifactId -->
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
        </dependency>
        <!-- uncomment this to get JSON support-->
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-moxy</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.2</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
             <version>20080701</version>
       </dependency>
         <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.15</version>
    </dependency>

    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.15</version>
    </dependency>
    </dependencies>

    <properties>
        <jersey.version>2.16</jersey.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
</project>

Any suggestion will be appreciated thank you ^.^


Get this bounty!!!

#StackBounty: #java #postgresql #hibernate How to connect PostgreSQl view with hibernate in Java?

Bounty: 50

I do have a java web application, which does use Hibernate ORM for database connectivity. There are a lot of database tables, mainly configured as hibernate xml mapping files , i.e hbm.xml where each file is a table in the database.

Now the question is, – there are a view created with postgreSQl in the database and I want to use that view in java, how to do it? If I create another hbm.xml file that will be a table created in database. I’ve read over the internet there are examples on how to use it with annotations, but I dont have it configured in my web application.

Update1:

After some research and recommendation on below answer, this is what I have atm:

I created xml mapping file and a java class with getters/setters for each property:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
 "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"

>

<hibernate-mapping>
<class name="org.xxx.model.SearchView" table="search" mutable="false">

    <id name="uuId" column="uuid">

    </id>


    <property name="typeOfCRA" column="typeofcra" />

    <property name="birthDate" column="birthDate" />

    <property name="lastName" column="lastname" />

    <property name="firstName" column="firstname" />

    <property name="middleName" column="middlename" />

    <property name="recordId" column="recordid" />

    <property name="registrationDate" column="registrationdate" />

    <property name="state" column="state" />

    <property name="organisationunitId" column="organisationunitid" />

    <property name="version" column="version" />

    <property name="gender" column="gender" />


</class>
</hibernate-mapping>

This is how I call it in java to get a list of results from database:

Session session = sessionFactory.getCurrentSession();
Criteria criteria = session.createCriteria(SearchView.class);

criteria.add(Restrictions.like("typeofcra", "birth"));
List<SearchView> tmp =criteria.list();

It does’nt give any errors nothing. It keeps returning 0 records based on my criteria. But when I filter it out directly in Postgresql with the same criteria it returns almost 600k results.

During compilation or running this code snippet there are also 0 errors. Any help is appreciated.


Get this bounty!!!

#StackBounty: #java #arrays #byte #usb4java Convert USB keyboard data from byte array to String USB4Java

Bounty: 50

I am reading a USB Keyboard (QR Code scanner) input using usb4java.

My code snippet looks like this:

byte[] data = new byte[16];
UsbPipe usbPipe = usbEndpoint.getUsbPipe();
if (usbPipe != null) {
    if (!usbPipe.isOpen()) {
        usbPipe.open();
    }
    if (usbPipe.isOpen()) {
        UsbIrp usbIrp = usbPipe.createUsbIrp();
        usbIrp.setData(data);

I have two questions:

1] On pressing A, byte array data is 2,0,0,0,0,0,0,0,2,0,4,0,0,0,0,0
On pressing AB, byte aray data is 2,0,0,0,0,0,0,0,2,0,4,0,0,0,0,0,2,0,5,0,0,0,0,0

How to convert it into character in java? i.e. get A or AB after conversion.

2] Currently, I am passing fixed size of byte array in above code snippet. For example, if I am expecting 1 char, I am passing 16 as size of byte array, for 2 characters 24 as size and so on. Is there any other elegant solution for making it dynamic?

PS: My byte array converter snippet:

StringBuffer sb = new StringBuffer();
for (byte b : data) {
    sb.append(b);
    sb.append(",");
}
String byteString = sb.toString();
return byteString;

Thanks for any help


Get this bounty!!!

#StackBounty: #java #maven-compiler-plugin #errorprone How to exclude error prone from being run on unit tests?

Bounty: 100

When maven-compiler-plugin:3.8.0:testCompile @ foo-child runs, thread dumps show errorprone is taking an extremely long time. I believe there is a bug with errorprone, but for now I’d rather just have errorprone not run on unit tests.

I have a parent pom.xml:

<modules>
  <module>foo-child</module>
</modules>
<dependencyManagement>
  <dependency>
    <groupId>com.google.errorprone</groupId>
    <artifactId>error_prone_annotations</artifactId>
  </dependency>
  // also has dependency for io.norberg auto-matter and com.google.auto.value auto-value
</dependencyManagement>
<build>
  <plugins>
     <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        // also has annotationProcessorPaths configuration for auto-matter and auto-value
     </plugin>
  </plugins>
</build>

Is there anything I can put in the foo-child pom.xml that will allow me to exclude maven-compiler-plugin:3.8.0:testCompile @ foo-child from being run at all.

I cannot exclude error prone completely because other things like guava depend on it.


Get this bounty!!!

#StackBounty: #java #android #reflection #android-8.0-oreo How to create an Object with private creator under PIE?

Bounty: 200

This class is defined under Android:

public abstract class EGLObjectHandle {
    private final long mHandle;

    protected EGLObjectHandle(long handle) {
        mHandle = handle;
    }


    public long getNativeHandle() {
        return mHandle;
    }

}

and also

public class EGLContext extends EGLObjectHandle {
    private EGLContext(long handle) {
        super(handle);
    }

} 

now my problem is that I want to create an EGLContext with my handle. How to do this? before I do it with the function below but it’s not working anymore under PIE

  private android.opengl.EGLContext createSharedEGLContextObj(long handle) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
    Class<?> classType =Class.forName("android.opengl.EGLContext"); 
    Class<?>[] types = new Class[] { long.class };
    Constructor constructor=classType.getDeclaredConstructor(types);
    constructor.setAccessible(true);     
    Object object=constructor.newInstance(handle);
    return (android.opengl.EGLContext) object;
  }

I need an EGLContext because I need to pass it to a procedure who require an EGLContext parameter, IE: createEgl14( android.opengl.EGLContext sharedContext)


Get this bounty!!!

#StackBounty: #java #apache-spark #databricks How to detect Databricks environment programmatically

Bounty: 50

I’m writing a spark job that needs to be runnable locally as well as on Databricks.

The code has to be slightly different in each environment (file paths) so I’m trying to find a way to detect if the job is running in Databricks. The best way I have found so far was to look for a “dbfs” directory in the root dir and if it’s there then assume it’s running on Databricks. This doesn’t feel like the right solution. Does anyone have a better idea?


Get this bounty!!!

#StackBounty: #java #nginx #spring-cloud #nginx-reverse-proxy #spring-cloud-gateway Gateway timeout with Sping cloud gateway and Nginx …

Bounty: 100

I created API gateway for my application and it will act as a front controller for other microservices.
In my production setup I user Nginx as a reverse proxy for my gateway

API gateway is running on port 8080

Nginx config as below

gateway-api.conf:

server {
    listen 80;
    server_name api.example.com;
    location / {
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_pass http://localhost:30010/;
        keepalive_timeout 500s;
    }
    keepalive_timeout 500s;
    access_log /var/log/nginx/api.log;  
    error_log /var/log/nginx/api_error.log;
}

timeout setting in nginx.conf

proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
send_timeout 300;

Spring cloud gateway gradle file:

compile('org.springframework.cloud:spring-cloud-starter-gateway')
 compile('org.springframework.cloud:spring-cloud-starter-openfeign')
 compile("org.springframework.boot:spring-boot-starter-actuator")
 compile('org.springframework.boot:spring-boot-starter-security')

springBootVersion=2.0.3.RELEASE
springDMPVersion=1.0.4.RELEASE
springPlatformBomVersion=Cairo-SR2
springCloudVersion=Finchley.RELEASE

Gateway application:

@SpringBootApplication
@ComponentScan(basePackages = {"com.example"})
@EntityScan(basePackages = {"com.example"})
@EnableFeignClients(basePackages = "com.example")
public class GatewayApplication {

    public static void main(String[] args) {
        SpringApplication.run(GatewayApplication.class, args);
    }
}

Problem statement:

In one of my microservice, one REST API take more than 3 minutes to complete.
If I call this API via nginx(api.example.com), it fails exactly after 1 min and gives HTTP status 504

curl:

curl --request GET 
  --url http://api.example.com/hellomicroservice/api/take/moretime

error:

504 Timeout while reading the response from Server

No error logs in nginx and API gateway

Access log from nginx:

203.129.213.102 - - [01/Apr/2019:08:14:33 +0000] "GET hellomicroservice/api/take/moretime HTTP/1.1" 499 0 "-" "PostmanRuntime/7.3.0"

But when I make a call of the same API directly to the gateway(on gateway port 8080), request process successfully

curl with gateway port:

curl --request GET 
  --url http://api.example.com:8080/hellomicroservice/api/take/moretime

Edit:
If I apply the Nginx timeout settings as less than 60 Seconds(For example 30 seconds), the request gets timed out in a specified time interval. But if I set the Nginx timeout to be more than 60 seconds, let’s 300 Seconds, the request gets timed out after 60 seconds.


Get this bounty!!!

#StackBounty: #java #android #excel #kotlin How to create an excel with an object in Android and send it via Email

Bounty: 50

On my app I have an object of records, let’s say I have todo a quiz with more than 5 guys, so I can then get the results of all of them and I have an Object with all of that information, is it possible to convert this Object to an Excel file? For example :

|---------------------|------------------|
|        Quiz         |     Question 1   |...
|---------------------|------------------|
|      Quiz Name      |    What's 1+1    |...
|---------------------|------------------|

Something like this, to know each user what answered and its score, all of it I have it on my Object.

And then if I can send it via Mail the .xls or whatever format.

EDIT

For example I’ll need Quiz name and if I can add more about this quiz is ok, but then I need to add all of users have asked this quiz (another object from api) so I could get the name and the score.


Get this bounty!!!