Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Monday, October 27, 2014

How to uninstall default open jdk in Oracle Linux

When you install linux OS on either virtual machines or physical machines then it comes with open jdk version 1.6 or 1.7 or both (In my case both on oracle linux 6.5). Well this is not a problem but sometimes you required to install the products (OSB, SOA, Weblogic etc.) which is certified with different jdk vendor or version. In that case you are required to remove the open jdk and install the jdk version you required (although you can install the new jdk version without removing older one i.e. you need to set the environment variable JAVA_HOME which is pointing to new jdk).

Here are the steps:

Check JDK installation

Run the command: java -version


Removing JDK

Run the command: yum remove java*

This command will search for all the java version and will show you all the available jdk version and ask for permission if you want to remove Y/N.


Enter 'y' to remove the jdk. After that verify jdk by running the command "java -version", you will get the following out put : bash: /usr/bin/java: No such file or directory


Install the new JDK Version

Go to the following link for how to install jdk on linux


Friday, April 11, 2014

JTA transaction is not in active state: The transaction status is "MARKED_ROLLBACK".

This issue generally comes due to low value (default value i.e. 30) set for JTA transaction timeout. To solve the above problem try the following things.

Setting syncMaxWaitTime: 

1.     Login into em console i.e http://<IP>:<PORT>/em
2.     Expand SOA and right click on "soa-infra" and select SOA Administration -> BPEL Properties
3.     Click on "More BPEL configuration Properties..." link
4.     Locate syncMaxWaitTime and increase the time value.

Setting the global transaction timeout at weblogic domain

1.     Log into Oracle WebLogic Administration Console.
2.     Click Services -> JTA.   
3.     Change the value of Timeout Seconds (the default is 30).
4.      Click Save.
5.      Restart Oracle WebLogic Server.

Note: For more information please follow the document Doc ID 1524757.1  and Doc ID 880313.1 on oracle support.


Tuesday, April 8, 2014

Weblogic Webservice Test client :http://localhost:7001/wls_utc not working

When you test the webservice that you have created in java and deployed on weblogic server in the browser you will get the following error:


Reason: The possible reason could be wlstestclient.ear is not deployed on the weblogic server. So deployed the application on server.

Solution:

  1. Go to the server/lib directory i.e. \Oracle\Middleware\wlserver_10.3\server\lib
  2. In that directory search for wlstestclient.ear.
  3. Deploy this wlstestclient.ear as an application on administration server (or target on to any server).
  4. Now test the client. you will some thing like this : 


Friday, April 4, 2014

Error: could not open "\OBI_INS\lib\amd64\jvm.cfg"

I was working on installation of weblogic server and I was extracting the weblogic jar setup using the command "java -D64 -jar wls_generic_1036.jar" but I got the following error

Error: could not open "\OBI_INS\lib\amd64\jvm.cfg"

Solution

  1. Check the JAVA_HOME and Path variable in environment variables i.e the value of these variables for java is changed to "c:\'program files\java" or "c:\java". So correct the path of jdk in these variables.
  2. The files java.exe, javaw.exe and javaws.exe are copied in the folder "c"\windows\system32", so remove all those files.
  3. Now just proceed everything is on the track.

Tuesday, March 11, 2014

Webcenter Content: Java update_51 Applet Security warning : Your security setting have blocked an untrusted application from running

I have updated my java to jdk 1.7.0 update 51, while accessing the java applets I am getting the following error:

 Your security setting have blocked an untrusted application from running




Solution

  1. Go to control panel, click on Java.
  2. Click on Security tab.
  3. set the security level medium.
  4. Click on Edit Site List... and add the url i.e http://10.88.12.242
  5. Click Apply and Ok to save changes made to the java control panel.



Wednesday, March 5, 2014

Caused by : java.lang.NoClassDefFoundError: javax.xml.rpc.Service

Exception : java.lang.NoClassDefFoundError: javax.xml.rpc.Service

Reason : This exception occur while calling the webservice proxy client from java application and it is due to the missing of weblogic.jar library.

Workaround :  Add the jar file to the project classpath. you can find this jar file at

%MW_HOME%\wlserver_10.3\server\lib\weblogic.jar

or

you can add the library in jdeveloper like this





Friday, February 28, 2014

Caused by: java.lang.UnsupportedOperationException: Remote JDBC disabled

I was creating one utility in which there was interaction with database. I was passing the data source name and URL of application server (Weblogic) from the properties file and creating the database connection. But while running the program I was getting the below error:

Exception in thread "main" java.lang.UnsupportedOperationException: Remote JDBC disabled at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:234) at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:348) at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:259) at weblogic.jdbc.common.internal.RmiDataSource_1035_WLStub.getConnection(Unknown Source) at ae.dso.common.DBConn.getConnection(DBConn.java:80) at ae.dso.history.data.TaskHistoryPayload.main(TaskHistoryPayload.java:82)Caused by: java.lang.UnsupportedOperationException: Remote JDBC disabled at weblogic.jdbc.common.internal.JDBCServerHelperImpl.<clinit>(JDBCServerHelperImpl.java:36) at weblogic.jdbc.common.internal.JDBCService.initialize(JDBCService.java:91) at weblogic.jdbc.common.internal.JDBCService.start(JDBCService.java:137) at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209) at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

This error comes because your weblogic does not allow you to perform any database operation remotely. So in that case you have to enable the JDBC access in weblogic.

Solution
  1. Go to the Weblogic Domain Directory and edit the setDomainEnv.sh file i.e %MW_HOME%\user project\domains\<your domain>\bin.
  2. Modify WLS_JDBC_REMOTE_ENABLED value false to true. i.e WLS_JDBC_REMOTE_ENABLED="-Dweblogic.jdbc.remoteEnabled=true"
  3. Restart the WebLogic Servers.

Sunday, February 16, 2014

Convert java.util.HashMap into Json using Jackson API

JSON: json is a java script object notation which used as a open standard format to transmit or communicate between server and client or web application. More Info

Jackson API: It is an open source streaming API to convert java collection into the json format and back forth.

Get JacksonAPI from : http://wiki.fasterxml.com/JacksonDownload

Example to convert hashmap into json:

import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.HashMap;
import java.util.Map;
 

public class ConvertToJson {
             public static void main(String[] args) {
                 try {
                        ObjectMapper mapper = new ObjectMapper();
                    String json = "";
    
                    Map<String, HashMap> map = new HashMap<String, HashMap>();
                      HashMap<String,String> hm = new  HashMap<String,String>();
                    hm.put("fname", "Anshul");
                    hm.put("lname", "Mittal");
                    map.put("map", hm);
    
                    //convert map to JSON string
                    json = mapper.writeValueAsString(map);
    
                    System.out.println(json);
    
            } catch (Exception e) {
                    e.printStackTrace();
            }
    
        }
    }


Example to convert json into HashMap:

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.HashMap;
import java.util.Map;


public class ConvertToHashMap {
    public static void main(String[] args) {               
            String j = "{\"map\":{\"lname\":\"Mittal\",\"fname\":\"Anshul\"}}";
            JsonParser jp;
            JavaType jt;          
                          
            HashMap<String,String> map = new HashMap<String,String>();
            ObjectMapper mapper = new ObjectMapper();
           try {
                  //convert JSON string to Map
                map = mapper.readValue(j,HashMap.class);
               System.out.println(map);    
            } catch (Exception e) {
                    e.printStackTrace();
            }    
        }
}


Note : Similarly do for other collections.

Java.lang.NoClassDefFoundError: oracle.jrf.PortabilityLayerException

Exception : Java.lang.NoClassDefFoundError: oracle.jrf.PortabilityLayerException

Reason : This exception occur while deploying of ADF application from jdeveloper, and it is due to the missing jrf-api.jar.

Workaround :  Add the jar file to the project classpath. you can find this jar file at

%JDEV_HOME%\oracle_common\modules\oracle.jrf_11.1.1\jrf-api.jar

Also add this jar in the deployment profile.