Tuesday, November 29, 2022

Jdeveloper 12.2.1.4 integrated server does not shutdown on windows

 
When you shut down the ide's built-in server on windows it hangs. To solve the solution is remove comment at line in a ide configuration file.

File: ORACLE_HOME/wlserver/common/derby/derbyServer.policy

Uncomment  Line: permission java.net.SocketPermission "*", "connect,resolve";

Friday, November 25, 2022

Oracle ADF selectManyCheckbox

 The following related to Jdeveloper 12g


Sometimes you may need to create a list with many select options, that can be a selectManyCheckbox or selectManyChoiche, saving the information from this list in a single column on the db.

Luckily for us there is a simple way to halde this need.

First you need to have a db column type varchar2 with size big enough to host the string rappresented by all the ids of the list plus the separator.

Then you have to create the list of values on the View Object attribute.




In the View Object source, in the attribute's properties you should add manually <DISPLAYWIDTH Value="100"/> and modify controltype in <CONTROLTYPE Value="delimited_ids_choice"/>.




Always in the View Object source you have to insert in the listbinding tag the delimiter you'd like to have using the property Delimiter, in my case for using the comma I added Delimiter=",".




Now you have to drag and drop the attribute from the data control to the jsf/jsff as you are creating a selectOneChoice list.




Once the list is created, in the source you can change manually the component tag to selectManyCheckbox or selectManyChoiche as you wish.

I've added a valueChangeListener to study components that are involved java side:


    public void onChangeManyCheck(ValueChangeEvent valueChangeEvent) {
        RichSelectManyCheckbox rsmc = null;
        rsmc = (RichSelectManyCheckbox)valueChangeEvent.getComponent();
        System.out.println("newValue = " + valueChangeEvent.geNewValue());
        String[] keyParams = rsmc.getLabel().split(",");
        for (UIComponent c : rsmc.getChildren()) {
            System.out.println("name = " + c.getClass().getName());
            if (c instanceof UISelectItems ) {
                UISelectItems usi = (UISelectItems) c;
                System.out.println("getChildCount = " + usi.getChildCount());
                System.out.println("getValue = " + usi.getValue() + " class " + usi.getValue().getClass().getName());
                List sia = (List) usi.getValue();
                for (Object sio : sia) {
                    System.out.println("val = " + ((SelectItem) sio).getValue());
                    System.out.println("lab = " + ((SelectItem) sio).getLabel());
                }
            }
         }

The output is:

newValue = [0,1]
name= javax.faces.component.UISelectItems
getChildCount = 0
getValue = [javax.faces.model.SelectItem@f7827d7, javax.faces.model.SelectItem@62627882] class oracle.adfinternal.view.faces.model.binding.FacesCtrlListBinding$1
val = 0
lab = LABEL1
val = 1
lab = LABEL1

the value of the SelectItem in the component is not the value setted on the list of value in the business component, but is the index into the list.

The attributeValue of the binding component into the pageDef does not return a value
instead the inputValue of the binding component into the pageDef contains the index
Is necessary operate on the attributeValue by java.

At this point you have to create a List <Object> in a bean in the task flow where is located the jsf/jsff, and modify the accessors of this list in this way:

  public void setDescrizioneList(List<Object> tfList) {
        JUCtrlListBinding bindList = getAttTrAss("Descrizione");
        if (bindList != null && tfList!=null && !tfList.isEmpty()) {
            bindList.setAttributeValue(tfList.toString().replace("[", "").replace("]", "").replace(" ", ""));
        }
        else {
            bindList.setAttributeValue(null);
        }

        this.tfList = tfList;
    }
       
    public List<Object> getDescrizioneList() {
        JUCtrlListBinding bindList = getAttTrAss("Descrizione");
        tfList = new ArrayList<>();
        if (bindList != null) {
            if(bindList.getAttributeValue()!=null){
                Object[] selectedValues = bindList.getAttributeValue().toString().split(",");
                for(Object item : selectedValues){
                    if(item!=null)
                        //the list contains index of the item
                        tfList.add(Integer.paseInt(item.toString()));
                }
            }
        }
        return tfList;
    }

And you need to add this method to the same bean:
   
    private JUCtrlListBinding getAttTrAss(String name) {
            BindingContext bctx = BindingContext.getCurrent();
            BindingContainer bindings = bctx.getCurrentBindingsEntry();
            JUCtrlListBinding list = (JUCtrlListBinding) bindings.get(name);
            return list;
    }



The last step to make it work is to change the value of the list in the source of the jsf/jsff with the List<Object> of the bean we just created and to set the autosubmit property to true.



Tuesday, February 15, 2022

Install ADF Essential 12.2.1.4 on Glassfish

For Migration popuse a customer asked to me to install ADF Essential latest release on Glassfish.

There is some confusion on documentation found. Those are the main references:

first of all, install oracle jdk 1.8 latest release, and verify that it works with java -version command. Then install glassfish version to use is 4.1.x (4.1.2 in my case) avaliable at that link: https://download.oracle.com/glassfish/4.1.2/release/index.html

Download and unzip content files where do you want to install glassfish (ex. /usr/local)

You should create some enviroment variable and aliases to made maintenence easy:

export GLASSFISH_HOME = "/usr/local/glassfish4.1.2"
export GLASSFISH_DOMAIN = $GLASSFISH_HOME / glassfish / domains
export GLASSFISH_DEFAULT_DOMAIN = $GLASSFISH_DOMAIN / domain1
export GLASSFISH_DEFAULT_DOMAIN_LOG = $GLASSFISH_DEFAULT_DOMAIN / logs
export GLASSFISH_MODULES = $GLASSFISH_HOME / glassfish / modules
export GLASSFISH_LIB = $GLASSFISH_HOME / glassfish / lib
export GLASSFISH_ADF_DOMAIN_LIB = $GLASSFISH_DEFAULT_DOMAIN / lib
alias glassfishStart = '$GLASSFISH_HOME/bin/asadmin start-domain'
alias glassfishStop = '$GLASSFISH_HOME/bin/asadmin stop-domain' 

start glassfish, reset passowrd and enable secure admin

$GLASSFISH_HOME/glassfish/bin/asadmin --port 4848 change-admin-password

$GLASSFISH_HOME/glassfish/bin/asadmin --port 4848 enable-secure-admin

 

Made a flat unzip of adf essential libraries on $GLASSFISH_ADF_DOMAIN_LIB folder adding jars:

  • commonj.sdo-2.1.1.jar
  • adf-share-glassfish.jar

 this is the complete jar list that you should have in $GLASSFISH_ADF_DOMAIN_LIB:

adf-controller-security.jar
adf-share-base.jar
adf-share-ca.jar
adf-share-glassfish.jar
adf-share-multi-tenancy.jar
adf-share-security.jar
adf-share-support.jar
adflogginghandler.jar
adfsharembean.jar
com.oracle.db.jdbc-dms.jar
com.oracle.http_client.http_client.jar
com.oracle.ojsp.globaltldcache.jar
com.oracle.ojsp.web-common.jar
com.oracle.webservices.fmw.oc4j-ws-support-impl.jar
com.oracle.webservices.fmw.web-common-schemas-impl.jar
commonj.sdo.jar
commons-beanutils.jar
commons-digester3-3.2.jar
commons-logging.jar
dms.jar
jakarta-commons-el-1.jar
jakarta-commons-el.jar
javamodel-rt.jar
javatools-annotations.jar
javatools-jndi-local.jar
javatools-nodeps.jar
jrf-api.jar
jsp-el-api.jar
mdsrt.jar
oicons.jar
ojdbc8dms.jar
ojdl.jar
ojdl2.jar
oracle-el.jar
oracle.logging-utils.jar
oracle.xdb.jar
orai18n-mapping.jar
orai18n-utility.jar
orai18n.jar
org.apache.bcel_6.2.jar
resourcebundle.jar
share.jar
xmlef.jar
xmlparserv2_sans_jaxp_services.jar

Restart all and create database data source and reference.

Deploing your application, you can have on the log a warning message about GRIZZLY0013 that you can bypass

If your application use upload files you can have an error like this when you try to upload the file:

[2022-02-18T15:03:41.871+0100] [glassfish 4.1] [SEVERE] [] [org.apache.myfaces.trinidadinternal.config.upload.FileUploadConfiguratorImpl] [tid: _ThreadID=35 _ThreadName=http
-listener-2(3)] [timeMillis: 1645193021871] [levelValue: 1000] [[

java.io.EOFException
        at org.apache.myfaces.trinidadinternal.share.util.MultipartFormHandler._skipBoundary(MultipartFormHandler.java:256)
        at org.apache.myfaces.trinidadinternal.share.util.MultipartFormHandler.<init>(MultipartFormHandler.java:111)
        at org.apache.myfaces.trinidadinternal.share.util.MultipartFormHandler.<init>(MultipartFormHandler.java:84)
        at org.apache.myfaces.trinidadinternal.config.upload.FileUploadConfiguratorImpl.beginRequest(FileUploadConfiguratorImpl.java:148)
        at org.apache.myfaces.trinidadinternal.config.GlobalConfiguratorImpl._startConfiguratorServiceRequest(GlobalConfiguratorImpl.java:883)
        at org.apache.myfaces.trinidadinternal.config.GlobalConfiguratorImpl._processPhysicalRequestBegin(GlobalConfiguratorImpl.java:529)
        at org.apache.myfaces.trinidadinternal.config.GlobalConfiguratorImpl._beginRequest(GlobalConfiguratorImpl.java:508)
        at org.apache.myfaces.trinidadinternal.config.GlobalConfiguratorImpl.beginRequest(GlobalConfiguratorImpl.java:220)
        at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:193)


To resolve this refer to: https://community.oracle.com/tech/developers/discussion/3890329/java-io-eofexception-using-af-inputfile-in-adfe12-2-1-gf4-1

you should rewrite into trinidad-impl.jar file the class MultipartFormHandler, you can decompile and rewrite _parseBoundary as sugested.

substitute the 5 .class file generated into  trinidad-impl.jar and configure project to have into the war the trinidad-impl.jar modified and not the original.

Here you can find the java class modified for trinidad-impl used into 12.2.1.4 and jar (trinidad-impl.jar) file modified

 

Update on 2022/05/24

You can have this problem at runtime:

To relove you should add into $GLASSFISH_LIB a jar that contains a
oracle.adf.share.security.identitymanagement.UserProfile implementation like this.