免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3069 | 回复: 2
打印 上一主题 下一主题

[WebLogic] weblogic的EJB调试的问题? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-02-22 14:05 |只看该作者 |倒序浏览
我在weblogic中配置了JDBC和数据源,其中JNDI名称为erp。我在JB中写了一个测试连接的代码如下:
package test1;
import java.sql.*;
import javax.naming.*;
import javax.sql.*;
import java.util.Properties;
import javax.rmi.PortableRemoteObject;
public class Untitled1 {
  public Untitled1() {
  }

  public static void main(String[] args) {
    DataSource ds=null;
    Context ctx=null;
    Connection myConn=null;
    try{
      /**
       * 获得weblogic server JNDI 初始上下文信息
       */
      ctx=getInitialContext();
      /**
       * 建立数据源对象
       */
      ds=(javax.sql.DataSource)ctx.lookup("erp";
      }catch(Exception e){
        System.out.println("Init Error:"+e);
      }
   Statement myStatement=null;
   ResultSet myResultSet=null;
   try{
     /**
      * 建立连接
      */
     myConn=ds.getConnection();
     /**
      * 建立语句对象
      */
     myStatement=myConn.createStatement();
     String str="select * from users";
     /**
      * 建立结果集对象
      */
     myResultSet=myStatement.executeQuery(str);
     /**
      * 篇历结果集对象,访问每条记录,输出字段
      */
     while(myResultSet.next()){
       System.out.println("the users name is"+myResultSet.getString(2));
     }
     //关闭结果集
     myResultSet.close();
     }catch(SQLException e){
       System.out.println("Error code="+e.getErrorCode());
       System.out.println("Error message="+e.getMessage());
     }finally{
       try{
         //关闭语句对象
         if(myStatement!=null){
           myStatement.close();
         }
         //关闭连接
         if(myConn!=null){
           myConn.close();
         }
       }catch(SQLException e){
         System.out.println("Error code="+e.getErrorCode());
         System.out.println("Error message="+e.getMessage());
       }
     }
  }
  private static Context getInitialContext() throws Exception{
    String url="t3://localhost:7001";
    String user="sa";
    String password="jpzhang28";
    Properties properties=null;
    try{
      properties=new Properties();
      properties.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory";
      properties.put(Context.PROVIDER_URL,url);
      if(user!=null){
        properties.put(Context.SECURITY_PRINCIPAL, user);
        properties.put(Context.SECURITY_CREDENTIALS,password==null ? "" : password);
      }
      return new InitialContext(properties);
    }catch(Exception e){
      throw e;
    }
  }
}
在JB中运行时提示这样的错误:D:\bea\jdk142_04\bin\javaw -classpath "C:\Borland\JBuilder2005\jdk1.4\jre\lib\rt.jar;D:\bea\weblogic81\server\lib\weblogic_sp.jar;D:\bea\weblogic81\server\lib\weblogic.jar;D:\bea\weblogic81\server\lib\webservices.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msbase.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\mssqlserver.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jar;D:/bea/jdk142_04/lib/tools.jar;"   -ms64m -mx64m -Djava.library.path="D:/bea/weblogic81/server/bin" -Dbea.home="D:/bea" -Dweblogic.Name=myserver -Djava.security.policy=="D:/bea/weblogic81/server/lib/weblogic.policy" -Dweblogic.management.discover=false -Dweblogic.ProductionModeEnabled=false -Dweblogic.management.password=JPZHANG28 -Dweblogic.management.username=system weblogic.Server  
<2006-2-22 下午12时32分39秒 CST> <Info> <WebLogicServer> <BEA-000377> <Starting WebLogic Server with Java HotSpot(TM) Client VM Version 1.4.2_04-b05 from Sun Microsystems Inc.>
<2006-2-22 下午12时32分40秒 CST> <Info> <Configuration Management> <BEA-150016> <This server is being started as the administration server.>
<2006-2-22 下午12时32分40秒 CST> <Info> <Management> <BEA-141107> <Version: WebLogic Server 8.1 SP3  Tue Jun 29 23:11:19 PDT 2004 404973
WebLogic XMLX Module 8.1 SP3  Tue Jun 29 23:11:19 PDT 2004 404973 >
<2006-2-22 下午12时32分41秒 CST> <Notice> <Management> <BEA-140005> <Loading domain configuration from configuration repository at D:\bea\user_projects\domains\sitoyapp\.\config.xml.>
<2006-2-22 下午12时32分46秒 CST> <Notice> <Log Management> <BEA-170019> <The server log file D:\bea\user_projects\domains\sitoyapp\myserver\myserver.log is opened. All server side log events will be written to this file.>
<2006-2-22 下午12时32分46秒 CST> <Warning> <EmbeddedLDAP> <BEA-171520> <Could not obtain an exclusive lock for directory: .\myserver\ldap\ldapfiles. Waiting for 10 seconds and then retrying in case existing WebLogic Server is still shutting down.>
<2006-2-22 下午12时32分56秒 CST> <Warning> <EmbeddedLDAP> <BEA-171520> <Could not obtain an exclusive lock for directory: .\myserver\ldap\ldapfiles. Waiting for 10 seconds and then retrying in case existing WebLogic Server is still shutting down.>
<2006-2-22 下午12时33分06秒 CST> <Warning> <EmbeddedLDAP> <BEA-171520> <Could not obtain an exclusive lock for directory: .\myserver\ldap\ldapfiles. Waiting for 10 seconds and then retrying in case existing WebLogic Server is still shutting down.>
<2006-2-22 下午12时33分16秒 CST> <Warning> <EmbeddedLDAP> <BEA-171520> <Could not obtain an exclusive lock for directory: .\myserver\ldap\ldapfiles. Waiting for 10 seconds and then retrying in case existing WebLogic Server is still shutting down.>
<2006-2-22 下午12时33分26秒 CST> <Error> <EmbeddedLDAP> <BEA-171519> <Could not obtain an exclusive lock to the embedded LDAP data files directory: .\myserver\ldap\ldapfiles because another WebLogic Server is already using this directory. Ensure that the first WebLogic Server is completely shutdown and restart the server.>
<2006-2-22 下午12时33分26秒 CST> <Critical> <WebLogicServer> <BEA-000364> <Server failed during initialization. Exception:weblogic.server.ServiceFailureException: Could not obtain an exclusive lock to the embedded LDAP data files directory: .\myserver\ldap\ldapfiles because another WebLogic Server is already using this directory. Ensure that the first WebLogic Server is completely shutdown and restart the server.
weblogic.server.ServiceFailureException: Could not obtain an exclusive lock to the embedded LDAP data files directory: .\myserver\ldap\ldapfiles because another WebLogic Server is already using this directory. Ensure that the first WebLogic Server is completely shutdown and restart the server.
        at weblogic.ldap.EmbeddedLDAP.ensureExclusiveAccess(EmbeddedLDAP.java:959)
        at weblogic.ldap.EmbeddedLDAP.initialize(EmbeddedLDAP.java:221)
        at weblogic.t3.srvr.T3Srvr.initializeHere(T3Srvr.java:816)
        at weblogic.t3.srvr.T3Srvr.initialize(T3Srvr.java:670)
        at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:344)
        at weblogic.Server.main(Server.java:32)
>
<2006-2-22 下午12时33分27秒 CST> <Emergency> <WebLogicServer> <BEA-000342> <Unable to initialize the server: weblogic.server.ServiceFailureException: Could not obtain an exclusive lock to the embedded LDAP data files directory: .\myserver\ldap\ldapfiles because another WebLogic Server is already using this directory. Ensure that the first WebLogic Server is completely shutdown and restart the server.>
***************************************************************************
The WebLogic Server did not start up properly.
Exception raised: 'weblogic.server.ServiceFailureException: Could not obtain an exclusive lock to the embedded LDAP data files directory: .\myserver\ldap\ldapfiles because another WebLogic Server is already using this directory. Ensure that the first WebLogic Server is completely shutdown and restart the server.'
Reason: weblogic.server.ServiceFailureException: Could not obtain an exclusive lock to the embedded LDAP data files directory: .\myserver\ldap\ldapfiles because another WebLogic Server is already using this directory. Ensure that the first WebLogic Server is completely shutdown and restart the server.
***************************************************************************
请问这是为什么呢?请高手指教,谢谢

论坛徽章:
0
2 [报告]
发表于 2006-02-22 14:33 |只看该作者
是不是启动了2次阿

论坛徽章:
0
3 [报告]
发表于 2006-02-22 14:43 |只看该作者

应该没有

我是在user projects中启动的,只启动了一次
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP