Struts Tiles Problem - Can't get definitions factory from context.

S

spivee

This is a common error, as I have found from searching for a solution.
Unfortunately, I haven't been able to find anything that helped me fix
my problem. I'm running struts 1.2 on windows XP with Tomcat 5.5.7.

I've been working on this for a while, but haven't gotten anywhere. I
chopped it down to a minimum. index.jsp works fine unless there is a
tile reference, in which case it throws the exception.

I do have the tiles.jar file in my WEB-INF/lib folder. The taglib
location on the webpages is correct. The location of the
struts-tile-defs.xml file is correct in the plugin.

Here is what I have so far..

----> PLUGIN from struts-config.xml

<plug-in className="org.apache.struts.tiles.TilesPlugin" >
<set-property property="definitions-config"
value="/WEB-INF/configs/struts-tile-defs.xml" />
<set-property property="definitions-debug" value="2" />
<set-property property="definitions-parser-details" value="2" />
<set-property property="definitions-parser-validate" value="true"
/>
<set-property property="moduleAware" value="true" />
</plug-in>

----> JSP Page index.jsp...

<%@ page language="java"%>
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tlds/struts-tiles.tld" prefix="tiles" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html:html locale="true">
<head>
<html:base />
<tiles:insert definition="page.default" />
</html:html>


----> struts-tile-defs.xml file entry for page.default

<definition name="page.default"
path="/WEB-INF/pages/layouts/defaultlayout.jsp" />

----> defaultlayout.jsp

<%@ page language="java"%>
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html:html locale="true">
<table border="0" width="80%">
Start Page
</table>
</html:html>

----> The Exception..

javax.servlet.ServletException: Can't get definitions factory from
context.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:846)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.WEB_002dINF.pages.index_jsp._jspService(org.apache.jsp.WEB_002dINF.pages.index_jsp:86)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause
javax.servlet.jsp.JspException: Can't get definitions factory from
context.
org.apache.struts.taglib.tiles.InsertTag.processDefinitionName(InsertTag.java:583)
org.apache.struts.taglib.tiles.InsertTag.createTagHandler(InsertTag.java:487)
org.apache.struts.taglib.tiles.InsertTag.doStartTag(InsertTag.java:451)
org.apache.jsp.WEB_002dINF.pages.index_jsp._jspx_meth_tiles_insert_0(org.apache.jsp.WEB_002dINF.pages.index_jsp:162)
org.apache.jsp.WEB_002dINF.pages.index_jsp._jspx_meth_html_html_0(org.apache.jsp.WEB_002dINF.pages.index_jsp:123)
org.apache.jsp.WEB_002dINF.pages.index_jsp._jspService(org.apache.jsp.WEB_002dINF.pages.index_jsp:77)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 
W

Wendy Smoak

I've been working on this for a while, but haven't gotten anywhere. I
chopped it down to a minimum. index.jsp works fine unless there is a
tile reference, in which case it throws the exception.

I do have the tiles.jar file in my WEB-INF/lib folder. The taglib
location on the webpages is correct. The location of the
struts-tile-defs.xml file is correct in the plugin.

What does the log file say when you start your webapp? Mine has:

12:35:42,050 - DEBUG org.apache.struts.tiles.xmlDefinition.I18nFactorySet -
Factory initialized from file '/WEB-INF/tiles-defs.xml'.
12:35:42,050 - INFO org.apache.struts.tiles.TilesPlugin - Tiles definition
factory loaded for module ''.
(Plus other lines listing all the tiles defs and their contents.)
 
S

spivee

When I reload the app, I get the following exceptions in my error
logs... (posting abbreviated thread dump)

Mar 10, 2005 3:27:03 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: restart: Reloading web application at '/registrar'
Mar 10, 2005 3:27:03 PM org.apache.catalina.core.StandardContext reload
INFO: Reloading this Context has started
Mar 10, 2005 3:27:04 PM org.apache.struts.util.PropertyMessageResources
<init>
INFO: Initializing, config='org.apache.struts.util.LocalStrings',
returnNull=true
Mar 10, 2005 3:27:04 PM org.apache.struts.util.PropertyMessageResources
<init>
INFO: Initializing, config='org.apache.struts.action.ActionResources',
returnNull=true
Mar 10, 2005 3:27:04 PM org.apache.struts.action.ActionServlet
handleConfigException
SEVERE: Parsing error processing resource path
java.net.UnknownHostException: struts.apache.org
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
at java.net.Socket.connect(Socket.java:507)
at java.net.Socket.connect(Socket.java:457)
at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:365)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:477)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:214)
at sun.net.www.http.HttpClient.New(HttpClient.java:287)
at sun.net.www.http.HttpClient.New(HttpClient.java:299)
.....


Mar 10, 2005 3:27:04 PM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet action as unavailable
Mar 10, 2005 3:27:04 PM org.apache.catalina.core.ApplicationContext log
SEVERE: Servlet /registrar threw load() exception
javax.servlet.UnavailableException: Parsing error processing resource
path
at
org.apache.struts.action.ActionServlet.handleConfigException(ActionServlet.java:1035)
at
org.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionServlet.java:1012)
at
org.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet.java:955)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:470)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
.....

Mar 10, 2005 3:27:04 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: list: Listing contexts for virtual host 'localhost'


When I hit the page, I get the error I posted in the first post.. This
error shows in the browser as well as in the logs...
 
W

Wendy Smoak

Mar 10, 2005 3:27:04 PM org.apache.struts.action.ActionServlet
handleConfigException
SEVERE: Parsing error processing resource path
java.net.UnknownHostException: struts.apache.org ....
org.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionServlet.j
ava:1012)

Are you using modules? Looks like there's a problem parsing that config
file.
 
S

spivee

I don't think I'm using modules. Not sure what modules are...

I am thinking that this has to do with the ActionServlet method trying
to parse down either the struts-config.xml file or the
struts-tiles-defs.xml file, but so far I haven't been able to find any
problems with them. I am using MyEclipse to code and it sees no
problems with either xml file.
 
C

cchang

First, let me begin by noting that I work for M7. We develop NitroX.
The Struts version has very nice support for Tiles including design
time edits/views. One nice feature about NitroX is it's ability to
detect inconsistencies/errors that span the web app - at design time.
This includes the struts-config.xml, web.xml, java, jsp, tlds, etc.

Since you're already using eclipse, you can download the trial (get the
light version that doesn't include eclipse) have it point your eclipse
environment (or make a copy if it if you're worried) and see if NitroX
can automatically find the errors or provide some hints to the problem.

You can see some of the tiles support here:
http://www.m7.com/tiles.htm

You can download here: www.m7.com/free
I'd recommend the free JSP Editor since it includes trial capabilities
for the Struts IDE and JSP IDE. Remember to get the Express edition so
you don't download eclipse as well.

good luck.
 
Joined
Aug 1, 2007
Messages
1
Reaction score
0
Answer

Since this thread is the first hit in Google when searching for the exception message, I'm posting my solution here. I don't think it's the answer every time this exception pops up, but I am convinced some visitors will benefit from this note:

Check your (tomcat) java security settings. Turn java security on the vm off to make sure java security is in your way. If it is, turn it back on and configure it properly.

Grtz!
 
Joined
Mar 24, 2008
Messages
1
Reaction score
0
Struts Tiles Problem - can't get tiles to work in subfolder of webapp root

Hi, i'm trying to get tiles to work for its layout and definition functionality.

i have the following files

tilestest.jsp - the page i request for in the browser
tilesdefinition.jsp - containing the definition for the layout
layout.jsp - contains the layout - simple insert attribute statements with header, content and footer
and header.jsp, content.jsp and footer.jsp.

now if i place all of these files at the root of the webapp, every thing works fine, the layout is populated according to the definition and is inserted into the tilestest.jsp, if i place the tiles = header.jsp, content.jsp and footer.jsp as well as the layout.jsp itseft in a subfolder at root ... every thing works fine... but when i either take the definition jsp in the subfolder or the tilestest.jsp in the subfolder ... i start getting blank pages... the system out statements in the definition files is executed but the system out statements in the layout file is not executed... even if i remove the definition and directly insert the layout in the tilestest.jsp in a subfolder it still does not work... i have been trying to dig out the reason for this problem ... but couldn't...

would really appreciate if any of you could help me out here...
can't get tiles to work in subfolder of webapp root ...

thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top