#StackBounty: #java #android #android-activity #barcode-scanner Strange issue with intent startActivity causing my scanner to not work …

Bounty: 50

So, after I finish my scanner activity with

      btn_take_photo.setOnClickListener(new FloatingActionButton.OnClickListener() {
        @Override
        public void onClick(View view) {
            String carde = cardnumberbox.getText().toString().trim();
            if (carde.matches("")) {
                Toast.makeText(getApplicationContext(), getString(R.string.Skan_Udfyld_Kort_Nummer), Toast.LENGTH_SHORT).show();
                cardnumberbox.requestFocus();
                return;
            }
            Intent i = new Intent(ScanActivity.this, CameraActivity.class);
            i.putExtra("EXTRA_SESSION_ID", carde);
            startActivity(i);

        }
    });

to go to my cam activity so I can take some pictures and go back with

    public void btn_aprove2(View view) {
    Intent i = new Intent(CameraActivity.this, ScanActivity.class);
    String counts = count.getText().toString().trim();
    i.putExtra("EXTRA_SESSION_IDs", counts);
    String carde = cardnumberbox2.getText().toString().trim();
    i.putExtra("EXTRA_SESSION_ID", carde);
    startActivity(i);
    finish();

to the scanneractivity again. My scanner does not work properly
but if I then press the back button it does go back to the scanneractivity again instead of my menu so it seems like the scanneractivity is running twice and only 1 of them are functional but is here where it confuses me

cause if do not press the btn_aprove2 button and just use the back button instead
i gets the exact same issue but here my scanneractivity is not runned twice as when i press the back button it just takes me back to the menu

a video of the issue

by removing my screen orientation from the manifest (so i can rotate it)
my scanner do now work but only if i first rotate to landscape and rotate it back to potrait

I am totally lost on how to get this to work.

on github with api demo and documentation in the wiki and with thoose classes that are being used


Get this bounty!!!

#StackBounty: #java #jboss #jndi #tomcat8 Name [services] is not bound in this Context. Unable to find [services]

Bounty: 50

I was trying to migrate a war deployed in jboss to tomcat 8. I am facing the below exception while loading my application context xml. This was working in jboss. (Had Same issue with dataSource, but it got fixed when I configured <GlobalNamingResources/> settings in context.xml.)

Application context has

..
<jee:jndi-lookup id="txnService" jndi-name="services/TxnService"
        lazy-init="true" />

<jee:jndi-lookup id="mailService" jndi-name="services/MailService"
        lazy-init="true" expected-type="com.tone.mailservice.MailService" />
..

And error:

Caused by: javax.naming.NameNotFoundException: Name [services/MailService] is not bound in this Context. Unable to find [services].

and

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'txnService': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [services/TxnService] is not bound in this Context. Unable to find [services].      

I can see the TxnService class has the following code.

public abstract interface TxnService
{
  public static final String JNDI_NAME = "services/TxnService";
  ..
}

This class is inside a jar and i have that jar inside the lib folder.
I have tried giving java:/comp/env/services/TxnService and java:/comp/env/services/MailService instead. But still same issue.

Full trace:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mailService': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [services/MailService] is not bound in this Context. Unable to find [services].
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1482)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByName(AbstractAutowireCapableBeanFactory.java:1146)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1096)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    ... 45 more
Caused by: javax.naming.NameNotFoundException: Name [services/MailService] is not bound in this Context. Unable to find [services].
    at org.apache.naming.NamingContext.lookup(NamingContext.java:816)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:173)
    at org.apache.naming.SelectorContext.lookup(SelectorContext.java:163)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154)
    at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
    at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
    at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
    at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:104)
    at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
    at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:201)
    at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:187)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479)
    ... 54 more
Related cause:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'txnService': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [services/TxnService] is not bound in this Context. Unable to find [services].
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1482)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getTypeForFactoryBean(AbstractBeanFactory.java:1368)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryBean(AbstractAutowireCapableBeanFactory.java:720)
    at org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:523)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:356)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:334)
    at org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(BeanFactoryUtils.java:187)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:897)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:855)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:770)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:795)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:723)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:196)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1045)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:949)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
    at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:651)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:599)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:665)
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:518)
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:459)
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    at javax.servlet.GenericServlet.init(GenericServlet.java:158)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1183)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1099)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:989)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4940)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5250)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:952)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1823)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: javax.naming.NameNotFoundException: Name [services/TxnService] is not bound in this Context. Unable to find [services].
    at org.apache.naming.NamingContext.lookup(NamingContext.java:816)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:159)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:827)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:159)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:827)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:173)
    at org.apache.naming.SelectorContext.lookup(SelectorContext.java:163)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154)
    at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
    at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
    at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
    at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
    at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
    at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:201)
    at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:187)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479)
    ... 51 more


Get this bounty!!!

#StackBounty: #command-line #java #convert #conversion #format-conversion SPC to WAV command-line

Bounty: 150

For example, these types of .SPC files:
random SPC and WAV folder

I don’t want it to bring a window in the foreground, just an invisible process that will convert SPC to WAV.

executable foo/bar/input.spc bar/foo/output.wav

I’m using this in a command-line Java application, so a Java solution would be appreciated if possible. (I can use ProcessBuilder to run the executable if not.)


Get this bounty!!!

#StackBounty: #java #regex Regex to replace single quote with single quote twice if it is inside <xsl: or <XSL:

Bounty: 50

Regular Expression to replace ' with '' if it is inside <xsl: else ' should remain as it is.
Code Snippet:

public static void main(String[] args) {
        String replaceSingleQuoteInsideXsltCondition = "(<\s*?xsl\s*?:.*?=.*?)(')(.*?)(')(.*?>)";
        String dummyXSLT = "<p>Thank you for sending us <xsl:for-each select="catalog/cd[artist='Bob Dylan']"> " +
                "paper's to prove your <span class="highlight"><xsl:if test="D01 ='Y'">Income</xsl:if></span> <span class="highlight"><xsl:if test="D02 ='Y'"> and " +
                "</xsl:if></span><span class="highlight"><xsl:if test="D03 ='Y'">Citizenship and/or Identity</xsl:if></span>. " +
                "We need a little more information to finish your application. Addition of few words like 7 o'clock, employees' or employ's and child's and 'xyz and 'hello'</p>" +
                "contact number for inquiry = '478965152' and email id = 'pqr@xyz'" +
                "<xsl:template match="num[ . = 3 or . = 5]"/></xsl:stylesheet><xsl:if test="contains($search, 'Web Developer') and (contains($expSearch, 'Computer') or contains($expSearch, 'Information') or contains($expSearch, 'Web' ))">" +
                "<xsl:if test="((node/ABC!='') and (normalize-space(node/DEF)='') and (normalize-space(node/GHI)=''))"> just a dummy sample.</xsl:if>";
        System.out.println(dummyXSLT.replaceAll(replaceSingleQuoteInsideXsltCondition,  "$1''$3''$5"));
    }

Actual Result by Above Code:

<p>Thank you for sending us <xsl:for-each select="catalog/cd[artist=''Bob Dylan'']"> paper's to prove your <span class="highlight"><xsl:if test="D01 =''Y''">Income</xsl:if></span> <span class="highlight"><xsl:if test="D02 =''Y''"> and </xsl:if></span><span class="highlight"><xsl:if test="D03 =''Y''">Citizenship and/or Identity</xsl:if></span>. We need a little more information to finish your application. Addition of few words like 7 o'clock, employees' or employ's and child's and 'xyz and 'hello'</p>contact number for inquiry = '478965152' and email id = 'pqr@xyz'<xsl:template match="num[ . = 3 or . = 5]"/></xsl:stylesheet><xsl:if test="contains($search, ''Web Developer'') and (contains($expSearch, 'Computer') or contains($expSearch, 'Information') or contains($expSearch, 'Web' ))"><xsl:if test="((node/ABC!='''') and (normalize-space(node/DEF)='') and (normalize-space(node/GHI)=''))"> just a dummy sample.</xsl:if>

Expected Result:

<p>Thank you for sending us <xsl:for-each select="catalog/cd[artist=''Bob Dylan'']"> paper's to prove your <span class="highlight"><xsl:if test="D01 =''Y''">Income</xsl:if></span> <span class="highlight"><xsl:if test="D02 =''Y''"> and </xsl:if></span><span class="highlight"><xsl:if test="D03 =''Y''">Citizenship and/or Identity</xsl:if></span>. We need a little more information to finish your application. Addition of few words like 7 o'clock, employees' or employ's and child's and 'xyz and 'hello'</p>contact number for inquiry = '478965152' and email id = 'pqr@xyz'<xsl:template match="num[ . = 3 or . = 5]"/></xsl:stylesheet><xsl:if test="contains($search, ''Web Developer'') and (contains($expSearch, ''Computer'') or contains($expSearch, ''Information'') or contains($expSearch, ''Web'' ))"><xsl:if test="((node/ABC!='''') and (normalize-space(node/DEF)='''') and (normalize-space(node/GHI)=''''))"> just a dummy sample.</xsl:if>


Get this bounty!!!

#StackBounty: #java #json #rest #javafx #response The registered message body readers compatible with the MIME media type are: applicat…

Bounty: 50

I’m using Spring Rest API in server side and jersey API from client side.

I’m creating a screen where it will fetch last 5 customer redeem transaction.

From server side i’m returning list of RedeemTransactionDetails and accepting the same in client side.

I had debugged server side code it’s returns the valid list,
and in client side response code is 200 , whereas while getting
entity i’m getting error from client side.

Server side:

    @RestController
    @RequestMapping("/rest/api")
    public class CustomerRestController {
            @Autowired private CustomerService customerService;

            @RequestMapping(value="/redeemTransactionList/{clientId}/{mobileNumber}/{numOfTransaction}" , method=RequestMethod.POST , produces = "application/json; charset=UTF-8")
            public @ResponseBody List<RedeemTransactionDetails> redeemTransaction(@PathVariable(value = "clientId") int clientId, @PathVariable(value = "mobileNumber") String mobileNumber , @PathVariable(value="numOfTransaction") int numOfTransaction) {
            LOG.debug("We are in redeemTransaction method for user {} " , clientId);
            List<RedeemTransactionDetails> redeemList = null ;
            try {
                redeemList =  customerService.redeemTransactionList(clientId, mobileNumber,numOfTransaction);

            } catch (Exception e) {
                LOG.debug("Excption while fetching redeemTransaction ");
            }
            return  redeemList;
        }
    }

Client Side :

public List<RedeemTransactionDetails> getRedeemTransactions(String mobileNumber, String clientId, String numberOfTransaction) {
    log.debug("inside authenticate() ");
    List<RedeemTransactionDetails> result = null; 
    try{
        webResource = client.resource(uri + "/redeemTransactionList").path(clientId).path(mobileNumber).path(numberOfTransaction) ;
        ClientResponse response = webResource.type(MediaType.APPLICATION_JSON).post(ClientResponse.class);
        if (response.getStatus() != 200) {
            log.debug("response.getStatus() : " +  response.getStatus() );  
            throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
         } 
        response.getType() ;
        result = (List<RedeemTransactionDetails>) response.getEntity(RedeemTransactionDetails.class);
        log.debug("user Details " + result);
    }
    catch(Exception e){
        log.debug(e);
    }
    return result ;
}
}

NOTE: I had used the following dependencies in pom xml file

<dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-json</artifactId>
        <version>1.19.3</version>
    </dependency>
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.8.6</version>
</dependency>

EDIT:

ERROR LOG

SEVERE: A message body reader for Java class com.prom.via.rest.dto.RedeemTransactionDetails, and Java type class com.prom.via.rest.dto.RedeemTransactionDetails, and MIME media type application/json;charset=UTF-8 was not found
Feb 23, 2017 4:52:17 PM com.sun.jersey.api.client.ClientResponse getEntity
SEVERE: The registered message body readers compatible with the MIME media type are:
*/* ->
  com.sun.jersey.core.impl.provider.entity.FormProvider
  com.sun.jersey.core.impl.provider.entity.StringProvider
  com.sun.jersey.core.impl.provider.entity.ByteArrayProvider
  com.sun.jersey.core.impl.provider.entity.FileProvider
  com.sun.jersey.core.impl.provider.entity.InputStreamProvider
  com.sun.jersey.core.impl.provider.entity.DataSourceProvider
  com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$General
  com.sun.jersey.core.impl.provider.entity.ReaderProvider
  com.sun.jersey.core.impl.provider.entity.DocumentProvider
  com.sun.jersey.core.impl.provider.entity.SourceProvider$StreamSourceReader
  com.sun.jersey.core.impl.provider.entity.SourceProvider$SAXSourceReader
  com.sun.jersey.core.impl.provider.entity.SourceProvider$DOMSourceReader
  com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General
  com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General
  com.sun.jersey.core.impl.provider.entity.XMLRootObjectProvider$General
  com.sun.jersey.core.impl.provider.entity.EntityHolderReader


Get this bounty!!!

#StackBounty: #debian #performance #java Bad performance with Java

Bounty: 50

I have a computer that was running Windows with a lot of big programas (like Adobe Fireworks, and many other stuff) and the computer performance was really good. I decided to format my computer (I didn’t need all this programs because this computer had a different owner) and I installed Debian 8 Jessie (stable).

But since the first fresh installation, every program that needs Java to run (like NetBeans, Google Chrome, Atom (advanced text editor) or anyone) it starts consuming CPU progressively (checked via top command) until I have to reboot manually through the button (the computer is unusable, I can’t open the menu and click on Power off).

I tried using different versions of Java (7 and 8) but nothing worked. Java 7 is installed through the official repositories and version-8 through Oracle downloads official site.

Any word of advice?

EDIT 1: Java version information

lrwxrwxrwx   1 root root    24 May  6  2014 default-java -> java-1.7.0-openjdk-amd64
lrwxrwxrwx   1 root root    20 Nov  7 01:58 java-1.7.0-openjdk-amd64 -> java-7-openjdk-amd64
-rw-r--r--   1 root root  2439 Feb  7 21:22 .java-1.7.0-openjdk-amd64.jinfo
drwxr-xr-x   5 root root  4096 Jan 11 18:54 java-6-openjdk-amd64
drwxr-xr-x   8 root root  4096 Feb 21 11:10 java-7-openjdk-amd64
drwxr-xr-x   9 root root  4096 Feb  3 08:56 jdk-8-oracle-x64
-rw-r--r--   1 root root  2531 Feb  2 10:16 .jdk-8-oracle-x64.jinfo
drwxr-xr-x   2 root root  4096 Feb 21 11:12 openjdk-7

Edit 2: Java performance
Also I’ve noticed via top command that Java process also consumes a lot of CPU (more than 200%).


Get this bounty!!!

#StackBounty: #java #maven #continuous-integration #bamboo #git-flow Bamboo build plan on branches but not on develop

Bounty: 50

Context:

  • Bamboo 5.10.3
  • Gitflow branching strategy applied
  • We would like to have a certain behavior on feature branches, a different behavior on release and hotfix branches, and a third different behavior on the develop branch

Implemented (not working) approach:

  • Three different build plan
  • The first provides a regex in the “Branches” tab of the build plan (“Create plan branches for matching new branches) to only match feature and bugfix branches ((?=(feature.*|bugfix.*)).*$). Then it provides the desired behavior in its stages and jobs
  • The second one as above configured for release and hotfix branches ((?=(hotfix.*|release.*)).*$), then with its own behavior in stages
  • The third has the “Do not create plan branches” in its “Branches” control, that is, no branching, only for develop.

This works fine, each branch has its own build plan based on the desired behavior. However, when merging any branch into develop, the three build plan start in parallel, because the three of them have develop in their “Repositories” as original branch entry.

Question: how could this side effect be avoided? How could we specify a build plan for certain branch types only and not also for the original branch (in this case develop)?


I understand Bamboo needs an origin from which cloning new build plan for its branches according to a certain strategy (the regex), but how can we block it to run the build plan for the original branch as well? Or, can we define a build plan for a branch type independently than its origin and based on a dynamic name (e.g. feature-something, feature-bob)?

(On this last point: in “Repository” we can specify a branch as origin, but that’s a static value, we cannot put a regex there, which would fix the overall issue, I suppose)


Get this bounty!!!

#StackBounty: #java #jmx #tomcat8 Why can't I get JMX to run with Tomcat8 through CATALINA_OPTS?

Bounty: 50

According to https://tomcat.apache.org/tomcat-8.0-doc/monitoring.html#Introduction I should be able to active JMX by setting some env variables on CATALINA_OPTS. I’ve done this:

export CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"

Some places seem to suggest I need catalina-jmx-remote.jar in $CATALINA_OPTS/lib which I have:

$ ls -l /opt/tomcat/apache-tomcat-8.0.37/lib/catalina-jmx-remote.jar
-rw-r--r-- 1 root root 13608 Jan 18 23:05 /opt/tomcat/apache-tomcat-8.0.37/lib/catalina-jmx-remote.jar

I’ve also made sure the environment variable is properly set:

$ sudo cat /proc/20893/environ
LANG=en_USLANGUAGE=en_US:PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binHOME=/srv/tomcatLOGNAME=tomcatUSER=tomcatSHELL=TOMCAT_JAVA_HOME=/opt/java/oracle/jdk1.8.0_112CATALINA_HOME=/opt/tomcat/apache-tomcat-8.0.37CATALINA_BASE=/srv/tomcat/catalina/tomcatCATALINA_OPTS=-Djava.rmi.server.hostname=172.16.29.134 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false

Despite this, JMX is not listening on 1099 and I cannot connect to it:

$ netstat --listen | grep 1099

If I run a regular java program with:

$ java -Djava.rmi.server.hostname=172.16.29.134 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false HelloWorld

This also seems to work if I pass it as args when starting tomcat:

/opt/java/oracle/jdk1.8.0_112/bin/java 
  -Djava.util.logging.config.file=/srv/tomcat/catalina/%i/conf/logging.properties 
  -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager 
  -Djava.security.egd=file:/dev/./urandom 
  -Djava.endorsed.dirs=/opt/tomcat/apache-tomcat-8.0.37/endorsed 
  -Dcatalina.home=/opt/tomcat/apache-tomcat-8.0.37 
  -Dcatalina.base=/srv/tomcat/catalina/%i 
  -Djava.io.tmpdir=/srv/tomcat/catalina/%i/temp 
  -Djava.net.preferIPv4Stack=true 
  -Djava.rmi.server.hostname=172.16.29.134 
  -Dcom.sun.management.jmxremote.authenticate=false 
  -Dcom.sun.management.jmxremote.port=1099 
  -Dcom.sun.management.jmxremote.ssl=false 
  -classpath "/opt/tomcat/apache-tomcat-8.0.37/bin/bootstrap.jar:/opt/tomcat/apache-tomcat-8.0.37/bin/tomcat-juli.jar" 
  org.apache.catalina.startup.Bootstrap start

So why doesn’t CATALINA_OPTS get picked up like the documentation suggests? What is it I’m missing?


Get this bounty!!!

#StackBounty: #java #mysql #apache-spark #jdbc #amazon-s3 Converting mysql table to spark dataset is very slow compared to same from cs…

Bounty: 50

I have csv file in Amazon s3 with is 62mb in size (114 000 rows). I am converting it into spark dataset, and taking first 500 rows from it. Code is as follow;

DataFrameReader df = new DataFrameReader(spark).format("csv").option("header", true);
Dataset<Row> set=df.load("s3n://"+this.accessId.replace(""", "")+":"+this.accessToken.replace(""", "")+"@"+this.bucketName.replace(""", "")+"/"+this.filePath.replace(""", "")+"");

 set.take(500)

The whole operation takes 20 to 30 sec.

Now I am trying the same but rather using csv I am using mySQL table with 119 000 rows. MySQL server is in amazon ec2. Code is as follow;

String url ="jdbc:mysql://"+this.hostName+":3306/"+this.dataBaseName+"?user="+this.userName+"&password="+this.password;

SparkSession spark=StartSpark.getSparkSession();

SQLContext sc = spark.sqlContext();

DataFrameReader df = new DataFrameReader(spark).format("csv").option("header", true);
Dataset<Row> set = sc
            .read()
            .option("url", url)
            .option("dbtable", this.tableName)
            .option("driver","com.mysql.jdbc.Driver")
            .format("jdbc")
            .load();
set.take(500);

This is taking 5 to 10 minutes.
I am running spark inside jvm. Using same configuration in both cases.

My issue is not how to decrease the required time as I know in ideal case spark will run in cluster but what I can not understand is why this big time difference in the above two case?


Get this bounty!!!

#StackBounty: #opengl #java #libgdx #lwjgl LibGDX Switching to fullscreen makes sprites blurry

Bounty: 100

I’m using LibGDX to develop/render my game and when I start the game in windowed mode, then switch to full screen, the sprites look blurry. Importantly(?), starting the game in full screen then switching to windowed mode doesn’t have this problem.

Here’s a section of a screenshot starting off windowed:

enter image description here

And after switching to fullscreen, the (roughly) same section of the screen:

enter image description here

The sprites are loaded from a TextureAtlas using LibGDX’s TexturePacker. They’re rendered using a normal SpriteBatch with the default settings/shaders.
These are my pack.json settings:

{
    "pot": true,
    "paddingX": 2,
    "paddingY": 2,
    "bleed": true,
    "edgePadding": true,
    "maxWidth": 4096,
    "maxHeight": 4096,
    "duplicatePadding": false,
    "filterMin": "MipMapLinearLinear",
    "filterMag": "Linear"
}

I wondered if the filterMin/Mag might be having some effect but trying different settings is giving the same results.

To switch between fullscreen and windowed, I’m using the following code:

public static void toggleFullscreen() {
    if (DisplaySettings.isGamefullscreen && Gdx.graphics.supportsDisplayModeChange()) {
        // Switch to windowed
        Gdx.graphics.setWindowedMode(DisplaySettings.windowedWidth, DisplaySettings.windowedHeight);
        DisplaySettings.isGamefullscreen = false;
    } else if (Gdx.graphics.supportsDisplayModeChange()) {
        // Switch to full screen
        Gdx.graphics.setWindowedMode(DisplaySettings.desktopWidth, DisplaySettings.desktopHeight);
        Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
        DisplaySettings.isGamefullscreen = true;
    }
}

So in this case the game starts off windowed then toggles to fullscreen after everything has loaded/been set up.

I am using some FrameBuffers and TextureRegions to draw to, but these are disposed and recreated on a resize.

I feel like there’s some problems perhaps with the mipmaps being created and used incorrectly in this case but I’m a bit stuck at this point, any help much appreciated!


Get this bounty!!!