开发者

Struts basic class loading issue

I have a basic Struts application, which has currently just one action - login. I confirmed that I set up my mappings correctly, and then wanted to add a real action behind it (i.e. something to verify the credentials.

I created a new project, and put in the authentication class there, and then added that project to my Web project's build path. However, now when I try to call my action, I get the following error:

java.lang.ClassNotFoundException: com.mysite.data.managers.Authentication
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
    com.mysite.struts.actions.LoginAction.execute(LoginAction.java:31)

From the other comments and earlier posts, I understand that while my class may compile (which it does), any referenced classes must be located in WEB-INF/lib (potentially within a jar file). This makes sense when the referenced classes are third-party inclusions.

When the referenced开发者_Python百科 class is part of my application (i.e. something I wrote as part of the application, though in a different project), is there no way to reference the project via the build path without exporting the project as a jar and copying that jar to WEB-INF/lib (which would mean that anytime I make a change to those projects, I need to repackage the classes and export again)?

The follow-up to this question is in regard to chaining projects. If there's a reference in Project A to a class in Project B, would I then need to include both projects in WEB-INF/lib?


This seems like more of an Eclipse question than anything else. You didn't mention which version of Eclipse you're using or which Application Server, but let's see if any of this helps.

In your Project's properties, check the Deployment Assembly page. Does the list of Sources include the folder where your source files are compiled to? For an Eclipse Dynamic Web Project, that path is normally WEB-INF/classes. Are your Struts jars listed there as well?

For your follow-up question, you can also include other Projects in that list. I assume that would pick up whatever that Project "exports" in its Build Path settings.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜