mardi 19 janvier 2010

[转]15 个第三方 Web 表单资源

http://www.cnbeta.com/articles/102464.htm

新闻来源:vandelaydesign.com
几乎每个 Web 站点都需要表单,不管是留言表单,还是会员注册表单,还是调查表或订单,尽管表单很有用,但对 Web 开发与设计者来说,表单的设计非常繁琐,本文搜集了15个免费或收费的第三方 Web 表单资源,可以轻松实现 Web 表单的设计与集成,它们中的一些还可以帮你实现非常专业的表单设计。 表单创建资源
FormSpring

FormSpring 可以创建标准的联系,调查,捐赠接收,注册等表单,无需编码,它会帮你管理和接收数据,甚至集成付款功能。分免费和收费两种服务,免费服务允许创建3个表单,每个表单10个栏,每月接收50次数据。

FormSpring

Wufoo

Wufoo 可以实现联系,调查,注册,在线支付等表单的设计,可以使用模板,包含多种报告,同样,也包含免费和收费服务。免费服务允许一个用户,3个表单,3个报告,10个栏,每月100次数据。

Wufoo

Icebrrg

Icebrrg 可用于创建联系,注册,调查,应用程序等表单,可以查看发送的数据或将数据导出到 Excel 文件。为收费服务,不包含免费或试用服务。

Icebrrg

FormSite

FormSite 用于超过100个预定义表单,并可以进行定制以符合自己的要求,可以创建联系,调查,这册,订单等表单,免费服务可以创建5个表单,每月100次数据。

FormSite

FormExperts

FormExperts 包含上百个模板,可用来创建各种 Web 表单,支持自动回复,自定义感谢页面以及自定义邮件格式,可以免费试用10天。

FormExperts

MachForm

MatchForm 可以帮你设计 PHP 表单,这是一个独立程序(有别于前面的托管服务),用 MySQL 数据库存储数据,单站点许可39美金。

MachForm

Email Me Form

Email Me Form 是一个在线服务,用来创建 HTML 或 PHP 表单,收费服务可以去掉 Email Me Form 的反向链接。

Email Me Form

FormLogix

FormLogix 可以用来创建反馈,调查,投票,注册,邀请,在线支付等表单,免费服务只用于测试。

FormLogix

FormAssembly

FormAssembly 可用于创建联系,注册,订单等 Web 表单,免费服务包含广告链接。

FormAssembly

Visitor Contact

这一个免费资源,包含 WordPress 插件,顾名思义,主要用于创建联系表单,功能包括自动回复,显示用户地理位置,还可以导出数据。

Visitor  Contact

Contactable

这是一个来自 theodin.co.uk 的 jQuery 插件,可以轻松实现联系与反馈表单。

Contactable
WordPress 插件
Gravity Forms

这是一个收费 WordPress 插件(39美金),可用于创建各种 Web 表单,可以集成到 WordPress 控制面板。

Gravity  Forms

CForms II

这是一个功能强大的联系表单创建插件。

CForms  II

Contact Form 7

这是一个非常受欢迎的联系表单设计插件,非常容易上手,可以轻松创建各种表单并插入到页面。

Contact Form 7

Fast and Secure Contact Form

该插件可以创建安全联系表单,使用 CAPTCHAs 与 Akismet 防止垃圾信息。

Fast and Secure Contact Form

本文来源:http://vandelaydesign.com/blog/tools/web-forms/
中文翻译来源:COMSHARP CMS 网站内容管理系统官方站

lundi 11 janvier 2010

【转】菜谱:洋葱牛肉丝

洋葱牛肉丝的做法:

主料:牛肉300克,洋葱250克�

辅料:鸡蛋清1个,淀粉10克,酱油、盐、料酒、白糖各适量,味精、胡椒粉各少许,食油50克。

做法: 1.牛肉洗净,切成筷子般粗的条形,放入酱油适量,盐少许腌约10分钟;洋葱纵切两半,再横切成条备用。

2.腌好的牛肉用鸡蛋清1个、淀粉、料酒、白糖、味精、胡椒粉和少量的食油拌匀,然后放入小火低温的热油中泡至嫩熟。

3.炒锅上火,倒油烧热,放入洋葱炒至变色,即下牛肉煸炒片刻,将酱抽、盐、料酒、白糖倒入,用淀粉勾芡,加入味精、胡椒粉,炒匀即可出锅上碟。

特点:此菜肉质滑软,口味清爽鲜香。

【转】Java操作SQL数据库[查询,更新,存储过程,类型对照]

一,SQL复习

1,SQL语句分为两类:DDL(Data Definition Language)和DML(Dat Manipulation Languge,数据操作语言)。前者主要是定义数据逻辑结构,包括定义表、视图和索引;DML主要是对数据库进行查询和更新操作。

2,Create Table(DDL):

Create Table tabName(
colName1 colType1 [else],
colName2 colType2 [else],
...,
colNamen colTypen [else]
);

例如:Cteate Table pJoiner(
pno char(6) not null,
eno char(6) nut null
);

char int varchar等等都是用来定义列数据类型的保留字,其中varchar表示可变字符类型。

3,Select ,,...,
From ,,...,
[Where<条件>]

条件中的子查询:

Where Not Exists(
Select * From tab2 Where col1=col2
)//当查询结果为空时,条件为真。

4,INSERT INTO VALUES(, ...)

5,DELETE FROM [WHERE<条件>]

6,UPDATE
SET =
...
=
[WHERE<条件>]

例如:
Update exployee
Set age=27
Where name=''赵一''

二,JDBC 主要接口:

java.sql.DriverManager类用于处理驱动程序的调入并且对新的数据库连接提供支持。
java.sql.Connection,指应用程序与特定数据库的连接。
java.sql.Statement,用于一般sql语句的执行(可以是查询、更新甚至可以创建数据库的执行过程)
java.sql.ResultSet,查询所返回的结果保存在此对象中,用它可以浏览和存取数据库内的记录。

1,通过jdbc-odbc桥使用odbc数据库(并不需要jdbc Drivers)
先在odbc DSN(Data Source Name)设置处设置pubs sysDSN,sa为username,密码为空

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//加载驱动程序
con=DriverManager.getConnection("jdbc:odbc:pubs","sa","");//jdbc:odbc:pubs
con.close();
//应当catch ClassNotFoundException和SQLException
Connection的getWarning方法返回一个SQLWarning对象,在连接之前应当先检查。
使用jdbc-odbc的最大好处是:免费的。但是性能受odbc的限制,而且一般odbc驱动比较昂贵。

2,使用专门的jdbc驱动程序。//此处是mm jdbc Driver
先将jar文件放在ClassPath里面。
Class.forName("org.gjt.mm.mysql.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/dbname","root","");
con.close();

可见使用何种方式连接何种数据库与数据库的操作和连接数据库是无关的。

三,查询数据库

Statement stmt=con.createStatement();
stmt.setMaxRows()可以控制输出记录最大数量;
ResultSet rs=stmt.executeQuery("select .....");
ResultSet指向当前记录:
int userId=rs.getInt("userid");
String userName=rs.getString("username");

...或者用序号(从1开始的)

int userId=rs.getInt(1);
Stirng userName=rs.getString(2);
ClassNotFoundException是由于Class.forName()无法载入jdbc驱动程序触发的

SQLException是jdbc在执行过程中发生问题时产生。有一个额外的方法getNextException()
catch(SQLException e){
out.println(e.getMessage());
while(e=e.getNextException()){
out.println(e.getMessage());
}

}

一般来说并不建议在jsp中编写数据库的访问程序,可以将数据库的访问封装在一个javabean中。

四,ResultSet深入

1,ResultSetMetaData
ResultSet rs=stmt.executeQuery("select....");
ResultSetMetaData rsmd=rs.getMetaData(); //获取ResultSetMateData对象
int numberOfColumns=rsmd.getColumnCount();//返回列数
boolean b=rsmd.isSearchable(int i);//返回第i列是否可以用于where子句
String c=rsmd.getColumnLabel(int i);//获取第i列的列标
Objcet obj=rs.getObject();
if(obj!=null)out.println(obj.toString());
else println("");

2,SQL类型与ResultSet的getObject返回类型及对应的XXX getXXX()方法
SQL类型 JSP类型 对应的getXXX()方法
————————————————————————————————————————————
CHAR - String - String getString()
VARCHAR - String - String getString()
LONGVARCHAR - String - InputStream getAsciiStream()/getUnicodeStream()
NUMERIC - java.math.BigDecimal - java.math.BigDecimal getBigDecimal()
DECIMAL - 同上
BIT - Boolean - boolean getBoolean()
TINYINT - Integer - byte getByte()
SMALLINT - Integer - short getShort()
INTEGER - Integer - int getInt()
BIGINT - Long - long getLong()
REAL - Float - float getFloat()
FLOAT - Double - double getDouble()
DOUBLE - Double - double getDouble()
BINARY - byte[] - byte[] getBytes()
VARBINARY - byte[] - byte[] getBytes()
LONGVARBINARY - byte[] - InputStream getBinaryStream()
DATE - java.sql.Date - java.sql.Date getDate()
TIME - java.sql.Time - java.sql.Time getTime()
TIMESTAMP - java.sql.Timestamp - java.sql.Timestamp getTimestamp()

3,null
int i=rs.getInt("age");
if(!rs.wasNull())....//RecordSet::wasNull()用来检查null

4,存取大字符串和二进制文本
对于数据库中longvarchar和langvarbinary进行流操作
ResultSet rs=stmt.executeQueryString("select ...");
BufferedReader br=new BufferedReader(new InputStream(rs.getAsciiStream("vol1")));//长文本串
BufferedReader br=new BufferedReader(new InputStream(rs.getUnicodeStream("vol1")));
BufferedReader br=new BufferedReader(new InputStream(rs.getBinaryStream("vol2")));//长二进制文本
//取数据必须在rs.getAsciiStream(), rs.getUnicodeStream(), rs.getBinaryStream()等之后马上进行
五,浏览ResultSet
1,JDBC2.0提供了更多浏览ResultSet的方法
首先,确定你的jdbc驱动程序支持jdbc2.0
其次,由Connection生成Statement时要指定参数
Statement stmt=con.getStatement("游标类型", "记录更新权限");
游标类型:
ResultSet.TYPE_FORWORD_ONLY:只可以向前移动
ResultSet.TYPE_SCROLL_INSENSITIVE:可卷动。但是不受其他用户对数据库更改的影响。
ResultSet.TYPE_SCROLL_SENSITIVE:可卷动。当其他用户更改数据库时这个记录也会改变。

记录更新权限:
ResultSet.CONCUR_READ_ONLY,只读
ResultSet.CONCUR_UPDATABLE,可更新
getStatement()缺省参数:getStatement(ResultSet.TYPE_FORWORD_ONLY, ResultSet.CONCUR_READ_ONLY)

2,如果ResultSet是可卷动的,以下函数可以使用:
rs.absolute()//绝对位置,负数表示从后面数
rs.first()第一条
rs.last()最后一条
rs.previoust()前一条
rs.next()后一条
rs.beforeFirst()第一条之前
rs.afterLast()最后之后
rs.isFirst(),rs.isLast(),rs.isBeforeFirst(),rs.isAfterLast

注意,刚打开的时候是处于第一条记录之前的

六,更新数据库

1,stmt.executeUpdate("strSql"),strSql是一条sql更新语句。update,insert,delete返回影响到的条数
2,stmt.execute()方法在不知道sql语句是查询还是更新的时候用。如果产生一条以上的对象时,返回true,此时可用stmt.getResultSet()和stmt.getUpdateCount()来获取execute结果,如果不返回ResultSet对象则返回false.
3,除了Statement的executeUpdate之外还可以用ResultSet:
rs.updateInt(1,10);
rs.updateString(2,"sfafd");
rs.updateRow();

七,使用预编译PreparedStatement

PreparedStatement对象和Statement对象类似,都可以用来执行SQL语句。不同在于,数据库会对PreparedStatement的SQL语句进行预编译,而且仍旧能输入参数并重复执行编译好的查询速度比未编译的要快。
PreparedStatement stmt=con.preparedStatement("Insert Into users(userid, username) values(?,?)");
stmt.clearParameters();
stmt.setInt(1,2);
stmt.setString(2,"Big");
stmt.executeUpdate();

八,执行存储过程

1,JDBC调用存储过程,并使用存储过程的返回值。这样可以将处理工作分为服务端和客户端两部分,并大大加快系统的设计和开发的时间。比如可以重复使用服务器上的组件。使用存储过程之后大量诸计算工作可以交给数据库服务器来处理,这将降低Web服务器的负载,从而提高整个系统的性能。

2,有两个表UserMain{UserID,UserName,UserType},UserRef{BrefID, UserID, UserBrief}
下面的存储过程可以接受jdbc传来的参数,新增内容到UserMain和UserRef,并输出一个OutUserID.
CREATE PROCEDURE ap_adduser
(
@OutUserID int output, //此为输出参数,output标记
@UserName varchar(25), //参数表示方法:"@XXX"为变量名,"变量名 类型 [output]"
@UserType tinyint,
@UserBrief varchar(255),
)

AS
Declare @UserID int //定义局部变量
insert into UserMain(UserName, UserType)
values(@UserName,@UserType)
select @UserID=@@IDENTITY //赋值用select,此处自动获得ID
insert into UserRef(UserID, UserBrief)
select @OutUserID=@UserID
GO/*结束,基本结构:
CREATE PROCEDURE procedureName(
parameters
)

AS
actions
GO
*/


JSP页面中这样使用:
CallableStatement stmt=con.prepareCall("{call ap_adduser(?,?,?,?)}");
stmt.registerOutParameter(1,Types.INTEGER,1);//注册输出变量
stmt.setString(2,"edmund");
stmt.setInt(3,1);
stmt.setString(4,"description");
stmt.execute();
int userid=stmt.getInt(1);
stmt.close()

八,使用事务

1,事务中的操作是一个整体,要么都执行成功要么都不成功:事务开始后,如果所有的改变都正确,则使用commit方法将这些动作全部存入数据库,否则就使用rollback取消所有的改变动作,而这时数据库中的数据和执行事务前的是相同的。

2,使用事务时应当先用 con.setAutoCommit(false),最后使用commit或者rollback

3,rollback一般在catch段执行

九,数据库连接池

1,如果有一个数据库连接请求并且连接中没有连接,则生成一个新的连接。这个连接使用完之后并不关闭它,而是将它放入连接池。在这个过程中,还要判断连接池中的连接是否超期。如果超期则将它关闭。

2,有很多已有的Connection Pool包可以使用。

3,一般将Connection Pool作为一个application作用域的变量使用

<%@page import="java.sql.*"%>
<%@page import="javastart.tools.*"%>

DBConnection con=null;
try{
con=pool.getConnection("sun.jdbc.odbc.JdbcOdbcDriver","jdbc:odbc:access","","");
Statement stmt=con.createStatement();
stmt.setMaxRows(10);
String query=request.getParameter("quey");
ResultSet rs=stml.executeQuery(query);
ResultSetMetaData rsmd=rs.getMetaData();
}
.....
finally{
pool.releaseConnection(con);
}

也可以使用一个Servlet初始化连接池

mardi 5 janvier 2010

RMI ClassNotFoundException

RMI

多主机运行RMI 代码,遇到类似如下的错误:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: examples.callback.MessageReceiverImpl_Stub

需要把Stub 类放在Internet 能访问到的目录下!

× 需要一个安全侧略文件:
grant codeBase "file:/Users/cwang/Documents/workspace/hocl/bin/" {
permission java.security.AllPermission;
};

×显示指出哪里能找到Stub 类:
-Djava.rmi.server.codebase=file:/Users/cwang/Documents/workspace/hocl/bin/

×指明本RMI 主机HOSTNAME,如没有可用IP 代替:
-Djava.rmi.server.hostname=131.254.14.42

【转】Dynamic code downloading using RMI


Dynamic code downloading using RMI
(Using the java.rmi.server.codebase Property)



This tutorial is organized as follows:
  1. Starting out
  2. What is a codebase?
  3. How does it work?
  4. Using codebase in RMI for more than just stub downloading
  5. Command-line examples
  6. Troubleshooting tips


1.0 Starting out

One of the most significant capabilities of the JavaTM platform is the ability to dynamically download Java software from any Uniform Resource Locator (URL) to a Java virtual machine* (JVM) running in a separate process, usually on a different physical system. The result is that a remote system can run a program, for example an applet, which has never been installed on its disk. For the first few sections of this document, codebase with regard to applets will be discussed in order to help describe codebase with regard to Java Remote Method Invocation (RMI).
For example, a JVM running from within a web browser can download the bytecodes for subclasses of java.applet.Applet and any other classes needed by that applet. The system on which the browser is running has most likely never run this applet before, nor installed it on its disk. Once all the necessary classes have been downloaded from the server, the browser can start the execution of the applet program using the local resources of the system on which the client browser is running.
Java RMI takes advantage of this capability to download and execute classes and on systems where those classes have never been installed on disk. Using the RMI API any JVM, not only those in browsers, can download any Java class file including specialized RMI stub classes, which enable the execution of method calls on a remote server using the server system's resources.
The notion of a codebase originates from the use of ClassLoaders in the Java programming language. When a Java program uses a ClassLoader, that class loader needs to know the location(s) from which it should be allowed to load classes. Usually, a class loader is used in conjunction with an HTTP server that is serving up compiled classes for the Java platform. Most likely, the first ClassLoader/codebase pairing that you came into contact with was the AppletClassLoader, and the "codebase" part of the HTML tag, so this tutorial will assume that you have some experience with Java RMI programming, as well as writing HTML files that contain applet tags. For example, the HTML source will contain something like:




2.0 What is a codebase?

A codebase can be defined as a source, or a place, from which to load classes into a Java virtual machine. For example, if you invited a new friend over for dinner, you would need to give that friend directions to the place where you lived, so that he or she could locate your house. Similarly, you can think of a codebase as the directions that you give to a JVM, so it can find your [potentially remote] classes.
You can think of your CLASSPATH as a "local codebase", because it is the list of places on disk from which you load local classes. When loading classes from a local disk-based source, your CLASSPATH variable is consulted. Your CLASSPATH can be set to take either relative or absolute path names to directories and/or archives of class files. So just as CLASSPATH is a kind of "local codebase", the codebase used by applets and remote objects can be thought of as a "remote codebase".

3.0 How does it work?

3.1 How codebase is used in applets

To interact with an applet, that applet and any classes that it needs to run must be accessible by remote clients. While applets can be accessed from "ftp://" or local "file:///" URLs, they are usually accessed from a remote HTTP server.
  1. The client browser requests an applet class that is not found in the client's CLASSPATH
  2. The class definition of the applet (and any other class(es) that it needs) is downloaded from the server to the client using HTTP
  3. The applet executes on the client

illustrates three steps above Figure 1: Downloading applets

The applet's codebase is always relative to the URL of the HTML page in which the tag is contained.

3.2 How codebase is used in RMI

Using RMI, applications can create remote objects that accept method calls from clients in other JVMs. In order for a client to call methods on a remote object, the client must have a way to communicate with the remote object. Rather than having to program the client to speak the remote object's protocol, RMI uses special classes called stubs that can be downloaded to the client that are used to communicate with (make method calls on) the remote object. The java.rmi.server.codebase property value represents one or more URL locations from which these stubs (and any classes needed by the stubs) can be downloaded.
Like applets, the classes needed to execute remote method calls can be downloaded from "file:///" URLs, but like applets, a "file:///" URL generally requires that the client and the server reside on the same physical host, unless the file system referred to by the URL is made available using some other protocol, such as NFS.
Generally, the classes needed to execute remote method calls should be made accessible from a network resource, such as an HTTP or FTP server.

illustrates the first 5 steps of the stub downloadling process, as listed below Figure 2: Downloading RMI stubs

  1. The remote object's codebase is specified by the remote object's server by setting the java.rmi.server.codebase property. The RMI server registers a remote object, bound to a name, with the RMI registry. The codebase set on the server JVM is annotated to the remote object reference in the RMI registry.
  2. The RMI client requests a reference to a named remote object. The reference (the remote object's stub instance) is what the client will use to make remote method calls to the remote object.
  3. The RMI registry returns a reference (the stub instance) to the requested class. If the class definition for the stub instance can be found locally in the client's CLASSPATH , which is always searched before the codebase, the client will load the class locally. However, if the definition for the stub is not found in the client's CLASSPATH, the client will attempt to retrieve the class definition from the remote object's codebase.
  4. The client requests the class definition from the codebase. The codebase the client uses is the URL that was annotated to the stub instance when the stub class was loaded by the registry. Back in step 1, the annotated stub for the exported object was then registered with the RMI registry bound to a name.
  5. The class definition for the stub (and any other class(es) that it needs) is downloaded to the client.
  6. Note: Steps 4 and 5 are the sames steps that the registry took to load the remote object class, when the remote object was bound to a name in (registered with) the RMI registry. When the registry attempted to load the remote object's stub class, it requested the class definition from the codebase associated with that remote object.
  7. Now the client has all the information that it needs to invoke remote methods on the remote object. The stub instance acts as a proxy to the remote object that exists on the server; so unlike the applet which uses a codebase to execute code in its local JVM, the RMI client uses the remote object's codebase to execute code in another, potentially remote JVM, as illustrated in Figure 3:

illustrates the final step of the above procedure Figure 3: RMI client making a remote method call

4.0 Using codebase in RMI for more than just stub downloading

In addition to downloading stubs and their associated classes to clients, the java.rmi.server.codebase property can be used to specify a location from which any class, not only stubs, can be downloaded.
When a client makes a method call to a remote object, the method that it calls could be written to accept no arguments or a number of arguments. There are three distinct cases that may occur, based on the data type(s) of the method argument(s).
In the first case, all of the method parameters (and return value) are primitive data types, so the remote object knows how to interpret them as method parameters, and there is no need to check its CLASSPATH or any codebase.
In the second case, at least one remote method parameter or the return value is an object, for which the remote object can find the class definition locally in its CLASSPATH.
In the third case (shown as Step 6, in Figure 4), the remote method receives an object instance, for which the remote object cannot find the class definition locally in its CLASSPATH. This type of remote method call is illustrated in Figure 4. The class of the object sent by the client will be a subtype of the declared parameter type. A subtype is either:
  • An implementation of the interface that is declared as the method parameter (or return) type
  • A subclass of the class that is declared as the method parameter (or return) type

Illustrates passing an unknown  subtype as a method parameter, as described above and below. Figure 4: RMI client making a remote method call, passing an unknown subtype as a method parameter

7. Like the applet's codebase, the client-specified codebase is used to download Remote classes, non-remote classes, and interfaces to other JVMs. If the codebase property is set on the client application, then that codebase is annotated to the subtype instance when the subtype class is loaded by the client. If the codebase is not set on the client, the remote object will mistakenly use its own codebase.

5.0 Command-line examples

In the case of an applet, the applet codebase value is embedded in an HTML page, as we saw in the HTML example in the first section of this tutorial.
In the case of Java RMI codebase, rather than having a reference to the class embedded in an HTML page, the client first contacts the RMI registry for a reference to the remote object. Because the remote object's codebase can refer to any URL, not just one that is relative to a known URL, the value of the RMI codebase must be an absolute URL to the location of the stub class and any other classes needed by the stub class. This value of the codebase property can refer to:
  • The URL of a directory in which the classes are organized in package-named sub-directories
  • The URL of a JAR file in which the classes are organized in package-named directories
  • A space-delimited string containing multiple instances of JAR files and/or directories that meet the criteria above
Note: When the codebase property value is set to the URL of a directory, the value must be terminated by a "/".

Examples

If the location of your downloadable classes is on an HTTP server named "webvector", in the directory "export" (under the web root), your codebase property setting might look like this:
-Djava.rmi.server.codebase=http://webvector/export/
If the location of your downloadable classes is on an HTTP server named "webline", in a JAR file named "mystuff.jar", in the directory "public" (under the web root), your codebase property setting might look like this:
-Djava.rmi.server.codebase=http://webline/public/mystuff.jar
Now let's suppose that the location of your downloadable classes has been split between two JAR files, "myStuff.jar" and "myOtherStuff.jar". If these JAR files are located on different servers (named "webfront" and "webwave"), your codebase property setting might look like this:
-Djava.rmi.server.codebase="http://webfront/myStuff.jar http://webwave/myOtherStuff.jar"

6.0 Troubleshooting tips

Any serializable class, including RMI stubs, can be downloaded if your RMI programs are configured properly. Here are the conditions under which dynamic stub downloading will work:
  1. The stub class and any of the classes that the stub relies on are served up from a URL reachable from the client.
  2. The java.rmi.server.codebase property has been set on the server program (or in the case of activation, the "setup" program) that makes the call to bind or rebind, such that:
    • The value of the codebase property is the URL in step A and
    • If the URL specified as the value of the codebase property is a directory, it must end in a trailing "/"
  3. The rmiregistry cannot find the stub class or any of the classes that the stub relies on in its CLASSPATH. This is so the codebase gets annotated to the stub when the registry does its class load of the stub, as a result of calls to bind or rebind in the server or setup code.
  4. The client has installed a SecurityManager that allows the stub to be downloaded. In the Java 2 SDK, Standard Edition, v1.2 and later this means that the client must also have a properly configured security policy file.
There are two common problems associated with the java.rmi.server.codebase property, which are discussed next.

6.1 If you encounter a problem running your RMI server

The first problem you might encounter is the receipt of a ClassNotFoundException when attempting to bind or rebind a remote object to a name in the registry. This exception is usually due to a malformed codebase property, resulting in the registry not being able to locate the remote object's stubs or other classes needed by the stub.
It is important to note that the remote object's stub implements all the same interfaces as the remote object itself, so those interfaces, as well as any other custom classes declared as method parameters or return values, must also be available for download from the specified codebase.
Most frequently, this exception is thrown as a result of omitting the trailing slash from the URL value of the property. Other reasons would include: the value of the property is not a URL; the path to the classes specified in the URL is incorrect or misspelled; the stub class or any other necessary classes are not all available from the specified URL.
The exception that you may encounter in such a case would look like this:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: examples.callback.MessageReceiverImpl_Stub
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: examples.callback.MessageReceiverImpl_Stub
java.lang.ClassNotFoundException: examples.callback.MessageReceiverImpl_Stub
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Compiled Code)
at sun.rmi.transport.StreamRemoteCall.executeCall(Compiled Code)
at sun.rmi.server.UnicastRef.invoke(Compiled Code)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Compiled Code)
at java.rmi.Naming.rebind(Compiled Code)
at examples.callback.MessageReceiverImpl.main(Compiled Code)
RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: examples.callback.MessageReceiverImpl_Stub

6.2 If you encounter a problem running your RMI client

The second problem you could encounter is the receipt of a ClassNotFoundException when attempting to lookup a remote object in the registry. If you receive this exception in a stacktrace resulting from an attempt to run your RMI client code, then your problem is the CLASSPATH with which your RMI registry was started. See requirement C in section 6.0. Here is what the exception will look like:
java.rmi.UnmarshalException: Return value class not found; nested exception is:
java.lang.ClassNotFoundException: MyImpl_Stub
at sun.rmi.registry.RegistryImpl_Stub.lookup(RegistryImpl_Stub.java:109
at java.rmi.Naming.lookup(Naming.java:60)
at RmiClient.main(MyClient.java:28)

Other resources

If you your codebase questions are still unanswered, please take a look through the archives of the rmi-users email list first.
You may wish to subscribe to the rmi-users email list.
We are very interested in knowing whether these tutorials are useful. Please send any comments or suggestions to: rmi-comments@java.sun.com, with a subject of "codebase tutorial".
*As used on this web site, the terms "Java virtual machine" or "JVM" mean a virtual machine for the Java platform.

Copyright © 2003 Sun Microsystems, Inc. All Rights Reserved.
Please send comments to: rmi-comments@java.sun.com

http://java.sun.com/j2se/1.4.2/docs/guide/rmi/codebase.html#sixStepC