Wednesday, 19 April 2017

ERROR [io.undertow.request] (default task-2) UT005023: Async is not supported for this request, as not all filters or Servlets were marked as supporting async


While upgrading JBOSS to Wildfly, we may observer below Exception:

"ERROR [io.undertow.request] (default task-2) UT005023: Exception handling request 
to /Sample/eventchannel: java.lang.IllegalStateException:
 UT010026: Async is not supported for this request, as not all filters or Servlets were
 marked as supporting async"

In order to avoid this error,

Upgrade the Servelet Jar version above 3.0

<dependency>
           <groupId>javax.servlet</groupId>
           <artifactId>javax.servlet-api</artifactId>
           <version>3.0.1</version>
           <scope>provided</scope>
       </dependency>


Enjoy Learning.

Upgrade JBOSS7 to Wildfly 8.1

Installations


Download Java 8 and Wildfly 8.2.0-Final on local machine

Standalone xml Changes

Location - (${JBOSS_HOME}\standalone\configuration)

Adding SSL configuration

1.       Add a new  security realm under <security-realms>
<security-realm name="SSLRealm">
                <server-identities>
                    <ssl>
                        <keystore path="${path_to_jks_file}/jboss.jks" relative-to="jboss.server.config.dir" keystore-password="changeit"/>
                    </ssl>
                </server-identities>
            </security-realm>
2.       Copy the jboss.jks inside jboss7 to ${JBOSS_HOME}\standalone\configuration
3.       Make a new entry for https listener within <server name="default-server"> , within <subsystem xmlns="urn:jboss:domain:undertow:1.2">
<https-listener name="default-ssl" socket-binding="https" security-realm="SSLRealm"/>

Adding Datasource

1.       Make a new entry for datasource within <datasources> for PV
<datasource jndi-name="java:/jdbc/datasources/pvMySQLDS" pool-name="pvMySQLDS" enabled="true">
                    <connection-url>jdbc:mysql://DB server name:3306/DB name</connection-url>
                    <driver>mysql</driver>
                    <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
                    <pool>
                        <min-pool-size>10</min-pool-size>
                        <max-pool-size>400</max-pool-size>
                    </pool>
                    <security>
                        <user-name>DB_USER</user-name>
                        <password>DB_PWD</password>
                    </security>
                    <timeout>
                        <blocking-timeout-millis>5000</blocking-timeout-millis>
                    </timeout>
                </datasource>
2.       Add a new driver for MySQL within <drivers>
<driver name="mysql" module="com.mysql">
                        <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
                    </driver>

Adding global modules

1.       Add global modules within <subsystem xmlns="urn:jboss:domain:ee:2.0">
<global-modules>
                <module name="config" slot="main"/>
                <module name="org.bouncycastle" slot="main"/>
                <module name="com.mysql" slot="main"/>
            </global-modules>
 Note:Put this change if required.

Copying dependent folders\jars


1.       Copy config folder into ${JBOSS_HOME}\modules\system\layers\base






2.       Copy mysql folder into ${JBOSS_HOME}\modules\system\layers\base\com.



Application changes


Open jboss-deployment-structure.xml and replace the existing with the following:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>

                <deployment>

                                <exclude-subsystems>
                                                <subsystem name="jaxrs" />
                                </exclude-subsystems>

                                <exclusions>
                                                <module name="javax.ws.rs.api" />
                                </exclusions>

                </deployment>
</jboss-deployment-structure>

Note: Put this change if required.


Enjoy Reading

svn: E200030: There are unfinished transactions detected in project


When you try to commit some file to SVN, you may have encountered this error,
"svn: E200030: There are unfinished transactions detected in project".

Solution to this problem:

  • Right Click on Project-->Team--->CleanUP or
  • Open CommandLine,Goto Project Directory ,run svn cleanup command.
  • Restart the eclipse.

Happy Learning.

Tuesday, 4 April 2017

Java Program to remove duplicates character from String


Sample Program:
 import java.util.LinkedHashSet;  
 import java.util.Set;  
 public class RemoveStringsDuplicates {  
      public static void main(String[] args) {  
           String string = "abcdanbcd";  
           // Convert String into char array.  
           char[] chars = string.toCharArray();  
           // Set is used to remove duplicates.  
           Set<Character> charSet = new LinkedHashSet<Character>();  
           for (char c : chars) {  
             charSet.add(c);  
           }  
           StringBuilder result = new StringBuilder(charSet.size());  
           for (Character character : charSet) {  
                result.append(character);  
           }  
           System.out.println(result.toString());  
      }  
 }  

Output:
 abcdn  

Enjoy Learning.

Convert Date Object into String Object



Sometimes we have a requirement where we need to convert the date object received from input into String object.

Sample Program:


 import java.text.DateFormat;  
 import java.text.SimpleDateFormat;  
 import java.util.Date;  
 public class ConvertDateToStringExample {  
      public static void main(String[] args) {  
           Date date=new Date();  
           DateFormat dateFormatter=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");  
           String strDate=dateFormatter.format(date);  
           System.out.println("Converted Date:" +strDate);  
      }  
 }  

Output:


Converted Date:2017-04-04 08:57:44  


Enjoy Coding.

Program to check if String contains only digits


Sample Program:


 public class CheckDigitString {  
      public static void main(String[] args) {  
           String str1="abcd";  
           String str2="abc1d";  
           String str3="11234567";  
           //provide regex pattern for digits  
           System.out.println(" String str1 :"+str1.matches("[0-9]+"));  
           System.out.println(" String str2 :"+str2.matches("[0-9]+"));  
           System.out.println(" String str3 :"+str3.matches("[0-9]+"));  
      }  
 }  

Output:


  String str1 :false  
  String str2 :false  
  String str3 :true  

Enjoy Learning.

Friday, 31 March 2017

Wildfly 8.2 Heap Issue


In Wildfly 8.2, We face out of memory error due to Heap memory gets filled.

Following configuration needs to be added in order to avoid heap issue:

Java 8 does not support Perm gen settings.Instead we need to specify MaxMetaspaceSize.

In order to run MaxMetaspaceSize,Make sure JAVA_HOME is set to JDK 1.8.

JAVA_OPTS="$JAVA_OPTS -XX:MaxMetaspaceSize=256M"

Also The memory leak work around needs to be added.

# Memory Leak issues
JAVA_OPTS="$JAVA_OPTS -Djboss.remoting.pooled-buffers=false"


Happy Learning.