You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by louis majanja <lo...@ironpulse.com> on 2003/07/01 04:47:06 UTC

struts + resin error

I just upgrade to struts 1.1 final and have been getting the following
error and have no idea wht it means.

java.lang.NoClassDefFoundError
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
	at java.lang.Class.newInstance0(Class.java:296)
	at java.lang.Class.newInstance(Class.java:249)
	at java.beans.Beans.instantiate(Beans.java:204)
	at java.beans.Beans.instantiate(Beans.java:48)
	at com.caucho.server.http.Application.instantiateServlet(Application.java:3164)
	at com.caucho.server.http.Application.createServlet(Application.java:3087)
	at com.caucho.server.http.Application.loadServlet(Application.java:3048)
	at com.caucho.server.http.QServletConfig.loadServlet(QServletConfig.java:435)
	at com.caucho.server.http.Application.getFilterChainServlet(Application.java:2792)
	at com.caucho.server.http.Application.buildFilterChain(Application.java:2748)
	at com.caucho.server.http.Invocation.service(Invocation.java:313)
	at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
	at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:246)
	at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:164)
	at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
	at java.lang.Thread.run(Thread.java:536)

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Iterate over an Iterator question

Posted by Mykola Ostapchuk <my...@sympatico.ca>.
Hello,

I'm having a problem to iterate with <logic:iterate ..> tag.
I have an Iterator object "allUsers". Here's my code:

<logic:iterate id="users" name="allUsers" scope="request"
type="com.web.users.UsersVO">
     <bean:write name="users" scope="page" property="userFirstName"/>
</logic:iterate>

In Action class:

Iterator allUsers = userBD.selectAllUsers();
request.setAttribute("allUsers", allUsers);

When I use Vector object in this case - everything works fine. With Iterator
object it returns nothing (no error, just nothing).

According to <logic:iterate ...> tag spec:
"Repeats the nested body content of this tag once for every element of the
specified collection, which must be an Iterator, a Collection, a Map (whose
values are to be iterated over), or an array."

Any suggestions - what I'm doing wrong?

Regards,
Mykola


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: setting input for action

Posted by Fedor Smirnoff <fe...@yahoo.com>.
Thanks Troy, you right this does help. I was thinking
actually between two solutions after some research,
one utilizing DispatchAction and regular ActionForm
and another simply separating create/update/delete
into 3 actions, 3 .jsp views all using 1 formbean,
more work but full control. However, you opened my
eyes to DynaActionForm which I never used before and
will look into right now, thanks for the help :)

Fedor

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: setting input for action

Posted by th...@part.net.
There are probably > 100 ways to solve this problem but based on the 
information provided this is what I would suggest. 

First of all, it sounds like you need to abstract some of the logic from 
your actions into a business framework of sorts, or you may already have 
something you need to adapt to (???). In either case, you want something 
that is easy to configure, and easy to access from your struts actions. You 
also want an API that is convenient for use within the struts action 
environment. One possibility is illustrated in the following sample code 
which includes a fictitious business api (BizManager), a 
org.apache.struts.action.PlugIn, and a 
org.apache.struts.actions.DispatchAction (NOTE: this is by no means meant to 
be a complete solution, and it assumes you know all about struts 
configuration and everything else I don't attempt to explain ;): 

======================================= begin sample code 

public interface BizManager
{
 void   create(Object valueObject) throws BizException;
 void   update(Object valueObject) throws BizException;
 Object select(Key id) throws BizException;
 Object delete(Key id) throws BizException;
} 


public class BizManagerPlugIn
implemente Plugin, BizManager
{
 public static final String KEY="BizPlugin"; 

 private String thisConfigParam;
 private String thatConfigParam;
 private String theOtherConfigParam; 

 public void setThisConfigParameter(String param){...}
 public void setThatConfigParameter(String param){...}
 public void setTheOtherConfigParameter(String param){...} 

 public void init(ActionServlet servlet, ModuleConfig config)
 {
   ...
   servlet.getServletContext().setAttribute(KEY, this);
 }

 public static final BizManager getBizManager(ActionServlet servlet)
 {
   return (BizManager) servlet.getServletContext().getAttribute(KEY);
 } 

 //~ ---------------------------------------- BizManager API
 // NOTE: you should strive for a very lightweight
 // implementation here. If your business requirements
 // are very simple then you can implement your entire
 // business framework here and it should be managable
 // (i.e. maintainable). However, for more complex requirements
 // you will want to invest some effort into creating a
 // reusable business system. Then you will simply need to
 // adapt (or pass-through) to it here.... 


 public void create(Object valueObject) throws BizException
 {
   ...
 } 

 public void update(Object valueObject) throws BizException
 {
   ...
 } 

 public Object select(Key id) throws BizException
 {
   ...
 } 

 public Object delete(Key id) throws BizException
 {
   ...
 }
} 

public class BizDispatcher
implements DispatchAction
{ 

 public ActionForward prepareFormForEdit(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
   throws Exception
 {
   DynaActionForm dForm = (DynaActionForm)form; 

   BizManager mgr=BizManagerPlugIn.getBizManager(getServlet()); 

   Key key=new Key((String) dForm.get("key"));
   Object valueObject=mgr.select(key); 

   BeanUtils.copyProperties(dform, valueObject); 

   ... 

   return mapping.findForward("editForm");
 } 


 public ActionForward prepareFormForAdd(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
   throws Exception
 {
   DynaActionForm dForm = (DynaActionForm)form; 

   BizManager mgr=BizManagerPlugIn.getBizManager(getServlet()); 

   ... 

   return mapping.findForward("addForm");
 } 


 public ActionForward processEdit(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
   throws Exception
 {
   DynaActionForm dForm = (DynaActionForm)form; 

   BizManager mgr=BizManagerPlugIn.getBizManager(getServlet());

   ... 

   Object valueObject=new Object();
   BeanUtils.copyProperties(valueObject, dform); 

   ... 

   mgr.update(valueObject); 

   ... 

   return mapping.findForward("editAcknowledgementPage");
 } 


 public ActionForward processAdd(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
   throws Exception
 {
   DynaActionForm dForm = (DynaActionForm)form; 

   BizManager mgr=BizManagerPlugIn.getBizManager(getServlet());

   ... 

   Object valueObject=new Object();
   BeanUtils.copyProperties(valueObject, dform); 

   ... 

   mgr.create(valueObject); 

   ... 

   return mapping.findForward("addAcknowledgementPage");
 }
}
======================================= end sample code 


I hope this helps. Sorry if I have mistaken your problem in any way, but 
from what information you've given I think this should provide some benifit 
(???). Good luck! 

Troy 


Fedor Smirnoff writes: 

> Hi I have a following situation: 
> 
> 2 .jsp views (New and Edit) using 
> 1 actionform (Product1)
> calling 2 separate actions(1 each)
> 1 is editAction product 
> 1 is newAction product
> both actions will call third SaveAction at the end 
> 
> However depending on which Action(new or edit) user
> came from, different functions will be performed by
> SaveAction. Since I cannot define one input in struts
> config for SaveAction, how can I find out which action
> the call came from to SaveAction ? so I know which
> methods to call and which .jsp to return to in case of
> errors?  Is there a way to do it, or I am going
> completely wrong about it and there is a better way?
> Thank you. 
> 
> __________________________________
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org 
> 
 

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


setting input for action

Posted by Fedor Smirnoff <fe...@yahoo.com>.
Hi I have a following situation:

2 .jsp views (New and Edit) using 
1 actionform (Product1)
calling 2 separate actions(1 each)
1 is editAction product 
1 is newAction product
both actions will call third SaveAction at the end

However depending on which Action(new or edit) user
came from, different functions will be performed by
SaveAction. Since I cannot define one input in struts
config for SaveAction, how can I find out which action
the call came from to SaveAction ? so I know which
methods to call and which .jsp to return to in case of
errors?  Is there a way to do it, or I am going
completely wrong about it and there is a better way?
Thank you.

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Iterate over an Iterator question

Posted by Mykola Ostapchuk <my...@sympatico.ca>.
Hello,

I'm having a problem to iterate with <logic:iterate ..> tag.
I have an Iterator object "allUsers". Here's my code:

<logic:iterate id="users" name="allUsers" scope="request"
type="com.web.users.UsersVO">
     <bean:write name="users" scope="page" property="userFirstName"/>
</logic:iterate>

In Action class:

Iterator allUsers = userBD.selectAllUsers();
request.setAttribute("allUsers", allUsers);

When I use Vector object in this case - everything works fine. With Iterator
object it returns nothing (no error, just nothing).

According to <logic:iterate ...> tag spec:
"Repeats the nested body content of this tag once for every element of the
specified collection, which must be an Iterator, a Collection, a Map (whose
values are to be iterated over), or an array."

Any suggestions - what I'm doing wrong?

Regards,
Mykola


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org