OW2 Consortium
Search OW2 Mail Archive: 

Advanced Search - Powered by Google


Mail Archive Home | exoplatform List | April 2008 Index

<--  Date Index  --> <--  Thread Index  -->

[exoplatform] Re: Problem instanciating a component via reflection


How does the webapp is called, I mean that code?

as a portlet (aka groing through the portal URL) or independently (for example in an IFrame)

If it is an IFrame then you surely need to have a filer in your webapp that will setup the PortalContainer current instance in the threadlocal of your request (from the iframe to your webapp)

The filter that may be needed in your web.xml are:

  <filter>
    <filter-name>PortalContainerInitializedFilter</filter-name>
    <filter-class>org.exoplatform.frameworks.jcr.web.PortalContainerInitializedFilter</filter-class>
  </filter>

  <filter>
    <filter-name>ThreadLocalSessionProviderInitializedFilter</filter-name>
    <filter-class>org.exoplatform.frameworks.jcr.web.ThreadLocalSessionProviderInitializedFilter</filter-class>
  </filter>

and then need to correctly set up the filter mapping like for instance:

 <filter-mapping>
    <filter-name>PortalContainerInitializedFilter</filter-name>
    <url-pattern>/rest/*</url-pattern>
  </filter-mapping>


On Tue, Apr 8, 2008 at 12:38 PM, Luis Arias <kaaloo@xxxxxxxxx> wrote:
Hi,

I'm reporting this problem for a friend Michael who has been having
some problems recently instanciating a component from a webapp running
on an exo-tomcat installation (latest community build).

The component passes unit tests run against the StandaloneContainer,
but fails when instanciated from the webapp.

[07 avr. 17:24:12] DEBUG (class Archiver in thread
graphane.diffusion.listener#0) - calling
Archiver.diffuse(Hashtable<String, String> argsHashTable, java.io.File
file)
 java.lang.Exception: PortalContainer.getInstance() returns null
    at com.docxa.corus.jcr.Archiver.getSession(Archiver.java:59)
    at com.docxa.corus.jcr.Archiver.diffuse(Archiver.java:77)
    at com.graphane.core.diffusion.listener.ListenerDiffusionComponent.dispatchDocuments(ListenerDiffusionComponent.java:85)
    at com.graphane.satellites.diffusion.threadstools.ThreadProcessor.callDispatchDocuments(ThreadProcessor.java:63)
    at com.graphane.satellites.diffusion.threadstools.ThreadProcessor.processDiffusion(ThreadProcessor.java:99)
    at com.graphane.satellites.diffusion.threadstools.ThreadProcessor.run(ThreadProcessor.java:222)
 [07 avr. 17:24:12] ERROR (class Archiver in thread
graphane.diffusion.listener#0) - Unable to diffuse to JCR
 java.lang.Exception: PortalContainer.getInstance() returns null
    at com.docxa.corus.jcr.Archiver.getSession(Archiver.java:59)
    at com.docxa.corus.jcr.Archiver.diffuse(Archiver.java:77)
    at com.graphane.core.diffusion.listener.ListenerDiffusionComponent.dispatchDocuments(ListenerDiffusionComponent.java:85)
    at com.graphane.satellites.diffusion.threadstools.ThreadProcessor.callDispatchDocuments(ThreadProcessor.java:63)
    at com.graphane.satellites.diffusion.threadstools.ThreadProcessor.processDiffusion(ThreadProcessor.java:99)
    at com.graphane.satellites.diffusion.threadstools.ThreadProcessor.run(ThreadProcessor.java:222)


The code that instanciates the component in the webapp is the following:

Class < DiffusionListenerInterface > classToLoad =
                    (Class < DiffusionListenerInterface > )
Class.forName(classNameToRegister);
 Constructor < DiffusionListenerInterface > constructor =
classToLoad.getConstructor();
 DiffusionListenerInterface diffusionListenerToRegister =
constructor.newInstance();


The call to PortalContainer.getInstance() that fails in the component
is the following:

   private Session getSession() throws RepositoryException
   {
       RepositoryService repoService =
(RepositoryService)PortalContainer.getInstance().getComponentInstanceOfType(RepositoryService.class);
       repository = repoService.getCurrentRepository();
       String wsName = repository.getConfiguration().getDefaultWorkspaceName();
       return repository.getSystemSession(wsName).getRootNode().getSession();
   }

We are stumped as to why this is happening, maybe some configuration
files missing in the webapp ?  Is there a better way to obtain a JCR
Session for the component ?  Is there a better way to instanciate the
component from the webapp ?

Thanks,

--
Luis Arias
+33 6 14 20 87 93
skype : kaaloo


--
You receive this message as a subscriber of the exoplatform@xxxxxxx mailing list.
To unsubscribe: mailto:exoplatform-unsubscribe@xxxxxxx
For general help: mailto:sympa@xxxxxxx?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws




<--  Date Index  --> <--  Thread Index  -->

Reply via email to:

Powered by MHonArc.

Copyright © 2006-2007, OW2 Consortium | contact | webmaster.