j2ee初学者FAQ-近来解决了一个大的问题,目前网上没有解决方案

这个FAQ是根据我学习j2ee遇到的各种问题,包括原书的印刷问题和目前网上没有解决的一些问题总结出来的。(06-12-31)
1.数据库mysql

//String url="jdbc:mysql://localhost:3306/mydata?user=root&password=123";
String url = " jdbc:mysql://localhost:3306/mydata";
//Connection con = DriverManager.getConnection(url);
Connection con = DriverManager.getConnection(url,"root","123");
这两个连接都是正确的。

Connection conn = DriverManager.getConnection(" jdbc:mysql//localhost:3306/mydata","test","test");
System.out.println("get connection");
这个就是错误的。

对比一看原来是书上印调了个冒号。

2. ejb-jar.xml里在第一行后加上dtd描述:
       <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

    否则在执行的时候出现这样的错误:“org.jboss.deployment.DeploymentException: ejb-jar.xml must either obey the right xml schema or define a valid DOCTYPE!”
    eclipse在新建xml文档的时候,会让你选择合适的DTD描述文件。

3.servlet调用ejb出错(这个问题比较的严重,我查了半天的资料没有一个给出了解决方案的):
没有加入jbossall-client.jar的出错信息:
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Servlet execution threw an exception


root cause

java.lang.NoClassDefFoundError
    org.jnp.interfaces.NamingContextFactory.getInitialContext(NamingContextFactory.java:41)
    javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
    javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
    javax.naming.InitialContext.init(InitialContext.java:223)
    javax.naming.InitialContext.<init>(InitialContext.java:197)
    com.soft.ejb.servlet.SearchServlet.displaySearchResult(SearchServlet.java:117)
    com.soft.ejb.servlet.SearchServlet.displayPage(SearchServlet.java:94)
    com.soft.ejb.servlet.SearchServlet.doPost(SearchServlet.java:62)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.15 logs.

含有jbossall-client.jar的出错信息
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Servlet execution threw an exception


root cause

java.lang.NoClassDefFoundError: org/jboss/logging/Logger
    org.jnp.interfaces.NamingContext.<clinit>(NamingContext.java:143)
    org.jnp.interfaces.NamingContextFactory.getInitialContext(NamingContextFactory.java:41)
    javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
    javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
    javax.naming.InitialContext.init(InitialContext.java:223)
    javax.naming.InitialContext.<init>(InitialContext.java:197)
    com.soft.ejb.servlet.SearchServlet.displaySearchResult(SearchServlet.java:117)
    com.soft.ejb.servlet.SearchServlet.displayPage(SearchServlet.java:94)
    com.soft.ejb.servlet.SearchServlet.doPost(SearchServlet.java:62)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.15 logs.

这些错误是因为没有加入足够的包引起的。原来在网上找了半天的资料才发现要把jboss-common-client.jar加上lib中,总算搞定。但是加入了这些可能还是会出错。看下面:

Known Bugs

Q: I installed KIM successfully and I had Tomcat installed before that. SESAME and KIM Server seem to work fine but I get the error (below) when I use Web UI and click to see the Entity Explorer Screen. What is the reason? What can I do?

    ... ... ...    java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:            java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:            java.net.MalformedURLException: no protocol: Files/Apache    ... ... ...    Caused by: java.net.MalformedURLException: no protocol: Files/Apache            at java.net.URL.(URL.java:567)    ... ... ...   

A: There is a bug in the JDK which makes RMI fail if Tomcat is installed in directory containing spaces (e.g. C:/Program Files/Apache Group/Jakarta Tomcat 5.0). This bug won't be fixed, so you can only workaround it.

The installation should have checked the folder name for you and promted you to reinstall Tomcat. If you missed that or renamed the folder after you installed KIM, follow the seme advice now: reinstall Tomcat in a folder (using underscores instead of spaces for example) or just rename folders needed so that the full path contains no spaces. Then reinstall KIM too and point it to the new loacation when asked for Tomcat server, or to skip the new install just manually edit your start/stop Tomcat bat/sh files in %KIM_Platform_Home%/bin directory where this path is used.

For more details refer to:

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4543
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4496398
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4273532
原来这么回事,tomcat不支持目录有空格,我重新下载了一个新的tomcat之后,解压到非空格目录,马上就测试成功了。而且,你必须在你的classes中加入ejb的Home和remote类文件。不然会提示找不到home文件。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值