Showing posts with label glassfish. Show all posts
Showing posts with label glassfish. Show all posts

Monday, February 6, 2023

Glassfish 4.1.x create database connection

 To connect glassfish to a database, is raccomanded setup jndi data source by command line.

In order to have the setup you shoud follow this steps

Create a Connection pool

to create a connection pool you can use the command create-jdbc-connection-pool as follow

create-jdbc-connection-pool --datasourceclassname oracle.jdbc.xa.client.OracleXADataSource --restype javax.sql.XADataSource --property portNumber=1521:user=CARDIO_USR:password=CARDIO_USR:serverName=localhost:databaseName=xe:drivertype=thin:connectionAttributes=\;create\\=true HRPool

You can do the same thing usning jdbc connection url

create-jdbc-connection-pool --datasourceclassname oracle.jdbc.xa.client.OracleXADataSource --restype javax.sql.XADataSource --property password=HR:user=HR:url="jdbc\:oracle\:thin\:@//localhost\:1521/xe":connectionAttributes=\;create\\=true HRPool

Create a JNDI reference to the connection

to create a jndi resource for the connection use this command

create-jdbc-resource --connectionpoolid HRPool jdbc/HRDS

Autocommit manage

you can disable autocommit on created connection. You can do that from the administrative console

Configuration -> server-config -> JVM Settings -> JVM Options

adding the propierty:

-Doracle.jdbc.autoCommitSpecCompliant=false

N.B.

all this configurations are store on:

<Glassfish_path>\glassfish\domains\domain1\config\domain.xml

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.