atom feed NullPointerException

View: New views
5 Messages — Rating Filter:   Alert me  

atom feed NullPointerException

by Christian Fochler :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi pebble community,

I am using the current trunk version of pebble with Tomcat 5.5.

My blog entries have categories and tags.

When I request the atom.xml I get the error page: "Sorry, there has  
been a problem with your request.". RSS is fine!

In the tomcat log file i can read following lines more than one time:

2008-06-17 10:00:55,999 [TP-Processor6] ERROR  
org.apache.catalina.core.ContainerBase.[Catalina].
[www.christianfochler.de].[/].[jsp]  - Servlet.service() for servlet  
jsp threw exception
java.lang.NullPointerException
         at net.sourceforge.pebble.domain.Tag.getPermalink(Tag.java:93)
         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:585)
         at org.apache.commons.el.ArraySuffix.evaluate
(ArraySuffix.java:314)
         at org.apache.commons.el.ComplexValue.evaluate
(ComplexValue.java:145)
         at org.apache.commons.el.ExpressionEvaluatorImpl.evaluate
(ExpressionEvaluatorImpl.java:263)
         at org.apache.commons.el.ExpressionEvaluatorImpl.evaluate
(ExpressionEvaluatorImpl.java:190)
         at  
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate
(PageContextImpl.java:917)
         at  
org.apache.jsp.WEB_002dINF.xml.feeds.main.atom_xml._jspx_meth_c_out_20
(atom_xml.java:1221)
         at  
org.apache.jsp.WEB_002dINF.xml.feeds.main.atom_xml._jspx_meth_c_forEach_
2(atom_xml.java:1154)
         at  
org.apache.jsp.WEB_002dINF.xml.feeds.main.atom_xml._jspx_meth_c_forEach_
0(atom_xml.java:835)
         at  
org.apache.jsp.WEB_002dINF.xml.feeds.main.atom_xml._jspService
(atom_xml.java:126)
         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.catalina.core.ApplicationDispatcher.invoke
(ApplicationDispatcher.java:672)
         at org.apache.catalina.core.ApplicationDispatcher.doInclude
(ApplicationDispatcher.java:574)
         at org.apache.catalina.core.ApplicationDispatcher.include
(ApplicationDispatcher.java:499)
         at net.sourceforge.pebble.web.view.XmlView.dispatch
(XmlView.java:73)
         at  
net.sourceforge.pebble.web.controller.HttpController.processRequest
(HttpController.java:134)
         at net.sourceforge.pebble.web.controller.HttpController.doGet
(HttpController.java:190)
         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  
net.sourceforge.pebble.web.filter.DispatchingFilter.doFilter
(DispatchingFilter.java:80)
         at  
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:202)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:173)
         at  
net.sourceforge.pebble.web.filter.PreProcessingFilter.doFilter
(PreProcessingFilter.java:174)
         at  
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:202)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:173)
         at org.acegisecurity.util.FilterChainProxy
$VirtualFilterChain.doFilter(FilterChainProxy.java:265)
         at  
org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke
(FilterSecurityInterceptor.java:107)
         at  
org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter
(FilterSecurityInterceptor.java:72)
         at org.acegisecurity.util.FilterChainProxy
$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
         at  
net.sourceforge.pebble.security.PrivateBlogSecurityInterceptor.invoke
(PrivateBlogSecurityInterceptor.java:110)
         at  
net.sourceforge.pebble.security.PrivateBlogSecurityInterceptor.doFilter(
PrivateBlogSecurityInterceptor.java:79)
         at org.acegisecurity.util.FilterChainProxy
$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
         at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter
(ExceptionTranslationFilter.java:124)
         at org.acegisecurity.util.FilterChainProxy
$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
         at  
org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter
(RememberMeProcessingFilter.java:142)
         at org.acegisecurity.util.FilterChainProxy
$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
         at  
org.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter
(BasicProcessingFilter.java:174)
         at org.acegisecurity.util.FilterChainProxy
$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
         at  
org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter
(HttpSessionContextIntegrationFilter.java:249)
         at org.acegisecurity.util.FilterChainProxy
$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
         at org.acegisecurity.util.FilterChainProxy.doFilter
(FilterChainProxy.java:149)
         at org.acegisecurity.util.FilterToBeanProxy.doFilter
(FilterToBeanProxy.java:98)
         at  
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:202)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:173)
         at  
net.sourceforge.pebble.web.filter.TransformingFilter.doFilter
(TransformingFilter.java:127)
         at  
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:202)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:173)
         at  
net.sourceforge.pebble.web.filter.BlogLookupFilter.doFilter
(BlogLookupFilter.java:142)
         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.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.jk.server.JkCoyoteHandler.invoke
(JkCoyoteHandler.java:199)
         at org.apache.jk.common.HandlerRequest.invoke
(HandlerRequest.java:282)
         at org.apache.jk.common.ChannelSocket.invoke
(ChannelSocket.java:767)
         at org.apache.jk.common.ChannelSocket.processConnection
(ChannelSocket.java:697)
         at org.apache.jk.common.ChannelSocket$SocketConnection.runIt
(ChannelSocket.java:889)
         at org.apache.tomcat.util.threads.ThreadPool
$ControlRunnable.run(ThreadPool.java:684)
         at java.lang.Thread.run(Thread.java:595)

I can not reproduce the error at my local installation.

After hacking the getPermalink method by replacing blog.getUrl() with  
a string I can download the atom.xml.

The category xml tag in that file looks like this for example:

  <category term="/leben" label="Leben" scheme="http://
christianfochler.de/categories/leben/" />
  <category term="leben" label="leben" scheme="nonetags/leben/" />

As you can see "none" is the replacement for blog.getUrl().

The first tag is from the blogEntry.getCategories and seems to be fine.

All tags of no category have "none" as url - that is the problem!

Can anybody reproduce that phenomenon?

Thanks for your help in advance!

Grettings from Berlin, Germany.

Christian

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Pebble-user mailing list
Pebble-user@...
https://lists.sourceforge.net/lists/listinfo/pebble-user

Re: atom feed NullPointerException

by Olaf Kock :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I've tried to reproduce, but unfortunately cannot. Some tipps though:

To reproduce your problem if it just exists on your public server, copy
your public settings to your local dev machine.

As you are using trunk you obviously have built pebble yourself. The
NullpointerException obviously has its root in blog.getUrl() referencing
null, e.g. blog is null. This is only set in Tags constructor - either
log the other parameter (name) there or place a breakpoint that is
triggered when blog is null.

Sorry, that's all that comes to my mind for now.

Cheers,
Olaf

Christian Fochler schrieb:

> Hi pebble community,
>
> I am using the current trunk version of pebble with Tomcat 5.5.
>
> My blog entries have categories and tags.
>
> When I request the atom.xml I get the error page: "Sorry, there has  
> been a problem with your request.". RSS is fine!
>
> In the tomcat log file i can read following lines more than one time:
>
> 2008-06-17 10:00:55,999 [TP-Processor6] ERROR  
> org.apache.catalina.core.ContainerBase.[Catalina].
> [www.christianfochler.de].[/].[jsp]  - Servlet.service() for servlet  
> jsp threw exception
> java.lang.NullPointerException
>          at net.sourceforge.pebble.domain.Tag.getPermalink(Tag.java:93)
[...]

>
> I can not reproduce the error at my local installation.
>
> After hacking the getPermalink method by replacing blog.getUrl() with  
> a string I can download the atom.xml.
>
> The category xml tag in that file looks like this for example:
>
>   <category term="/leben" label="Leben" scheme="http://
> christianfochler.de/categories/leben/" />
>   <category term="leben" label="leben" scheme="nonetags/leben/" />
>
> As you can see "none" is the replacement for blog.getUrl().
>
> The first tag is from the blogEntry.getCategories and seems to be fine.
>
> All tags of no category have "none" as url - that is the problem!
>
> Can anybody reproduce that phenomenon?



--
abstrakt gmbh, henriettenstraße 73, 20259 hamburg
geschäftsführer: olaf kock, amtsgericht hamburg hrb 77188

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Pebble-user mailing list
Pebble-user@...
https://lists.sourceforge.net/lists/listinfo/pebble-user

Re: atom feed NullPointerException

by Christian Fochler :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Olaf,

thanks for your answer.

It take some time to setup my local dev machine. With Netbeans I was  
not able to get a stable configuration.
So I installed Intellij IDEA and now pebble starts locally with all  
personal stuff like custom configuration and plugins.
Of course with the described error too.

As we already know it happend because there is no blog object to get  
the url from.
It also happend only for tags of categories.

The categories are stored in a xml file and loaded via JAXB. That is  
new since revision 383.

If you take a look into the FileCategoryDAO.getCategories() method,  
you will see that all tags were loaded as String via the method  
setTags() from the class Category (line 65). That method setTags()  
create tags objects from the string with the blog object of the  
Category object (line 283).

Problem is that this Category object has no blog object. It was  
created via the empty constructor in the FileCategoryDAO.getCategories
() method (line 62). Than filled with ID, name and tags, but no blog  
object!

I could fix that problem by modifying the for loop to:

         for (CategoryType categoryType : categoriesType.getCategory
()) {
           Category category = new Category(categoryType.getId(),  
categoryType.getName());
           category.setBlog(blog);
           category.setTags(categoryType.getTags());

           categoryBuilder.addCategory(category);
         }

The only thing that I do not understand is why you can not reproduce  
that fault?
If you use the current dev code and if you have categories with tags  
it should also produce null pointer exceptions!

However, that is my fix!

To avoid such errors it would maybe better to create category objects  
with an blog object in the constructor and set the empty constructor  
private!
Something like:

        /**
         * Default, no args constructor.
         */
        private Category() {
        }

       /**
        * Creates a new category with the specified properties.
        *
        * @param id          the id
        * @param name          the name
        */
       public Category(String id, String name) {
         this();
         setId(id);
         setName(name);
       }

       /**
        * Creates a new category with the specified properties.
        *
        * @param blog            the blog
        * @param id          the id
        * @param name          the name
        */
       public Category(Blog blog, String id, String name) {
         this(id, name);
         setBlog(blog);
       }

Thanks for your help!

Greetings,
Christian


Am 18.06.2008 um 22:03 schrieb Olaf Kock:

> Hi,
>
> I've tried to reproduce, but unfortunately cannot. Some tipps though:
>
> To reproduce your problem if it just exists on your public server,  
> copy
> your public settings to your local dev machine.
>
> As you are using trunk you obviously have built pebble yourself. The
> NullpointerException obviously has its root in blog.getUrl()  
> referencing
> null, e.g. blog is null. This is only set in Tags constructor - either
> log the other parameter (name) there or place a breakpoint that is
> triggered when blog is null.
>
> Sorry, that's all that comes to my mind for now.
>
> Cheers,
> Olaf

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Pebble-user mailing list
Pebble-user@...
https://lists.sourceforge.net/lists/listinfo/pebble-user

Re: atom feed NullPointerException

by Olaf Kock :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Christian Fochler schrieb:
> Problem is that this Category object has no blog object. It was  
> created via the empty constructor in the FileCategoryDAO.getCategories
> () method (line 62). Than filled with ID, name and tags, but no blog  
> object!

Thanks, that makes things a lot clearer to me. I'll look at it again,
probably this weekend, and fix it in svn. There shouldn't be any more
problems to reproduce.

> The only thing that I do not understand is why you can not reproduce  
> that fault?
> If you use the current dev code and if you have categories with tags  
> it should also produce null pointer exceptions!

The reason is probably because I'm myself pretty new to pebbles
internals. Plus (this is what others on this list suffer from, too) I've
not had too much time in the last weeks. The localization updates I've
just committed were done in several micro-steps, each taking 5-10
minutes, at times, when I couldn't concentrate on hard bug hunting (e.g.
due to loud environment or other distractions).

Sorry, that I couldn't help sooner or better...

Cheers,
Olaf

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Pebble-user mailing list
Pebble-user@...
https://lists.sourceforge.net/lists/listinfo/pebble-user

Re: atom feed NullPointerException

by Olaf Kock :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Christian Fochler schrieb:
[...]

> If you take a look into the FileCategoryDAO.getCategories() method,  
> you will see that all tags were loaded as String via the method  
> setTags() from the class Category (line 65). That method setTags()  
> create tags objects from the string with the blog object of the  
> Category object (line 283).
>
> Problem is that this Category object has no blog object. It was  
> created via the empty constructor in the FileCategoryDAO.getCategories
> () method (line 62). Than filled with ID, name and tags, but no blog  
> object!
>
> I could fix that problem by modifying the for loop to:
>
>          for (CategoryType categoryType : categoriesType.getCategory
> ()) {
>            Category category = new Category(categoryType.getId(),  
> categoryType.getName());
>            category.setBlog(blog);
>            category.setTags(categoryType.getTags());
>
>            categoryBuilder.addCategory(category);
>          }

Thanks, I've now applied this and committed to svn.

I'll leave your suggestion re private Category constructor to Simon to
comment. I can't exactly tell if Category is constructed somewhere via
Reflection, at least the constructor is currently used 4 times and I
don't feel confident enough to change this yet.

Thanks again for your efforts.

Cheers,
Olaf


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Pebble-user mailing list
Pebble-user@...
https://lists.sourceforge.net/lists/listinfo/pebble-user