S2: Advice on debugging jsp/action interactions..
This is an off-shoot of an unanswered question I posted about 10 days ago (during the holidays, I know...) The orginal email is repeated below, but I'm asking a more general question now. I've been getting very frustrated with trying to figure out why some of my jsp's are not retrieving properties from the backing action. I have devMode=true and logging set to DEBUG; but there's nothing in the logs thats helping me. Break points inside the getters are not hit. I've tried both OGNL-based function calls and EL-based bean/property approaches. 95% of the time everything is good, but I've been stuck on this jsp for about two weeks and can't figure out why it doesn't work and I can't seem to find any diagnostic aide to figure out where the problem is. (The following code shows the original attempt, I've already tried an approach that follows bean conventions, and returns a complete map rather that is indexed inside the JSP rather than this on-demand lookup version.) Can anyone offer any helpful hints for diagnosing why my function isn't getting called? Thank you. Eric -- Original Email I'm working on something a little bit like a data grid. However, while the current display is tabular, the data backing it isn't. As a result I can't use straight map notation to access the values to display. For now I have a inefficient helper lookup attached to the action, but I can't seem to get it invoked. The relevant portion of the jsp looks like s:iterator value=competition.feeCategories id=fee trths:property value=name //th/tr s:iterator value=competition.sessions id=session tr tds:property value=name //td s:iterator value=competition.deadlines id=deadline tds:property value=#session.getDisplayPrice(#deadline,#fee) //td !-- 1 -- tds:textfield name=sessionMap[%{#session.id}][%{#deadline.id}][%{#fee.id}] value=%{getSessionMarkup(#session,#fee,#deadline).costDeltaInCents} //td !-- 2-- tdStudio Markup (%)/td /s:iterator /tr /s:iterator /s:iterator The action looks like: public class ConfigurePrices extends ExcursionBase { public String execute() { return SUCCESS; } public StudioSessionPrice getSessionMarkup(Session session, CompetitionDeadline deadline, FeeCategory fee) { for (StudioSessionPrice ssp: excursion.getSessionPrices()) { if (ssp.getUnderlyingCompetitionSession().getSession().equals(session) ssp.getUnderlyingCompetitionSession().getDeadline().equals(deadline) ssp.getUnderlyingCompetitionSession().getFeeCategory().equals(fee)) return ssp; } StudioSessionPrice ssp = new StudioSessionPrice(); ssp.setExcursion(excursion); ssp.setUnderlyingCompetitionSession(session.getCSPfor(deadline,fee)); ssp.setCostDeltaInCents(0L); ssp.setDeltaInPercent(0.0F); excursion.addSessionPrice(ssp); excursionRepository.save(excursion); return ssp; } } ExcursionBase implements ActionSupport; the jsp shown before is hooked up to the INPUT result of the action. The line preceding the !-- 1 -- works properly, so I thought I knew how to call functions with parameters in OGNL. The line around !-- 2-- does not work. The breakpoint just inside the function is not hit. However there are no errors in the log. None of the iterator related objects respond to the getSessionMarkup message and thus shouldn't be masking it from bubbling down to the action. What am I missing? Thank you. Eric - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
S2: Can't seem to access action's properties inside an iterator
I'm working on something a little bit like a data grid. However, while the current display is tabular, the data backing it isn't. As a result I can't use straight map notation to access the values to display. For now I have a inefficient helper lookup attached to the action, but I can't seem to get it invoked. The relevant portion of the jsp looks like s:iterator value=competition.feeCategories id=fee trths:property value=name //th/tr s:iterator value=competition.sessions id=session tr tds:property value=name //td s:iterator value=competition.deadlines id=deadline tds:property value=#session.getDisplayPrice(#deadline,#fee) //td !-- 1 -- tds:textfield name=sessionMap[%{#session.id}][%{#deadline.id}][%{#fee.id}] value=%{getSessionMarkup(#session,#fee,#deadline).costDeltaInCents} //td !-- 2-- tdStudio Markup (%)/td /s:iterator /tr /s:iterator /s:iterator The action looks like: public class ConfigurePrices extends ExcursionBase { public String execute() { return SUCCESS; } public StudioSessionPrice getSessionMarkup(Session session, CompetitionDeadline deadline, FeeCategory fee) { for (StudioSessionPrice ssp: excursion.getSessionPrices()) { if (ssp.getUnderlyingCompetitionSession().getSession().equals(session) ssp.getUnderlyingCompetitionSession().getDeadline().equals(deadline) ssp.getUnderlyingCompetitionSession().getFeeCategory().equals(fee)) return ssp; } StudioSessionPrice ssp = new StudioSessionPrice(); ssp.setExcursion(excursion); ssp.setUnderlyingCompetitionSession(session.getCSPfor(deadline,fee)); ssp.setCostDeltaInCents(0L); ssp.setDeltaInPercent(0.0F); excursion.addSessionPrice(ssp); excursionRepository.save(excursion); return ssp; } } ExcursionBase implements ActionSupport; the jsp shown before is hooked up to the INPUT result of the action. The line preceding the !-- 1 -- works properly, so I thought I knew how to call functions with parameters in OGNL. The line around !-- 2-- does not work. The breakpoint just inside the function is not hit. However there are no errors in the log. None of the iterator related objects respond to the getSessionMarkup message and thus shouldn't be masking it from bubbling down to the action. What am I missing? Thank you. Eric - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
S2: s:include tag and s:param
I've been having trouble getting s:include and s:param to work. I have a snippet I want to include in multiple pages. This snippet will want to make use of Struts 2 tags and OGNL, though at present I just need a simple c:out. The snippet looks like: %@ taglib prefix=c uri=http://java.sun.com/jsp/jstl/core; % div class=primaryBox h1Competition Information/h1 c:out value=${comp.name} / /div - END -- I'm currently using it with: s:include value=/WEB-INF/components/competitions/identity-readonly.jsp s:param name=comp value=competition / /s:include END - The c:out isn't printing anything. I've tried using ${} notation in the param value; that doesn't lead any different behavoir for me. If I reference competition.name in the snippet and skip the s:param, everything works on this page (because the action exposes the competition property. However other pages that include it will not expose it directly (but I can navigate to it from properties that are exposed). What am I missing? Eric - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: S2: Actions/DAO interaction getting messy...
Adam Hardy on 26/03/08 00:28:43 Eric D Nielsen on 25/03/08 14:29, wrote: Its a Struts2/Spring2/JPA(Hibernate) based project. I'm using a slightly modified version of the Generic DAO pattern shown in the Java persistence with Hibernate book and/or the IBM ThoughtWorks very similar example. (Modified to allow Spring Based Injection of the JPA EntityManger, while falling back to a native Hibernate session inside the DAOs to allow a few more optimizations). So its basically Business Objects (POJOs) ---1:1--- DAOs which is a relatively normal pattern I beleive. Is it normal with that Generic DAO pattern to name the DAOs 'services'? In the Domain-Driven-Design paradigm that I generally follow, the services are objects which carry out operations that you don't want to specifically assign to one domain object. I'm willing to admit a LOT of confusion about DAOs v (Services | Managers) v business logic on POJOs. I will say that my Actions are taking things named services but typed as DAOs since I thought I would eventually migrate towards this extra tier, but have let to really understand what belongs there. I think a large part of my confusion comes from most examples I've seen where just about 100% of the method in the vast majority of service classes are proxied calls from the DAO. With only 1-2 methods added to a small percentage of the services. However we are getting quite far afield for Struts matters here. I'd be very happy to receive further enlightenment, but if its better to move this part of the discussion elswhere, please let me know... just use POJOs there. I believe this approach would work with the Model-Driven idea, but it feels a little odd to me to mark up the domain object with HTTP-specific details Yes it would do, but what do you mean by 'mark up the domain object with HTTP-specific details'? I don't think you have to touch the domain objects to code the re-construction of your incoming Bug POJO. Yay! Back to Struts matters... I haven't written any type converters yet, but from the examples I'd been seeing I thought you had to add a @TypeConversion annotation to accessors that wanted custom type conversion. http://struts.apache.org/2.x/docs/typeconversion-annotation.html So if I was using Model Driven, would this mean putting these annotation on the model. (much like the Vistor pattern for Validation) Eric - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
S2: Actions/DAO interaction getting messy...
I'm starting to get some rather stinky code in one of my projects and wanted to ask for some advice. ( Its a Struts2/Spring2/JPA(Hibernate) based project. I'm using a slightly modified version of the Generic DAO pattern shown in the Java persistence with Hibernate book and/or the IBM ThoughtWorks very similar example. (Modified to allow Spring Based Injection of the JPA EntityManger, while falling back to a native Hibernate session inside the DAOs to allow a few more optimizations). So its basically Business Objects (POJOs) ---1:1--- DAOs which is a relatively normal pattern I beleive. Now I'm working on an Action that creates an object that contains lots of references to other objects. A bug tracker would be a reasonable facsimile of my domain object -- when creating a bug, you select a severity, a project, a module, a found in version, possibly you're assigning it to someone, etc. Most of these options come from a drop-down on the view page, however they are all backed by their own domain object -- ie its not just id/string display name lookup-table backing the drop down. So the form submits a whole suite of IDs or String natural keys and I need to build an Defect/Bug and then persist it. In building the Defect I need to convert all the keys to domain objects. This is where things begin to fall apart. To covert the keys to domain object seems to require injecting all the subordinate object DAOs into the Action, its not a big deal but its starting to feel like the subordinate DAOs are taking over the action. Furthermore, its slightly annoying from a performance stand-point that I need to retrieve all the objects from the DB, just to set a foreign key -- I will never be updating the details on the subordinate object from the master only changing which one I'm linked to. [As a side issue: this is a place where the Get (returning a proxy/lazy load thunk with only the ID set without hitting the DB) versus Load could be useful, but I've never seen any of the generic DAO approaches expose that level of control in their API -- does anyone know why?] Here's an example (not from live code, please ignore any minor typos) representing the current state of application and test code. Afterwards I'll list a few of the approaches I've considered for cleaning it up: AddBug.java code: public class AddBug extends ActionSupport { private BugDAO bugService; private UserDAO userService; private ProjectDAO projectService; private ModuleDAO moduleService; private VersionDAO versionService; private String submitterUsername; private String assigneeUsername; private Long projectID; private Long moduleID; private ListLong affectedVersionIDs; public String execute() { Bug bug = new Bug(); // The following lines are what feel unclean to me bug.setSubmitter(userService.findByUsername(getSubmitterUsername())); bug.setAssignee(userService.findByUsername(getAssigneeUsername())); bug.setProject(projectService.find(getProjectID())); bug.setModule(moduleService.find(getModuleID())); for( Long versionID : getAffectedVersionIDs()) { bug.addAffectedVersion(versionService.find(versionID)); } bugDAO.persist(bug); return SUCCESS; } // This block of setters also seems to be wrong... Only the first one // should really be required by this action I think public void setBugService(final BugDAO bs) {bugService=bs;} public void setUserService(final UserDAO us) {userService=us;} public void setProjectService(final ProjectDAO ps) {projectService=ps;} public void setModuleService(final ModuleDAO ms) {moduleService=ms;} public void setVersionService(final VersionDAO vs) {versionService=vs;} public void setSubmitterUsername(final String username) {submitterUsername=username;} public void setAssigneeUsername(final String username) {assigneeUsername=username;} public void setProjectID(final Long id) {projectID=id;} public void setModuleID(final Long id) {moduleID=id;} public void setAffectedVersionIDs(final ListLong ids) {affectedVersionIDs=ids;} public String getSubmitterUsername() {return submitterUsername;} public String getAssigneeUsername() {return assigneeUsername;} public Long getProjectID() {return projectID;} public Long getModuleID() {return moduleID;} public ListLong getAffectedVersionIDs() {return affectedVersionIDs;} } TestAddBug.java (Sorry this is purely from memory so I know I'm missing some of my infrastructure) code: public void testAddBug() { String submitterUsername=TestUser; String assigneeUsername=TestVictim; User submitter=new User(submitterUsername); User assignee=new User(assigneeUsername); UserDAO userService = createMock(UserDAO.class);
S2/SmartURLs: parameterized results...
I've been trying to understand how parameterized results should work under the SmartURLs plugin for Struts 2. In my specific case, I'm trying to redirect on success to a new URL that includes a paramter. I've tried modelling it after the standard XML=based example in the WebWork in Action book on page 191: result name=success type=redirectorder-confirmation.jsp?confirmationNumber=${confirmationNumber}/result So I tried @Results({ @Result(name=success,location=/competitions/admin?id=${getCompId}, type=redirect)}) However nothing gets injected into the variable. I've tried several different formulations of the variable: getCompId, getCompId(), compId, etc. Currently I have a simple method on the action: public String getCompId() {return (comp!=null ? comp.getId().toString() : 0;} (In reality 0 should never be returned, but I wanted an explicit value to be able to tell if I've hooked up the paramter correctly, versus having access to the Id in the first place.) When I try to follow along directly with the XML based approach the action/results from struts.xml seem to interact poorly with the other annotation based configurations and I can't seem to chase down what would make a valid hybrid configuration. Cna anyone give me some pointers on how to either make paramterized locations work with SmartURLs or, how to configure these results in struts.xml wtthout interfereing too much with the other convention/annotations based approaches? Thank you. Eric - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
SmartURLs and Validation Annotations...
I've been trying to figure out how to use Validation Annotations with the SmartURLs plugin. I'm not sure which half I'm not understanding properly, but I can't get the validations to fire at all. I've seen several similiar posts in the archives and have tried tweaking things in a variety of directions. I've also tried emulating Ted Husted's Zero-Configuration Mail-Reader demo app. I've even tried adding what I think should be an always failing ExpressionValidator to help make sure that its not some other subsystem throwing off my expected results. The failure mode I'm seeing is that execure is getting called regardless of the validation success or failure. I'm adding my action, struts.xml, struts.properties, and web.xml. What am I missing about how the validations are supposed to work? Here's my action - package com.ballroomregistrar.compinabox.web.action.account; import com.ballroomregistrar.compinabox.data.User; import com.ballroomregistrar.compinabox.data.service.UserDAO; import com.ballroomregistrar.compinabox.web.action.Unsecured; import com.opensymphony.xwork2.ActionSupport; import com.opensymphony.xwork2.validator.annotations.EmailValidator; import com.opensymphony.xwork2.validator.annotations.ExpressionValidator; import com.opensymphony.xwork2.validator.annotations.RequiredStringValidator; import com.opensymphony.xwork2.validator.annotations.Validations; import org.texturemedia.smarturls.ActionName; import org.texturemedia.smarturls.ActionNames; import org.texturemedia.smarturls.Result; @ActionNames({ @ActionName(name=login, method=execute), @ActionName(name=login-input,method=input) }) @Result(name=success, location=pendingActivation, type=redirect-action) @SuppressWarnings(serial) @Unsecured public class Create extends ActionSupport { private String username; private String email; private String password; private String password_confirm; private UserDAO userDAO; public String input() { return INPUT; } @Validations( requiredStrings = { @RequiredStringValidator(fieldName=username,message=Please enter a username), @RequiredStringValidator(fieldName=password,message=Please enter a password), @RequiredStringValidator(fieldName=password_confim,message=Please confirm your password)}, emails = [EMAIL PROTECTED](fieldName=email,message=Please enter your e-mail address)}, expressions = { @ExpressionValidator(expression=password eq password_confirm,message=The two passwords must be the same), @ExpressionValidator(expression=true eq false, message=Forcing validation failed)} ) public String execute() { User user = new User(); user.setUsername(getUsername()); user.setEmail(getEmail()); user.setPassword(getPassword()); userDAO.makePersistent(user); return SUCCESS; } public void setUsername(String username) { this.username = username; } public String getUsername() { return username; } public void setEmail(String email) { this.email = email; } public String getEmail() { return email; } public void setPassword(String password) { this.password = password; } public String getPassword() { return password; } public void setPassword_confirm(String password_confirm) { this.password_confirm = password_confirm; } public String getPassword_confirm() { return password_confirm; } public void setUserService(UserDAO service) { userDAO=service; } public void setSubmit(String dummy) {} public static final String CANCEL = cancel; } - My struts.xml ?xml version=1.0 encoding=UTF-8 ? !DOCTYPE struts PUBLIC -//Apache Software Foundation//DTD Struts Configuration 2.0//EN http://struts.apache.org/dtds/struts-2.0.dtd; struts constant name=struts.objectFactory value=spring / constant name=struts.devMode value=true / package name=cib-default extends=struts-default interceptors interceptor name=authentication class=com.ballroomregistrar.compinabox.web.interceptors.AuthenticationInterceptor / interceptor name=authorization class=com.ballroomregistrar.compinabox.web.interceptors.AuthorizationInterceptor / interceptor-stack name=cibStack interceptor-ref name=authentication / interceptor-ref name=authorization / interceptor-ref
Re: SmartURLs and Validation Annotations...
On 10/8/07, Ted Husted wrote: On 10/8/07, Dave Newton [EMAIL PROTECTED] wrote: Is validation firing at *all*? I had been under the impression that classes needed to be annotated with the Validation annotation. http://struts.apache.org/2.x/docs/validation-annotation.html True. First, @Validations() tags the class, and then the individual annotations specify the validations as a separate statement or statements. I'm confused. You say True, but then seem to imply that the class doesn't need an extra explicit annotation in addition to the annotation on the method? I've been looking at the Login class inthe mailreader-zero app and it doesn't tag the class in addition to the method. However, it almost working now and it looks like the primary problem was that something in my build chain is misbehaving -- changes to annotations are only getting picked up by every other build/deployment. Other minor issue: I was suprised that @EmailValidator doesn't appear to detect a missing email, it seems like you have to also use @RequiredStringValidator. And this indirectly caused most of my problems since I my initial automated tests for seeing how to hook up validations was only testing a missing email field. Thank you. Eric - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] Hooking up custom interceptors (Annotations)
Thank you Dave and Adam. I;'ve tried both suggestions. 1) Changing away from annotations, works an proved that my interceptors do work outside of their unit tests and actually in the system. 2) Trying the ParentPackage Annotation, works. I had read about this annotation, but convinced myself it wasn't what I was needing... Since I thought I needed to set the XWork Package for my action, not the Parent Package of the XWork Package... though given the way package inheritence works, I should have realized it would work. Now, I really want to use annotations instead of xml where possible, but the ParentPackage approach doesn't feel as clean/DRY as i would like. Configuring the interceptor stack (and global results) in XML is acceptable, since the only other options would tend to require place holder do-nothing classes to annotate. However having to annotate every action with a ParentPackage is very wrong. It feels like something like one of the following options would be needed and I can't tell if anything like this exists yet: 1) Provide some way for a default package to be declared in the struts.xml file 2) Make the actionPackages auto-detection set the XWork package based on the java package in some predictable fashion. (Not just the namespace as currently documented. ParentPackage could still override this default when needed for flexibility. 3) Move towards the do-nothing class to hold annotations -- some sort of ActionPackage interface... Might be able to make it slightly less useless by allowing anonymous interceptors to be defined/configured here if they don't need to be re-used in other packages? Is there some other appraoch to linking all Zero Configuration actions to a specified package without repeating it in every action? What could also be useful -- extend the config-browser plugin to expose an action's XWork package. It would definitely help with debugging/checking what XWork package an auto detected actionPackage is using. Eric - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[S2] Hooking up custom interceptors
I've written a pair of interceptors to implement my application's authentication and authorization requirements. I'm now trying to add them into my application's default stack, but it doesn't seem to be working. Looking around with config-browser I can see that the interceptors are not being listed. I'm using most of the Zero Configuration techniques: actionPackages and the Result annotations. I think the problem is that the auto-detected actions aren't being assigned to the package with the configured custom interceptor stack. I've tried several variations on naming my XWork package based on the wording in the Zero Configuration page under Action and Package name, but that seems to apply to the namespace of the autodetected action not their package. Here's a current version of the struts.xml package definition. - package name=cib-default extends=struts-default interceptors interceptor name=authentication class=com.ballroomregistrar.compinabox.web.interceptors.AuthenticationInterceptor / interceptor name=authorization class=com.ballroomregistrar.compinabox.web.interceptors.AuthorizationInterceptor / /interceptors interceptor-stack name=cibStack interceptor-ref name=authentication / interceptor-ref name=authorization / interceptor-ref name=defaultStak / /interceptor-stack default-interceptor-ref name=cibStack / /package My actions live in: com.ballroomregistrar.compinabox.web.action Here is a simple/sample action -- package com.ballroomregistrar.compinabox.web.action; import org.apache.struts2.config.Result; import com.opensymphony.xwork2.Action; @Result(name=success, value=WEB-INF/jsp/createcomp.jsp) public class CreateComp implements Action { public String execute() { return success; } } -- What am I missing? How do I link the autodetected actions to a package? Or how do I set my custome package as the default package for all actions, etc? Thank you. Eric - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
In-process acceptance testing with Jetty
I've been trying to adapt the approach shown at http://today.java.net/pub/a/today/2007/04/12/embedded-integration-testing-of-web-applications.html for building acceptance tests that can be run more simply within the IDE and that don't require creating a multi-module POM in Maven (since all articles/books I've seen on setting up integration/acceptance testing in maven requires the acceptance tests to live in a different module). I've got the system working for static pages, but there are errors list in the log. When I start trying to test a struts 2 action, it fails. The errors in the log are something like Unable to load bean referencing JspTemplateEngine. The server returns a 404 for the requested page. The project is setup as a standard maven-webapp archetype, identical directory structure as the quickstart application on the Struts 2 Wiki (the Struts 2, Spring2, JPA, Hibernate, AJAX tutorial). I can tell that the applicationContext.xml file is getting picked up and processed. Past that the logs don't seem to give me much to go on. Can anyone offer any advice? Anyone else taking a similar approach to their integration/acceptance testing? Thank you. Eric - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: I'm completely lost, please help... [Thank you/Update]
Thank you for your comments. After another few hours last night I got things working using the following sequence of steps: 1. Deployed a new blank application 2. Editted all the configuration files, with a text editor (NOTE: there appears to be a name mismatch between the Tiles TLD and the taglib entry in the web.xml of the sample struts application) 3. Rebuilt my Tiles framework, again outside of Eclipse 4. Created the src/package structure by hand 5. Coded my custom tag via my preferred text editor 6. Modified build.xml 7. Built from command-line ant 8. Re-started Tomcat from the command-line Ie, doing everything by-hand in a plain text editor, outside of Eclipse. Now that's how I'm used to doing development, but I liked the promise Eclipse support for testing and CVS as well as the object/method browsing as I'm new to Java and will always be looking up stuff. I'm going to try an Eclipse configuration again later today, using your comments and starting from a regular Java Project in Eclipse and not a Tomcat Project and see if more manual intervention in the setup allows better results down the road. Thank you. Eric Quoting Bill Siggelkow [EMAIL PROTECTED]: Eric, It sounds like you are definitely reaching frustration level. I do not have experience on Mac OS X but I can tell you my WinXP experience. First, I don't use the Sysdeo plug-in; I just start and stop tomcat manually -- I *do* utilize Eclipse's Ant integration to run my builds; this works fine. As far as development, when developing I add the jsp-api.jar and servlet-api.jar to my project's build path; I also reference these jars in my compile path in my Ant script; however, I do not include these jars in my WEB-INF/classes as they are part of Tomcat's system classpath. As far as my Ant build; I build a War file with the 'dist' target; and then deploy by extracting the WAR into Tomcat's webapps directory. There are other techniques; one popular approach is to point your Tomcat to your application's working development (web) directory; this will let you develop on-the-fly without needing to restart Tomcat. I suggest you get a simple application working the way you want. Then you can start on your custom tag app. -Bill Siggelkow - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
I'm completely lost, please help...
Long post follows...I don't know if its an Eclipse, Tomcat or Struts problem... I've been trying to get started on Java Web Development using Eclipse, Tomcat, and Struts for the past several weeks. Sometime last week I got both simple JSP's (no custom logic) and the same JSP's using Tiles working. I've been trying to work on my first custom tag. I'm developing on a Mac OS X 10.3 platform. I had to fiddle a lot for the application wide class path and the project-specific class path to get the jsp-api.jar reachable. Once I got that fixed the base classes were resolve-able and my classes compiled. However, the default build from Eclipse, using the Tomcat project template from the Sysdeo plugin, did not appear to put class files into the correct location for Tomcat to use them (ie not in WEB-INF/classes/package/). I looked at the Eclipse In Action book published by Manning to for how to invoke Ant from inside Eclipse and use the provided build.xml file included in the sample Struts application. I had to add classpaths to the build.xml to locate servlet-api.jar and jsp-api.jar. Once that was done Ant could compile the files and the directory structure looked correct. I had a typo in the package for my tag handler in the .tld. After I fixed that I started getting: javax.servlet.ServletExceptions with the root cause as java.lang.NoClassDefFoundError: javax/servlet/Servlet At which point I started working backward, removing custom components from my JSP's, until it was only the Tiles and static template content, but I got the same errors. I had been restarting Tomcat several times throughout this process from the Sysdeo plugin for Eclipse and didn't see anything suspicious in the log. I now tried the root web-application (default Tomcat install) and received: javax.servlet.ServletException: Error allocating a servlet instance org.apache.catalina.values.ErrorReportValue.invoke(ErrorReportValue.java : 105) At this point I tried stopping and restarting Tomcat from the command-line instead of from within Eclipse. The root application started working. My development application however now shows 1 of 2 behaviors: 1) Blank page, no content in view source: direct request for a simple complete jsp (only template text, valid HTML) or for the basic template with an pHi/p as the body. These pages only use the /tags/tiles taglib. 2) org.apache.jasper.JasperException: Failed to load or instantiate TagExtraInfo class: org.apache.struts.taglib.logic.IterateTei org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHand ler.java:50) on any page that includes the /tags/struts-logic taglib. I'm afraid I've corrupted by install of Tomcat or Struts somehow. I haven't done that much actual development, so re-installing everything is doable, but the amount of cross application configuration is daunting even with the help on-line tutorials and both the Eclipse in Action and Struts in Action books. None of the tutorials indicated either of the problems with adding the jsp-api.jar to the eclipse and/or Ant classpaths nor the configuration required for .classes to end up in /WEB-INF/class. Does anyone know if Mac OS X has serious issues with the normal configurations that would be causing those problems? Does anyone know what I did that cased the ServletExceptions near the end of my story or why it can't find struts-logic anymore while it can still find tiles? Any other advice? Thank you. Eric - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Help with new installation...
I'm a developer new to Java and Struts. I've been working with other scripting languages for several years, and am excited about an opportunity to return to Java. I'm getting a little frustrated/over-whelmed with getting everything configured properly, however. I've gotten Tomcat installed and operational. I've gotten Eclipse and the Tomcat Plugin working. Simple JSPs, not using any of Struts, work. I was able to deploy the blank Struts application and obtain the welcome page. I've been trying to follow along with the Struts In Action book by Husted et al. However any time I try to use a struts tag lib in a JSP, such as: %@ taglib uri=/tags/struts-html prefix=html % I get an error when I view the page: 'org.apache.jasper.JasperException: File /tags/struts-html not found' (plus more trace, but assume that's all that really needed.) struts-html.tld is in the WEB-INF folder for the application the web.xml file contains: taglib taglib-uri/tags/struts-html/taglib-uri taglib-location/WEB-INF/struts-html.tld/taglib-location /taglib I feel bad asking this question here, as I know it is bound to be something trivial I'm overlooking, but after several days of minor tweaking and no progress I need some help. What do I need to do? Thank you. Eric - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help with new installation...
I see the response from David Friedman on my question in the archive; I'm on the digest so I haven't received the email. I hope its ok that I've replying to my own post, while quoting his response into this: From: David G. Friedman [EMAIL PROTECTED] Subject: Help with new installation... Date: Sat, 11 Dec 2004 23:27:21 -0500 Content-Type: text/plain; charset=US-ASCII Eric, Are you sure your web.xml taglib directive is in the right place (usually about last)? Have you checked your tomcat logs to see if there are any loading errors? Regards, David The taglibs are the last set of directives in the file, but are still children of the web-app tag. I am finding something suspicious in my logs now: Dec 12, 2004 12:12:51 AM org.apache.catalina.startup.ContextConfig applicationWebConfig INFO: Missing application web.xml, using defaults only StandardEngine[Catalina].StandardHost[localhost].StandardContext[/JCIB] However, Tomcat/webapps/JCIB/WEB-INF/web.xml exists and has full read permissions. I've looked at the Tomcat mailing list archives, it appears that this is a common problem for people on Windows systems with the OS playing games with folding names to lower-case, but reporting upper-case(or something like that) I'm on Mac OS X and I've verified that the WEB-INF directory is fully upper-cased and that the web.xml is fully lowercased. However, I realize now that this is not a Struts problem, so I'l switch my query to the Tomcat list, unless anyone here has any parting advice? Thank you for you reply. Eric On Dec 11, 2004, at 10:58 PM, Eric D. Nielsen wrote: I'm a developer new to Java and Struts. I've been working with other scripting languages for several years, and am excited about an opportunity to return to Java. I'm getting a little frustrated/over-whelmed with getting everything configured properly, however. I've gotten Tomcat installed and operational. I've gotten Eclipse and the Tomcat Plugin working. Simple JSPs, not using any of Struts, work. I was able to deploy the blank Struts application and obtain the welcome page. I've been trying to follow along with the Struts In Action book by Husted et al. However any time I try to use a struts tag lib in a JSP, such as: %@ taglib uri=/tags/struts-html prefix=html % I get an error when I view the page: 'org.apache.jasper.JasperException: File /tags/struts-html not found' (plus more trace, but assume that's all that really needed.) struts-html.tld is in the WEB-INF folder for the application the web.xml file contains: taglib taglib-uri/tags/struts-html/taglib-uri taglib-location/WEB-INF/struts-html.tld/taglib-location /taglib I feel bad asking this question here, as I know it is bound to be something trivial I'm overlooking, but after several days of minor tweaking and no progress I need some help. What do I need to do? Thank you. Eric - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]