Saturday, September 29, 2012

Oracle SOA: Huh, how to resolve "Get initiable processes error BPM-70805" or how to remove damaged composite

In my case the error appears after restart of SOA managed server, when composite wasn't loaded successfully because of problem with one of webservices. After the first crash, composite could not be restored, even though the web service already works.

In SOA diagnostic log I found:

[2012-09-28T19:30:00.511+02:00] [SOA] [ERROR] [] [oracle.bpm.services.processMetadata] [tid: [ACTIVE].ExecuteThread: '7' for queue: 'weblogic.kernel.Default (self-tuning)'] [ecid: e9b6dbbc873f2b62:5a4cf738:139e3511bb4:-8000-000000000002d0f3,1:35137] [APP: soa-infra] Exception[[
exception.70805.type: error
exception.70805.severity: 2
exception.70805.name: Error getting initiable processes list for selected BPMContext
exception.70805.description: Error getting initiable processes list for selected BPMContext
exception.70805.fix: Error getting initiable processes list for selected BPMContext.

 ORABPEL-30017


Invalid task definition.

The task definition at 
default/procesTest!1.4*soa_ab8d7806-2433-4ce6-8457-d4c40ff2b4d2/firstStep
 could not be read. The task definition is associated with workflow default/procesTest!1.4*soa_ab8d7806-2433-4ce6-8457-d4c40ff2b4d2/ .

Make sure that the task definition is available at the specified URL and that it is a valid XML document.

    at oracle.bpel.services.workflow.metadata.impl.TaskMetadataCache.getTaskDefinition(TaskMetadataCache.java:339)
    at oracle.bpel.services.workflow.metadata.impl.TaskMetadataService.getTaskDefinitionById(TaskMetadataService.java:190)
    at oracle.bpel.services.workflow.metadata.impl.TaskMetadataService.getTaskDefinitionById(TaskMetadataService.java:205)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
    at oracle.bpel.services.workflow.common.WorkflowServiceCacheEventAdvice.invoke(WorkflowServiceCacheEventAdvice.java:91)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at oracle.bpel.services.workflow.test.workflow.ExceptionTestCaseBuilder.invoke(ExceptionTestCaseBuilder.java:155)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    at $Proxy245.getTaskDefinitionById(Unknown Source)
    at oracle.bpel.services.workflow.metadata.ejb.TaskMetadataServiceBean.getTaskDefinitionById(TaskMetadataServiceBean.java:58)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
    at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:37)
    at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54)
    at com.bea.core.repackaged.springframework.jee.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:50)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    at $Proxy306.getTaskDefinitionById(Unknown Source)
    at oracle.bpel.services.workflow.metadata.ejb.TaskMetadataServiceBean_kykm8_EOImpl.__WL_invoke(Unknown Source)
    at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:40)
    at oracle.bpel.services.workflow.metadata.ejb.TaskMetadataServiceBean_kykm8_EOImpl.getTaskDefinitionById(Unknown Source)
    at oracle.bpm.services.processmetadata.impl.ProcessMetadataService.getInitiatableProcesses(ProcessMetadataService.java:646)
    at sun.reflect.GeneratedMethodAccessor36781.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
    at oracle.bpel.services.workflow.common.WorkflowServiceCacheEventAdvice.invoke(WorkflowServiceCacheEventAdvice.java:91)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    at $Proxy239.getInitiatableProcesses(Unknown Source)
    at oracle.bpm.services.processmetadata.ejb.ProcessMetadataServiceBean.getInitiatableProcesses(ProcessMetadataServiceBean.java:151)
    at sun.reflect.GeneratedMethodAccessor44411.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
    at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:37)
    at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54)
    at com.bea.core.repackaged.springframework.jee.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:50)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    at $Proxy268.getInitiatableProcesses(Unknown Source)
    at oracle.bpm.services.processmetadata.ejb.ProcessMetadataServiceBean_fasv2m_ProcessMetadataServiceRemoteImpl.__WL_invoke(Unknown Source)
    at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:40)
    at oracle.bpm.services.processmetadata.ejb.ProcessMetadataServiceBean_fasv2m_ProcessMetadataServiceRemoteImpl.getInitiatableProcesses(Unknown Source)
    at oracle.bpm.services.processmetadata.ejb.ProcessMetadataServiceBean_fasv2m_ProcessMetadataServiceRemoteImpl_WLSkel.invoke(Unknown Source)
    at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:667)
    at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
    at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:522)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
    at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:518)
    at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
Caused by: ORABPEL-30017

Invalid task definition.

The task definition at 
default/procesTest!1.4*soa_ab8d7806-2433-4ce6-8457-d4c40ff2b4d2/firstStep

 could not be read. The task definition is associated with workflow null .

Make sure that the task definition is available at the specified URL and that it is a valid XML document.

    at oracle.bpel.services.workflow.fabric.WorkflowServiceEngine.getTaskDefinition(WorkflowServiceEngine.java:2212)
    at oracle.bpel.services.workflow.metadata.impl.TaskMetadataCache.getTaskDefinition(TaskMetadataCache.java:334)
    ... 85 more
Caused by: ORABPEL-30084


    at oracle.bpel.services.workflow.fabric.WorkflowServiceEngine.getComponentModel(WorkflowServiceEngine.java:2582)
    at oracle.bpel.services.workflow.fabric.WorkflowServiceEngine.getTaskDefinition(WorkflowServiceEngine.java:2204)
    ... 86 more

]]

I have tried several ways to resuscitation of my workflow, but because of lack of time finally I decided to redeploy the composite (and remove the old version). 

And here was a next surprise: composite could not be undeployed. Of course because of next errors, but it does not matter...

The question was: how to remove damaged composite ?

I have tried to change some entries in my SOAINFRA schema in database, but without success. Finally I found a solution that was easier than I expected before. To remove composite I needed only modify some values in metadata store of soa-infra. How do this in next post:)

Thursday, September 20, 2012

ADF How to: resolving problem with af:inlineFrame source (url) in ADF Portlet

When you want to use af:inlineFrame component in portletized application, you will encounter problem with source parameter. By default, URLs in the portletized page or task flow are encoded / rewrited by ADF Portlet Bridge, and if you want to point to remote adress, the behaviour of your page will be unpredictable.

If you don't want to encode these URLs, you can do this by setting the _xEncodeUrl parameter to false on URLs that are passed to the Oracle JSF Portlet Bridge for encoding.

By example:

<af:inlineframe id="if1" 
  shortdesc="My UCM document rendition" 
    source="http://my-custom-server/doc?q=4732847239847&amp;_xEncodeUrl=false">
</af:inlineframe>

Wednesday, September 19, 2012

Webcenter Spaces: oracle.mds.core.MetadataNotFoundException: MDS-00013: no metadata found for metadata object

This strange error appears sometomes after redeploying WSRP portlet and when this portlet is consumend by Webcenter Spaces or Webcenter Portal.

[2012-09-19T13:48:50.799+02:00] [WC_Spaces] [ERROR] [] [oracle.portlet.binding] [tid: [ACTIVE].ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: weblogic] [ecid: e9b6dbbc873f2b62:16e90ad0:139dd9e5e52:-8000-0000000000002906,0] [APP: webcenter#11.1.1.4.0]  An error has occured for binding portlet portlet7035644851.[[

oracle.adf.model.portlet.binding.PortletBindingException: The metadata for portlet binding portlet7035644851 was not found in MDS :

    at oracle.adf.model.portlet.binding.PortletBinding._initModel(PortletBinding.java:484)

    at oracle.adf.model.portlet.binding.PortletBinding.initModel(PortletBinding.java:913)

   at oracle.adf.model.portlet.binding.PortletBinding.getPortletModel(PortletBinding.java:541)

    at oracle.adf.model.portlet.binding.PortletBinding.prepareRenderPhase(PortletBinding.java:394)

    at oracle.adf.model.portlet.binding.PortletBinding._refresh(PortletBinding.java:330)

    at oracle.adf.model.portlet.binding.PortletBinding.refresh(PortletBinding.java:922)

    at oracle.adf.model.binding.DCBindingContainer.internalRefreshControl(DCBindingContainer.java:3271)

    at oracle.adf.model.binding.DCBindingContainer.refresh(DCBindingContainer.java:2874)

    at oracle.adf.controller.v2.lifecycle.PageLifecycleImpl.prepareRender(PageLifecycleImpl.java:561)

    at oracle.adf.controller.faces.lifecycle.FacesPageLifecycle.prepareRender(FacesPageLifecycle.java:81)

    at oracle.adf.controller.v2.lifecycle.Lifecycle$9.execute(Lifecycle.java:224)

    at oracle.adfinternal.controller.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:197)

   

...

 Caused by: oracle.portlet.client.persistence.PersistenceNotFoundException: mdsId=/oracle/adf/portlet/scopedMD/s1fbe8801_cf19_4970_a002_0582c5baf1e6/portlets/MyPortlet_b7c97a45_87d8_4860_844b_b05af20d88e0.pxml not found

    at oracle.portlet.client.persistenceimpl.mds.MDSPersistenceContext.getInternal(MDSPersistenceContext.java:649)

    at oracle.portlet.client.persistenceimpl.mds.MDSPersistenceContext.get(MDSPersistenceContext.java:604)

    at oracle.portlet.client.beanimpl.persistence.PersistenceBeanFactory.getExisting(PersistenceBeanFactory.java:249)

    at oracle.portlet.client.beanimpl.persistence.PersistenceBeanContext.getExisting(PersistenceBeanContext.java:110)

    at oracle.portlet.client.containerimpl.PublicFactoryImpl.get(PublicFactoryImpl.java:300)

    at oracle.portlet.client.containerimpl.PublicFactoryImpl.get(PublicFactoryImpl.java:310)

    at oracle.portlet.client.containerimpl.PortletContainerImpl.getById(PortletContainerImpl.java:345)

    at oracle.portlet.client.containerimpl.PortletContainerImpl.getPortlet(PortletContainerImpl.java:267)

    at oracle.adfinternal.model.portlet.binding.PortletModelImpl.init(PortletModelImpl.java:380)

    at oracle.adf.model.portlet.binding.PortletBinding$InnerPortletModel.init(PortletBinding.java:1101)

    at oracle.adfinternal.model.portlet.binding.ActivityPortletModelWrapper.init(ActivityPortletModelWrapper.java:112)

    at oracle.adf.model.portlet.binding.PortletBinding._initModel(PortletBinding.java:471)

    ... 87 more

Caused by: oracle.mds.core.MetadataNotFoundException: MDS-00013:  no metadata found for metadata object "/oracle/adf/portlet/scopedMD/s1fbe8801_cf19_4970_a002_0582c5baf1e6/portlets/MyPortlet_b7c97a45_87d8_4860_844b_b05af20d88e0.pxml"

    at oracle.mds.core.MetadataObject.getBaseMO(MetadataObject.java:1279)

    at oracle.mds.core.MDSSession.getBaseMO(MDSSession.java:3040)

    at oracle.mds.core.MDSSession.getMetadataObject(MDSSession.java:1341)

I'm not sure what is real cause of this error. But I suppose this is configuration persistence problem, probably Webcenter Spaces holds the older configuration information which should be refreshed after deployment.

The problem can lay in page bindings: in Webcenter Spaces you don't have control over the bindings stored in page definition. There is also possible the error lays in wrong portlet producer configuration.

Till now I found one sure method to refresh Spaces configuration:
  • Delete the portlet from the page (in Spaces via composer). 
  • Unregister the producer from Spaces (via EM). 
  • Register the producer from scratch. 
  • Add the portlet to the page.

Tuesday, September 18, 2012

JSF custom components: the role of componentType and componentFamily properties

The component-type property is very important element of definition of each JSF component. When you provide a custom component, you need to produce a tag library descriptor file that specifies component-type value. Any error in component-type value leads to fatal errors. But, what actually is the role of this element ?
<!--e x a m p l e   o f   t a g   l i b r a r y   d e s c r i p t o r-->

<facelet-taglib ...>
   <namespace>http://my-java-planet.pl</namespace>

   <tag>

      <tag-name>customTable</tag-name>

      <component>

         <component-type>pl.my-java-planet.customTable</component-type>        

      </component>      

   </tag> 

</facelet-taglib> 

As JSF specification says: component-type attribute specifies the logical name for a UI component. The
logical name is used to register the UI component with JSF so that it can later be accessed by the same logical name. In other words the component type is an identifier for the component class that must get mapped to the actual class. While not a property of UIComponent , the component-type property is used by tag library to force instatiating of concrete component instance.

To create an instance of JSF UI Component a tag library uses the Application object which resides "between" JSP (facelets) page and a sublass of UIComponent. Technically the createComponent() method of this object is used as shown below:

Application.createComponent("componen-type-value");

When there isn't possible to find appropriate component-type value, an exception is raised.
You can set the compponent-type ID with an annotation of the component class:

@FacesComponent("pl.my-java-planet.customTable") 
public class UICustomTable extends UIComponent

@FacesComponent annotation is an alternative for the following XML in the  faces-config.xml  file::

<faces-config version="1.2" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee  
    http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">

  <component>

    <component-type>pl.my-java-planet.customTable</component-type>

    <component-class>pl.myjavaplanet.jsf.components.UICustomTable</component-class>

  </component>

</faces-config>

The component-family is the next mysterious attribute which defines behaviour of each JSF component. 
If your custom component class delegates rendering, it needs to override the getFamily method of UIComponent to return the identiier of a component family, which is used to refer to a component or set of components that can be rendered by a renderer or set of renderers.  

Definition says: The  component-family element specifies the component family that a renderer will be linked to. Component families are used to group families of components together and are used along with renderer types to uniquely identify a specific rendering. But ... what does this mean?

Component-family attribute is used to link components (one or more) with renderer. Cause one renderer can be in theory used for more than one component, the logical construct of family is used. To bind component-family with renderer you can use faces-config.xml as shown below:


<faces-config version="1.2" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee  
    http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
    <render-kit>
        <renderer> 


             <component-family>
                 pl.my-java-planet.CustomTableFamily
             </component-family> 

             <renderer-type>pl.my-java-planet.CustomTableRenderer</renderer-type>
             <renderer-class>
                  pl.myjavaplanet.UICustomTableRenderer
             </renderer-class> 

         </renderer>
    </render-kit>

</faces-config>

But. How we should "inform" the Component to which family belongs? To bind component-family with Component, the getFamily method of custom component class should be used. Value returned by getFamily method must match with component-family value from renderer definition:

public String getFamily() {

    return ( "pl.my-java-planet.CustomTableFamily");

}

Value returned by getFamily method must match with component-family in faces-config.xml

Saturday, September 1, 2012

SOA 11g installation issue: DB Init Param Prerequisite failure for: processes

This is a common issue when running RCU on a "fresh" database instance but, I always forget how to deal with this problem:) Therefore, in order to remember the solution I wrote down this small "tutorial":

1. Run sqlplus and  connect to your database as SYS

SQL> CONNECT SYS as SYSDBA
Enter password: sys_password

2. Next you can examine PROCESSES parameter

SQL> show parameters processes;

3. The response should look like shown bellow:

NAME                                 TYPE        VALUE
------------------------------------ ----------- -----
aq_tm_processes                      integer     0
db_writer_processes                  integer     1
gcs_server_processes                 integer     0
global_txn_processes                 integer     1
job_queue_processes                  integer     1000
log_archive_max_processes            integer     4
processes                            integer     100

4. You can also check count of running processes:

SQL> select count(*) from v$process; 

and also number of running background processes:

SQL> select count(*) from v$process where BACKGROUND=1;

5. To increase number of PROCESSES run from sqlplus:

SQL> alter system set processes=200;

6. System changes will be active after restart of database instance. To perform database restart you should stop instance:

SQL> shutdown immediate;

7. To startup instance you have to run:

SQL> startup;

When you examine PROCESSES parameter once again, you should see new updated value.

Tuesday, August 21, 2012

How-to fix: ResourceServlet._setHeaders(): Content type for /oracle/webcenter/portalapp/shared/png/image.png is NULL!

While browsing the error log of webcenter portal application I noticed recurrent error:

[2012-08-02T17:21:00.486+02:00] [WC_Portlet1] [WARNING] [] [org.apache.myfaces.trinidad.webapp.ResourceServlet] [tid: [ACTIVE].ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: myUser] [ecid: 0000JZbvEp6Cwk85njP5iZ1G6c2e0000NQ,0] [APP: Portal_application1#V2.0] ResourceServlet._setHeaders(): Content type for /oracle/webcenter/portalapp/shared/png/settings.png is NULL![[
Cause: Unknown file extension
]]

The error isn't fatal, but clutters the log. To fix this error I did small investigation. In the first step I went to org.apache.myfaces.trinidad.webapp.ResourceServlet class source (I found it on grepcode.com). Then I found the source of our error in _setHeaders function:

if (contentType == null || "content/unknown".equals(contentType))
    {
      url = connection.getURL();
      resourcePath = url.getPath();

      // 'Case' statement for unknown content types
      if (resourcePath.endsWith(".css"))
        contentType = "text/css";
      else if (resourcePath.endsWith(".js"))
        contentType = "application/x-javascript";
      else if (resourcePath.endsWith(".cur") || resourcePath.endsWith(".ico"))
        contentType = "image/vnd.microsoft.icon";
      else
        contentType = getServletContext().getMimeType(resourcePath);

      // The resource has an file extension we have not
      // included in the case statement above
      if (contentType == null)
      {
        _LOG.warning("ResourceServlet._setHeaders(): " +
                     "Content type for {0} is NULL!\n" +
                     "Cause: Unknown file extension",
                     resourcePath);
      }
    }
  
It can be seen clearly the problem lays in line 14:

contentType = getServletContext().getMimeType(resourcePath);

where function  getMimeType definitely returns null.

To check what happens in this function I went to documentation of javax.servlet.ServletContext class. In javadoc we can read:

"Returns (getMimeType) the MIME type of the specified file, or null if the MIME type is not known. The MIME type is determined by the configuration of the servlet container, and may be specified in a web application deployment descriptor. Common MIME types are "text/html" and "image/gif"."

The key to solve our problem lays in words: "The MIME type is determined by the configuration of the servlet container, and may be specified in a web application deployment descriptor"

The mime types for web application can be configured in a web.xml deployment descriptor. A mapping between an extension and a mime type defines fhe mime-mapping element. As described in documentation the following elements you can define within a mime-mapping element:

<extension>  A string describing an extension, for example: txt.
<mime-type> A string describing the defined mime type, for example: text/plain.

In accordance with these instructions to configure mime-types for png files I added to my web.xml descriptor:

<mime-mapping>

    <extension>png</extension>

    <mime-type>image/png</mime-type>

</mime-mapping>
 
After redeployment all should work fine. And really works:)

Thursday, August 9, 2012

How to: force loading "managed server wide" jar library in Weblogic

To force loading custom java jar library on application server start, usually you have to put jar file to appropriate folder of the application server. For example:

Apache Tomcat 5.5: [SERVER_DIR]/common/classes/
Apache Tomcat 6.x: [SERVER_DIR]/lib/
jBoss 4.x, 5.x: [SERVER_DIR]/server/[SERVER_TYPE]/conf/
Glassfish 2.x, 3.x: [SERVER_DIR]/domain/[DOMAIN]/lib/classes/

In the case of Weblogic 11g/12c server you can force loading of jar library on all managed servers in the domain by putting file to folder

[DOMAIN_DIR]/lib

You can also configure each managed server separately to load library by putting path to jar in managed server classpath. To do this run weblogic server administration console and next go to Environment | Servers | (Configuration Tab) | Selected_Server. Go to managed server configuration and find Server Start tab. The below image shows where you can put path to jar file: