As a developer and architect I’m working with different version of JDeveloper and WebLogic servers. Sometimes I switch version multiple times a day. Most customers have multiple deployment targets (development, QS and production) on different Weblogic servers. This make it sometimes hard to keep track of the different versions.
I searched for a way to find out which ADF Runtime is installed on a given WebLogic server. If you look at the console application or the Enterprise Manager application you’ll see no difference. Sometimes you can guess which version is running if you know which other application version is running under which server version. Still there should be a better solution.
Searching (my friend Google) the only way I found was to check the MANIFEST.MF of a specific jar on the server. As I don’t have access to a command shell on all servers this method won’t work for me. Then I stumbled upon the PrintVersion class (http://docs.oracle.com/cd/E15051_01/apirefs.1111/e10653/oracle/jbo/common/PrintVersion.html) which prints the BC4J version. A bit more digging led to the class oracle.jbo.Version which was mentioned in a really old blog entry from 2003 (http://radio-weblogs.com/0123729/stories/2003/07/10/associationConsistencyOnNondetailVos.html). This class is still available and hold information about the ADF version like the build label and BC4J version. Some of the info is stored in static final variables and only one public method Version.getAsAtring() is available.
This class is the solution I was looking for. As I couöd not build an ADF application, but needed a solution which is deployable to a managed server, I decided to implement a web service which returns the BC4J version and the build label of the ADF Runtime Library deployed ton the WebLogic server.
To make this work, I could not directly access the static final fields of the Version class. Doing this would compile the version information from the ADF Runtime Library at compile time into the web service. To access the build label which has no getter method I need to use reflection. Finally I wrote this Class
package de.hahn.blog.adfversionws; import java.lang.reflect.Field; import java.lang.reflect.Method; import javax.jws.WebMethod; import javax.jws.WebService; import oracle.jbo.Version; @WebService public class AdfVersion { public AdfVersion() { super(); } @WebMethod public String getVersion() { return Version.getAsString(); } @WebMethod public String getBuildLabel() { Class<?> cl = null; try { cl = this.getClass().getClassLoader().loadClass("oracle.jbo.Version"); } catch (ClassNotFoundException e) { e.printStackTrace(); return e.getMessage(); } Method[] lDeclaredMethods = cl.getDeclaredMethods(); Field[] lDeclaredFields = cl.getDeclaredFields(); try { Field lDeclaredField = cl.getDeclaredField("buildLabel"); String y = (String) lDeclaredField.get(lDeclaredField); return y; } catch (IllegalAccessException e3) { e3.printStackTrace(); return e3.getMessage(); } catch (NoSuchFieldException e) { e.printStackTrace(); return e.getMessage(); } } }
To make the web service independent from the Jdeveloper ADF Runtime I reference the ADF Runtime Library which is deployed on the server as shared library ‘adf.oracle.domain’. For this I created a weblogic-application.xml descriptor and add the library ref to it.
<?xml version = '1.0' encoding = 'UTF-8'?> <weblogic-application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-application http://xmlns.oracle.com/weblogic/weblogic-application/1.1/weblogic-application.xsd" xmlns="http://xmlns.oracle.com/weblogic/weblogic-application"> <library-ref> <library-name>adf.oracle.domain</library-name> </library-ref> </weblogic-application>
Now, after deployment of the EAR you can test the web service on different servers with different ADF Runtime Libraries deployed and see something like
or
The ear should be deployable on all 10.3.x WebLogic servers.
You can download the workspace (build with JDev 11.1.2.1.0) from here: blogadfversoinws-zip.doc
Please rename the file to ‘.zip’ after downloading it! There in no DB connection needed.
Hi Timo,
Nice blog. I like to know the version of the ADF.
But when I tried your code it given me bunch of errors. below is the strac trace. Can you please tell me what I need to do to resolve the issue.
The selected operation getVersion could not be invoked.
An exception occured while invoking the webservice operation. Please see logs for more details.
oracle.sysman.emSDK.webservices.wsdlapi.SoapTestException: oracle/jbo/Version
java.lang.Exception: oracle.sysman.emSDK.webservices.wsdlapi.SoapTestException: oracle/jbo/Version at oracle.sysman.emas.model.wsmgt.WSTestModel.invokeOperation(WSTestModel.java:575) at oracle.sysman.emas.view.wsmgt.WSView.invokeOperation(WSView.java:381) at oracle.sysman.emas.view.wsmgt.WSView.invokeOperation(WSView.java:298) at sun.reflect.GeneratedMethodAccessor2086.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.sun.el.parser.AstValue.invoke(AstValue.java:157) at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283) at org.apache.myfaces.trinidadinternal.taglib.util.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:53) at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcastToMethodBinding(UIXComponentBase.java:1259) at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:183) at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:90) at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:309) at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:94) at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:97) at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:90) at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:309) at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:94) at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:91) at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475) at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756) at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._invokeApplication(LifecycleImpl.java:698) at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:285) at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:177) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300) at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:97) at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:420) at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60) at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:420) at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:247) at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:157) at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.help.web.rich.OHWFilter.doFilter(Unknown Source) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.sysman.emSDK.license.LicenseFilter.doFilter(LicenseFilter.java:101) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:191) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.sysman.emas.fwk.MASConnectionFilter.doFilter(MASConnectionFilter.java:41) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:159) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.sysman.eml.app.AuditServletFilter.doFilter(AuditServletFilter.java:179) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.sysman.eml.app.EMRepLoginFilter.doFilter(EMRepLoginFilter.java:203) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.sysman.core.app.perf.PerfFilter.doFilter(PerfFilter.java:141) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.sysman.eml.app.ContextInitFilter.doFilter(ContextInitFilter.java:542) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.dms.wls.DMSServletFilter.doFilter(DMSServletFilter.java:330) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.doIt(WebAppServletContext.java:3684) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3650) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2268) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2174) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1446) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201) at weblogic.work.ExecuteThread.run(ExecuteThread.java:173) Caused by: oracle.sysman.emSDK.webservices.wsdlapi.SoapTestException: oracle/jbo/Version at oracle.sysman.emSDK.webservices.wsdlapi.dispatch.DispatchUtil.invoke(DispatchUtil.java:260) at oracle.sysman.emSDK.webservices.wsdlparser.OperationInfoImpl.invokeWithDispatch(OperationInfoImpl.java:985) at oracle.sysman.emas.model.wsmgt.PortName.invokeOperation(PortName.java:729) at oracle.sysman.emas.model.wsmgt.WSTestModel.invokeOperation(WSTestModel.java:569) … 68 more Caused by: javax.xml.ws.soap.SOAPFaultException: oracle/jbo/Version at oracle.j2ee.ws.client.jaxws.DispatchImpl.throwJAXWSSoapFaultException(DispatchImpl.java:955) at oracle.j2ee.ws.client.jaxws.DispatchImpl.invoke(DispatchImpl.java:750) at oracle.j2ee.ws.client.jaxws.OracleDispatchImpl.synchronousInvocationWithRetry(OracleDispatchImpl.java:234) at oracle.j2ee.ws.client.jaxws.OracleDispatchImpl.invoke(OracleDispatchImpl.java:105) at oracle.sysman.emSDK.webservices.wsdlapi.dispatch.DispatchUtil.invoke(DispatchUtil.java:256) … 71 more
Thanks in Advance,
Udaya
Udaya,
can you please be a bit more specific?
What exactly have you done?
Have you recompiled the source code, build an EAR out of it and deployed it to a stand alone WebLogic server?
Which jdev Version do you use?
Which version has the WebLogic Server?
Timo
Nice to have the version in the UI, but if you do have command line access the following approach also works:
[oracle@iademo oracle_common]$ export ORACLE_HOME=/oracle/ofm_new/oracle_common
[oracle@iademo oracle_common]$ OPatch/opatch lsinventory
where, for example, amongst other things it displays the string: “Oracle Application Developer 11g 11.1.1.6.0”
fyi
See also the related ADFEMG JIRA issue ADFEMG-112, “ER 12834041 : ADF RUNTIME LIBRARIES DON’T SHOW THE CORRECT VERSION NUMBERS IN WLS CONFIG.XML”
at http://java.net/jira/browse/ADFEMG-112
(or the forum message at https://forums.oracle.com/forums/thread.jspa?messageID=10697465#10697465 )
regards
Jan Vervecken
Hi Timo,
Nice blog but web service testing window showing all script/code written in editor environment.
http://myserver:7003/blogadfversoin/AdfVersionPort showing web service info but requesting
http://myserver:7003/blogadfversoin/AdfVersionPort?wsdl is showing all code in browser window.
I am unable to test.
Rashid, this is normal behavior. You can use SoapUI to test the web service or you use the WebLogic Servers test facility (like shown in the blog). Is you ask for the wsdl using a browser, you get the wsdl as xml data returned.
The blog doesn’t come with an UI for the web service. This you have to do yourself. You can use jdev to create a WebService Data Control from the web service to show the returned value in an ADF UI. However, this will only work if you have the right adf runtime installed on the server (which you try to find out!).
hi Rashid R
Alternatively you could try to deploy (and use) ADFLibrariesVersionsApp.ear available
in http://www.consideringred.com/files/oracle/2012/ADFLibrariesVersionsApp-v0.01.zip
(see also https://java.net/jira/browse/ADFEMG-112 )
success
Jan Vervecken
Pingback: Developer Cloud Service with JDeveloper 12.2.1 available | JDev & ADF Goodies