portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Woonsan Ko (JIRA)" <jetspeed-...@portals.apache.org>
Subject [jira] Commented: (JS2-734) Calling PortletContext.getResource in Portlet.init can throw NullPointerException
Date Wed, 20 Jun 2007 04:16:26 GMT

    [ https://issues.apache.org/jira/browse/JS2-734?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12506388
] 

Woonsan Ko commented on JS2-734:
--------------------------------

I guess I found the cause.
Two problems:
  (1) Your portlet application war file name should not be prefixed by 'jetspeed-'.
        If the war file name is like that, org.apache.jetspeed.deployment.impl.DeployPortletAppEventListener
class will treat it as a local portlet application.
  (2) In your war file, there should not be any duplicate entry. In your war file, there's
a duplicate entry, test.jsp. Duplicate entry makes java.util.zip.ZipException, which stops
auto deployment of Jetspeed-2.

I created war file named 'myjetspeed-bug.war' with no duplicate entry like the following:
  > jar cvf ../myjetspeed-bug.war *

And, I modified the psml like this to adjust the unique fragment IDs:

  <fragment id="getresource" type="layout" name="jetspeed-layouts::VelocityTwoColumns">
    <fragment id="getresource-00" type="portlet" name="myjetspeed-bug::jetspeed-bug-interface">
       <!-- ... -->
    </fragment>
    <fragment id="getresource-01" type="portlet" name="myjetspeed-bug::jetspeed-bug-superclass">
       <!-- ... -->
    </fragment>
  </fragment>

After deploying this war file, I succeeded in seeing 'Resource: jndi:/localhost/myjetspeed-bug/'
in the page.
And, I could see the following in the Tomcat console without any exception:

MyPortlet.init: called
MyPortlet.getResource: resource = /
MyPortlet.initialize: resource = jndi:/localhost/myjetspeed-bug/
MyPortlet.getResource: resource = /WEB-INF/web.xml
MyPortlet.initialize: resource = jndi:/localhost/myjetspeed-bug/WEB-INF/web.xml
MyGenericPortlet.init
MyGenericPortlet.getResource: resource = /
MyGenericPortlet.initialize: resource = jndi:/localhost/myjetspeed-bug/
MyGenericPortlet.getResource: resource = /WEB-INF/web.xml
MyGenericPortlet.initialize: resource = jndi:/localhost/myjetspeed-bug/WEB-INF/web.xml
MyPortlet.render: called
MyPortlet.getResource: resource = /
MyPortlet.initialize: resource = jndi:/localhost/myjetspeed-bug/
MyGenericPortlet.render: called
MyGenericPortlet.getResource: resource = /
MyGenericPortlet.initialize: resource = jndi:/localhost/myjetspeed-bug/

If this solves your problem, we can get a good lesson: Don't prefix by 'jetspeed-'. :-)

> Calling PortletContext.getResource in Portlet.init can throw NullPointerException
> ---------------------------------------------------------------------------------
>
>                 Key: JS2-734
>                 URL: https://issues.apache.org/jira/browse/JS2-734
>             Project: Jetspeed 2
>          Issue Type: Bug
>          Components: Container
>    Affects Versions: 2.1
>            Reporter: Deryk Sinotte
>         Attachments: getResource.zip
>
>
> It's fairly easy to demonstrate the issue.  In the init() method of a simple Portlet,
if I attempt to get the PortletContext and then call getResource on it like so:
>         PortletContext context = portletConfig.getPortletContext();
>         try {
>             URL resource = context.getResource("/");
>         } catch (MalformedURLException e) {
>              e.printStackTrace();
>         }
> I'll get the following:
> 2007-06-14 15:13:31,125 [http-8080-Processor25] ERROR org.apache.jetspeed.factory.JetspeedPortletFactory
- PortletFactory: Failed to load portlet foo.test.MyPortlet
> java.lang.NullPointerException
>         at org.apache.jetspeed.container.JetspeedPortletContext.getResource(JetspeedPortletContext.java:193)
>         at foo.test.MyPortlet.init(Unknown Source)
>         at org.apache.jetspeed.factory.JetspeedPortletInstance.init(JetspeedPortletInstance.java:84)
>         at org.apache.jetspeed.factory.JetspeedPortletFactory.getPortletInstance(JetspeedPortletFactory.java:229)
>         at org.apache.jetspeed.aggregator.impl.HeaderAggregatorImpl.renderHeaderFragment(HeaderAggregatorImpl.java:1056)
>         at org.apache.jetspeed.aggregator.impl.HeaderAggregatorImpl.aggregateAndRender(HeaderAggregatorImpl.java:1037)
>         at org.apache.jetspeed.aggregator.impl.HeaderAggregatorImpl.aggregateAndRender(HeaderAggregatorImpl.java:1029)
>         at org.apache.jetspeed.aggregator.impl.HeaderAggregatorImpl.aggregateAndRender(HeaderAggregatorImpl.java:1029)
>         at org.apache.jetspeed.aggregator.impl.HeaderAggregatorImpl.build(HeaderAggregatorImpl.java:1007)
>         at org.apache.jetspeed.aggregator.HeaderAggregatorValve.invoke(HeaderAggregatorValve.java:48)
>         at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:166)
>         at org.apache.jetspeed.decoration.DecorationValve.invoke(DecorationValve.java:97)
>         at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:166)
>         at org.apache.jetspeed.pipeline.valve.impl.ActionValveImpl.invoke(ActionValveImpl.java:182)
>         at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:166)
>         at org.apache.jetspeed.container.ContainerValve.invoke(ContainerValve.java:76)
>         at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:166)
>         at org.apache.jetspeed.profiler.impl.ProfilerValveImpl.invoke(ProfilerValveImpl.java:255)
>         at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:166)
>         at org.apache.jetspeed.security.impl.LoginValidationValveImpl.invoke(LoginValidationValveImpl.java:159)
>         at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:166)
>         at org.apache.jetspeed.security.impl.PasswordCredentialValveImpl.invoke(PasswordCredentialValveImpl.java:149)
>         at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:166)
>         at org.apache.jetspeed.localization.impl.LocalizationValveImpl.invoke(LocalizationValveImpl.java:169)
>         at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:166)
>         at org.apache.jetspeed.security.impl.AbstractSecurityValve$1.run(AbstractSecurityValve.java:118)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at javax.security.auth.Subject.doAsPrivileged(Subject.java:454)
>         at org.apache.jetspeed.security.JSSubject.doAsPrivileged(JSSubject.java:195)
>         at org.apache.jetspeed.security.impl.AbstractSecurityValve.invoke(AbstractSecurityValve.java:112)
>         at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:166)
>         at org.apache.jetspeed.container.url.impl.PortalURLValveImpl.invoke(PortalURLValveImpl.java:67)
>         at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:166)
>         at org.apache.jetspeed.capabilities.impl.CapabilityValveImpl.invoke(CapabilityValveImpl.java:128)
>         at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:166)
>         at org.apache.jetspeed.pipeline.JetspeedPipeline.invoke(JetspeedPipeline.java:145)
>         at org.apache.jetspeed.engine.JetspeedEngine.service(JetspeedEngine.java:214)
>         at org.apache.jetspeed.engine.JetspeedServlet.doGet(JetspeedServlet.java:242)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
>         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
>         at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
>         at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
>         at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
>         at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
>         at org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:688)
>         at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:658)
>         at org.apache.jsp.index_jsp._jspService(index_jsp.java:44)
>         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
>         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
>         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
>         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
>         at org.apache.jetspeed.engine.servlet.XXSUrlAttackFilter.doFilter(XXSUrlAttackFilter.java:51)
>         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
>         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
>         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
>         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
>         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
>         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
>         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
>         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
>         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
>         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
>         at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
>         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
>         at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
>         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
>         at java.lang.Thread.run(Thread.java:613)
> It appears the PortletContext gets created but the wrapped servlet context that it uses
is null.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message