cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a Taglib as a service

Former Member
0 Kudos

I am attempting to create my own taglib, ala framework and layout taglibs, but am running into errors picking up the taglib.

I've followed the steps in this document which does exactly what I want to do: https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/40599e45-8cf9-2910-cbaa-d4cd8e15...

However, I receive the following ParseException in the stack trace: Error in parsing taglib 'minimalLayout' tag in web.xml or .tld file of the taglib library. I am attempting to access the TLD in the same manner that I am pulling the TLD for htmlb or framework tags. They should be accessible from any PAR that I'm creating if I define it in the portalapp.xml file:


        <property name="com.sap.portal.reserved.layout.TagLibLayout" value="/SERVICE/com.sap.portal.pagebuilder/taglib/layout.tld"/>
        <property name="minimalLayout" value="/SERVICE/com.myapp.portal.framework.tags/taglib/minimalLayout.tld"/>        

Really struggling to understand what I'm missing here. Any ideas?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

OK, I've found what the problem is, but I don't know how to correct it. It's looking in the wrong place for the TLD!


java.io.FileNotFoundException: /usr/sap/EPT/JC00/j2ee/cluster/server0/apps/sap.com/irj/servlet_jsp/irj/root/portalapps/com.myapp.portal.framework/taglib/minimallayout.tld (No such file or directory)
	at java.io.FileInputStream.open(Native Method)
	at java.io.FileInputStream.<init>(FileInputStream.java:106)
	at java.io.FileInputStream.<init>(FileInputStream.java:66)
	at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:69)
	at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:156)
	at java.net.URL.openStream(URL.java:913)
	at com.sap.engine.lib.xml.parser.AbstractXMLParser.parse(AbstractXMLParser.java:201)
	at com.sap.engine.lib.xml.parser.AbstractXMLParser.parse(AbstractXMLParser.java:263)
	at com.sap.engine.lib.xml.parser.Parser.parseWithoutSchemaValidationProcessing(Parser.java:280)
	at com.sap.engine.lib.xml.parser.Parser.parse(Parser.java:342)
	at com.sap.engine.lib.xml.parser.DOMParser.parse(DOMParser.java:101)
	at com.sap.engine.lib.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:127)
	at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:124)
	at com.sapportals.portal.prt.servlets_jsp.server.jsp.syntax.JspTaglibDirective.verifyAttributes(JspTaglibDirective.java:177)
...

It should be looking in com.myapp.portal.framework.tags/taglib/minimalLayout.tld. com.myapp.portal.framework is a different package! This error only seems to appear upon the first click after making a change to the PAR, which is why I missed it earlier.

Even so, this path suggests looking for a tld file outside of the PORTAL-INF folder structure, which doesn't seem quite right either. When I look at that area on the server I see javascript, images and css files. Nothing that's inside of PORTAL-INF.

Former Member
0 Kudos

Hi,

Could you send the portal component to the mail in my contact information?

Do you have the TLD in a separate portal component and the calling portal component in another? (think this is the basis for the other examples)

Regards

Dagfinn

Former Member
0 Kudos

You have mail.

It is two separate projects/PARs. One contains the TLD and tag class, while the other consumes this class.

Thanks!

Former Member
0 Kudos

Unfortunately it seems have not received the mail and I can find it in the spam folder either.

Did you send it to the ameneon g-mailaddress?

Regards

Dagfinn

Former Member
0 Kudos

I resent from my gmail account. I believe it may have been blocked thru my office email.

Former Member
0 Kudos

Got it,

In your the portalapp.xml for your tabbedpage portal component you have a sharingreference to your taglib portal component tags.

This sharing reference gives you access to the java sources in the src.api "folder" and other "open files".

However, in the tags portal component you have used the src.core folder for the MinimalContainer javaclass.

You have two choices I believe:

1. Move the MinimalContainer javaclass from the src.core to the src.api

2. Define a privatesharingreference instead of a normal sharingreference in the portalapp.xml of your tabbedpage component

I would prefer 1.

Also you try to use the com.sapportals.portal.pb.layout.PageLayout as a controller for your JSP. The pagebuilder project this is contained in doesn't have a reference to the htmlb code and this might be why the code fails with an error "Caused by: java.lang.NoClassDefFoundError: com/sapportals/htmlb/Container" once you have correct the issue with your custom taglib.

I created a more simplified component in the tabbedpage component, this time as a jspnative project

> <component-config>

> <property name="ComponentType" value="jspnative"/>

> <property name="JSP" value="jsp/spryTabbedPanelPage2.jsp"/>

When just creating a minimalcontainer tag in the jsp file, it appears to be calling the taglib correctly.

However, the taglib class fails with the following exception.

>Caused by: java.lang.NullPointerException

> at com.garden2.portal.framework.tags.MinimalContainerWithLayoutTag.isNestedPage(MinimalContainerWithLayoutTag.java:363)

> at com.garden2.portal.framework.tags.MinimalContainerWithLayoutTag.doInitBody(MinimalContainerWithLayoutTag.java:101)

Cheers

Dagfinn

Former Member
0 Kudos

code vs api. Now I understand what the difference is. Sure enough that was in the document, but it was not followed correctly since it wasn't spelled out for beginners

I'm still getting a FileNotFoundException, but I suspect it has something to do with the other part you alluded to in terms of the consuming JSP page. It's still looking in the wrong place for the taglib.

I'll look at making those changes and see what happens.

Former Member
0 Kudos

Hello,

my colleague and I have stumbled over the same problem in a NetWeaver 7.0 portal, whereas the same definition works in a NW7.3 portal.


/SERVICE/com.mycompany.app1.app2/taglib/layout.tld

The problem was that we have two portal applications: com.mycompany.app1 and com.mycompany.app1.app2. Therefore the system interpreted app2 to be a component of com.mycompany.app1 and decided that the taglib must be part of app1.

The solution was to add a dummy suffix to the app2 application:


/SERVICE/com.mycompany.app1.app2.*/taglib/layout.tld

Best regards,

Björn

Answers (4)

Answers (4)

Former Member
0 Kudos

Still looking into this.

I've discovered that it's failing upon attempting to grok the TLD file (just like the error suggests). Upon decompiling of JspTaglibDirective and searching through the method and the JspParseException messages, it's failing during the effort to parse the DOM of the TLD and store the TLD in the cache.

JspParseException. The message it's using is servlet_jsp_0098, which is called in two places. If it's an IOException other than FileNotFoundException. In this case, the only ones that seem possible are MalformedURLExcepion or something like EOFException. Or it can be called if an Error occurs since it also catches Throwable further down the catch tree.

The code that fails is somewhere in this block:


                try
                {
                    StandardDOMParser parser_ = new StandardDOMParser();
                    org.w3c.dom.Document parsed = null;
                    parsed = parser_.parse(super.parser.getRootDirectorty() + uri);
                    tagD = tagLibDoc.loadDescriptorFromDocument(parsed);
                    ((TagLibraryInfoImpl)tagD).setURI(uri);
                    ((TagLibraryInfoImpl)tagD).setPrefixString(prefix);
                    super.parser.getTagLibDescriptors().put(uri, tagD);
                    tags = tagD.getTags();
                }
                catch(OutOfMemoryError ex)
                {
                    throw ex;
                }
                catch(ThreadDeath ex)
                {
                    throw ex;
                }
                catch(IOException io)
                {
                    if(io instanceof FileNotFoundException)
                    {
                        Object params[] = {
                            uri
                        };
                        throw new JspParseException("servlet_jsp_0301", params);
                    } else
                    {
                        throw new JspParseException("servlet_jsp_0098", io);
                    }
                }
                catch(Throwable ex)
                {
                    throw new JspParseException("servlet_jsp_0098", ex);
                }
                finally
                {
                    Thread.currentThread().setContextClassLoader(appLoader);
                }

I'm guessing that there's something wrong with how I'm calling the Service, but I haven't found that error yet.

Is it true that you do not need to define anything in a portalapp.xml in a project that only contains a taglibrary, as in the original document's guidelines?

Former Member
0 Kudos

Well, I did find two things wrong in the TLD..a stray end tag, and incorrect class name! So Thanks!

But it's still failing.... However I think the reason is changing. I'm finding new stuff in the stack trace pointing to a different TLD path.

I'm going to continue digging. Appreciate your assistance.

Former Member
0 Kudos

Sure:


Component : pcd:portal_content/com.portal.Sandbox/com.portal.NewFramework/app2/frameworkPages/com.app2.portal.Garden2LightFrameworkPage/com.app2.portal.Garden2LIP/com.app2.portal.Spry_Tabbed_Page/com.app2.portal.SpryTabbedPage
Component class : com.sapportals.portal.pb.layout.PageLayout
User : MCornell
	at com.sapportals.portal.prt.core.PortalRequestManager.handlePortalComponentException(PortalRequestManager.java:973)
	at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:444)
	at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:527)
	at com.sapportals.portal.prt.core.async.AsyncPortalComponentResponse.include(AsyncPortalComponentResponse.java:680)
	at com.sapportals.portal.pb.layout.PageLayout.doContent(PageLayout.java:82)
	at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:209)
	at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114)
	at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
	at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
	at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
	at com.sapportals.portal.prt.core.async.AsyncPortalComponentResponse.include(AsyncPortalComponentResponse.java:355)
	at com.sapportals.portal.prt.core.async.AsyncPortalComponentResponse.include(AsyncPortalComponentResponse.java:310)
	at com.sapportals.portal.pb.PageBuilder.includeLayout(PageBuilder.java:1039)
	at com.sapportals.portal.pb.PageBuilder.doContent(PageBuilder.java:517)
	at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:209)
	at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114)
	at com.sapportals.portal.prt.component.CachablePortalComponent.service(CachablePortalComponent.java:273)
	at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
	at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
	at com.sapportals.portal.prt.core.async.AsyncIncludeRunnable$1$DoDispatchRequest.run(AsyncIncludeRunnable.java:375)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sapportals.portal.prt.core.async.AsyncIncludeRunnable.run(AsyncIncludeRunnable.java:388)
	at com.sapportals.portal.prt.core.async.ThreadContextRunnable.run(ThreadContextRunnable.java:164)
	at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:729)
	at java.lang.Thread.run(Thread.java:534)
Caused by: com.sapportals.portal.prt.component.PortalComponentException: Error occurs when the jsp parser try to read the jsp
	at com.sapportals.portal.prt.core.broker.JSPComponentItem.getComponentInstance(JSPComponentItem.java:116)
	at com.sapportals.portal.prt.core.broker.PortalComponentItemFacade.service(PortalComponentItemFacade.java:355)
	at com.sapportals.portal.prt.core.broker.PortalComponentItem.service(PortalComponentItem.java:934)
	at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:435)
	... 23 more
Caused by: com.sapportals.portal.prt.servlets_jsp.server.jsp.ParseException:  Error in parsing taglib 'minimalLayout' tag in web.xml or .tld file of the taglib library.
	at com.sapportals.portal.prt.servlets_jsp.server.jsp.syntax.JspTaglibDirective.verifyAttributes(JspTaglibDirective.java:189)
	at com.sapportals.portal.prt.servlets_jsp.server.jsp.syntax.JspDirective.parse0(JspDirective.java:162)
	at com.sapportals.portal.prt.servlets_jsp.server.jsp.syntax.JspDirective.parse(JspDirective.java:117)
	at com.sapportals.portal.prt.servlets_jsp.server.jsp.syntax.ElementCollection.parse(ElementCollection.java:86)
	at com.sapportals.portal.prt.servlets_jsp.server.jsp.syntax.ParserImpl.parse(ParserImpl.java:595)
	at com.sapportals.portal.prt.servlets_jsp.server.jsp.JSPParser.parse(JSPParser.java:2144)
	at com.sapportals.portal.prt.servlets_jsp.server.jsp.JSPCompiler.compile(JSPCompiler.java:81)
	at com.sapportals.portal.prt.servlets_jsp.server.jsp.JSPCompiler.run(JSPCompiler.java:140)
	at com.sapportals.portal.prt.core.broker.JSPComponentItem.compileJSP(JSPComponentItem.java:291)
	at com.sapportals.portal.prt.core.broker.JSPComponentItem.getComponentInstance(JSPComponentItem.java:141)
	... 26 more

The specific trace at the bottom:


EXCEPTION]
 {0}#1#com.sapportals.portal.prt.servlets_jsp.server.jsp.ParseException:  Error in parsing taglib 'minimalLayout' tag in web.xml or .tld file of the taglib library.
	at com.sapportals.portal.prt.servlets_jsp.server.jsp.syntax.JspTaglibDirective.verifyAttributes(JspTaglibDirective.java:189)
	at com.sapportals.portal.prt.servlets_jsp.server.jsp.syntax.JspDirective.parse0(JspDirective.java:162)
	at com.sapportals.portal.prt.servlets_jsp.server.jsp.syntax.JspDirective.parse(JspDirective.java:117)
	at com.sapportals.portal.prt.servlets_jsp.server.jsp.syntax.ElementCollection.parse(ElementCollection.java:86)
	at com.sapportals.portal.prt.servlets_jsp.server.jsp.syntax.ParserImpl.parse(ParserImpl.java:595)
	at com.sapportals.portal.prt.servlets_jsp.server.jsp.JSPParser.parse(JSPParser.java:2144)
	at com.sapportals.portal.prt.servlets_jsp.server.jsp.JSPCompiler.compile(JSPCompiler.java:81)
	at com.sapportals.portal.prt.servlets_jsp.server.jsp.JSPCompiler.run(JSPCompiler.java:140)
	at com.sapportals.portal.prt.core.broker.JSPComponentItem.compileJSP(JSPComponentItem.java:291)
	at com.sapportals.portal.prt.core.broker.JSPComponentItem.getComponentInstance(JSPComponentItem.java:141)
	at com.sapportals.portal.prt.core.broker.PortalComponentItemFacade.service(PortalComponentItemFacade.java:355)
	at com.sapportals.portal.prt.core.broker.PortalComponentItem.service(PortalComponentItem.java:934)
	at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:435)
	at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:527)
	at com.sapportals.portal.prt.core.async.AsyncPortalComponentResponse.include(AsyncPortalComponentResponse.java:680)
	at com.sapportals.portal.pb.layout.PageLayout.doContent(PageLayout.java:82)
	at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:209)
	at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114)
	at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
	at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
	at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
	at com.sapportals.portal.prt.core.async.AsyncPortalComponentResponse.include(AsyncPortalComponentResponse.java:355)
	at com.sapportals.portal.prt.core.async.AsyncPortalComponentResponse.include(AsyncPortalComponentResponse.java:310)
	at com.sapportals.portal.pb.PageBuilder.includeLayout(PageBuilder.java:1039)
	at com.sapportals.portal.pb.PageBuilder.doContent(PageBuilder.java:517)
	at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:209)
	at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114)
	at com.sapportals.portal.prt.component.CachablePortalComponent.service(CachablePortalComponent.java:273)
	at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
	at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
	at com.sapportals.portal.prt.core.async.AsyncIncludeRunnable$1$DoDispatchRequest.run(AsyncIncludeRunnable.java:375)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sapportals.portal.prt.core.async.AsyncIncludeRunnable.run(AsyncIncludeRunnable.java:388)
	at com.sapportals.portal.prt.core.async.ThreadContextRunnable.run(ThreadContextRunnable.java:164)
	at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:729)
	at java.lang.Thread.run(Thread.java:534)

Former Member
0 Kudos

Hi,

Could you also post the minimalLayout.tld file ?

Also check if the issue is the last one mentioned on this page: http://ww2.avispublicsduparisien.com/irj/portalapps/com.sap.portal.pdk.documentation.howtodevelopmyp...

The reason is that the declaration of the tag library in the JSP does not match the entry in the portalapp.xml file.

Declaration in JSP - mistyped

<%@ taglib uri= "taglib" prefix="hbj" %>

Correction:

<%@ tagLib uri= "taglib" prefix="hbj" %>

tagLib is written with a capital L.

Regards

Dagfinn

Former Member
0 Kudos

Hi,

Could you post the stack trace of the exception?

From my point of view it sound like it finds the TLD but the parsing fails (could be invalid XML).

Regards

Dagfinn