JBULDER2005 is too "intelligence", resulting in class.fromname () error

xiaoxiao2021-03-06  45

JBULDER2005 is too "intelligence", resulting in class.fromname () error

Develop a lot of meaningless problems with unfamiliar language and development tools.

Although I have been known for Java and JSP, I have not learned to learn. This time because of the needs of the project, you have to go to the Java row of .NET. After receiving the task of New Year's Day, the book and information of J2EE after closing the door have been officially started.

From these more than 2 months of understanding, the Java platform is still in terms of easy operational aspects, and there are still several levels of magnitude.

I used JavaBean to call or explicit declaration a testbean object Web .testbean test = new web.testbean (); this is nothing wrong with it.

I saw a Command mode post last night (http://www.cnjbb.org/thread.jsp?boardid=3&threadid=43244&pageno=last), I want to try it, the problem will appear: I always throw the classnotfoundexception! Posts the main code of the servlet

String classname = Request.getParameter ("classname");

IF (classname == null)

{

Throw new servletexception ("no 'classname' parameter! [? classname =]");

}

Class C = NULL;

Try

{

C = Class.Forname (classname);

Web.controller.icontroller CTL = (iController) C.NewInstance ();

CTL.Execute (Request, Response);

}

Catch (ClassNotFoundException EX)

{

Request.setttribute (Appconfig.ControlleRexecuteerror,

"ClassNotFoundException:" ClassName);

}

Catch (ILLEGALACCESSEXCEPTION EX)

{

Request.setttribute (Appconfig.ControlleRexecuteerror,

"IllegaCcessException");

}

Catch (InstantiationException EX)

{

Request.setttribute (Appconfig.ControlleRexecuteerror,

"IllegaCcessException");

}

Start thinking is a PACKE or class name write error, after confirming that N times ClassName is correct, then the problem is still unresolved.

Suddenly I thought about watching the web-inf / class directory and found the problem!

There is no login.class in the web-inf / classes / web / controller directory. My code package is as shown below

However, in the web-inf / classes / web / controller directory, it can't find login.class. There is indeed login.java in the SRC directory of the project, and found login.class in the Class directory of the project, but why is it in the publisher? Going to login.class? Where is this file run? Searching in Google and Baidu has not found the answer for a long time.

Asked a few friends around Java, I haven't seen this problem, they use JBuilderx, I thought it was the jbuilder2005 bug. I can't compile it with JBBuilderx on another.

Do you really want me to copy the .class file in the Class directory every time rebuild? !

I have all the configuration of JBilder, I finally found the answer. Right-click Web-> Properties

In the properties of the web module, Borland's role is said to this page.

The Content page of the Module Properties dialog box is where you choose which packages, classes, and resources to include in the archive file. You can accept the default which includes everything in the project, or you can choose specific packages, classes, files, And Resources. You can also create Custom Filters That Include or Exclude Specific Items.

Which files can be configured in this page included in the Publish Package (.war). There are a few priorities here.

INCLUDE All Classes and Resources

All classes and resources are incrry in the archive.

INCLUDE Specified Filtered Files and Their Deprondencies

Only the files and files list box and the only include module specific Java classes option

Include Specified Filters and Files ONLY

ONLY THE FILTERSY

You can choose the first include all classes and resources or select the second include specified filter files and their dependencies, then add files, add the file you need.

One thing I don't know why if it is , it will automatically copy the corresponding .class to the web-inf / class directory, but if there is no explicit use in all .jsp and .java files. If a class, you will not copy the past. If the login I just said is an icontroller interface, only this is used in the code.

C = class.Forname (classname); web.controller.icontroller CTL = (iController) c.newinstance ();

CTL.Execute (Request, Response);

JB thinks that I have not used the login class, "intelligent" excludes this class from the WAR file. It is this "intelligent" to give this harm.

The battle has just begun, I don't know what can I have.

转载请注明原文地址:https://www.9cbs.com/read-53358.html

New Post(0)