`
cooper
  • 浏览: 494 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
文章分类
社区版块
存档分类
最新评论

web service中的jndi问题

阅读更多
项目需要通过jndi获得远程ejb对象,在把相应的操作发布成web service供.net调用

直接通过JNDI访问没有问题,web service发布也没问题,可以查看wsdl,但是在web service服务端里使用JNDI获得远程EJB就报错了

难道在web service中不能使用jndi???

提供的service方法为:
public FindCdmaResponse findCdma(FindCdmaRequest request) {

FindCdmaResponse response = new FindCdmaResponse();

try {
OSSInterface oss = JNDIUtil.getOSSInterface();

List list = oss.findCdmaAccNbrByWHRX(request.getDistNbr(), request.getNxxNbr(), request.getLineNbr(), request.getCount(), request.getLocalNetId());

PhoneNumber[] numbers = new PhoneNumber[list.size()];
for (int i = 0; i < list.size(); i++) {
Map m = (Map) list.get(i);
numbers[i] = new PhoneNumber();
numbers[i].setAccNbr((String) m.get("AccNbr"));
numbers[i].setAreaId((String) m.get("AreaId"));
numbers[i].setAccNbrClassId((String) m.get("AccNbrClassId"));
numbers[i].setAccNbrClassName((String) m.get("AccNbrClassName"));
numbers[i].setAgentId((String) m.get("AgentId"));
numbers[i].setWorkAreaId((String) m.get("WorkAreaId"));
numbers[i].setWorkAreaName((String) m.get("WorkAreaName"));
numbers[i].setIsAdvance((String) m.get("IsAdvance"));
}

response.set_return(numbers);
} catch (RemoteException e) {
e.printStackTrace();
} catch (CreateException e) {
e.printStackTrace();
} catch (NoDataException e) {
e.printStackTrace();
} catch (InterfaceException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}

return response;
}

public class JNDIUtil {

private static final String JNDI_NAME = "OSSInterface";
private static final String PROVIDER_URL = "t3://133.0.176.229:5001";
private static final String SECURITY_PRINCIPAL = "weblogic";
private static final String SECURITY_CREDENTIALS = "weblogic";

public static Context getInitialContext() throws Exception {
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL, PROVIDER_URL);
p.put(Context.SECURITY_PRINCIPAL, SECURITY_PRINCIPAL);
p.put(Context.SECURITY_CREDENTIALS, SECURITY_CREDENTIALS);

return new InitialContext(p);
}

public static OSSInterface getOSSInterface() throws Exception {

Context cxt = getInitialContext();
Object objRef = cxt.lookup(JNDI_NAME);
OSSInterfaceHome home = (OSSInterfaceHome) PortableRemoteObject.narrow(
objRef, OSSInterfaceHome.class);

return home.create();
}

}


直接通过JNDI访问
public class JNDITest {

/**
* @param args
*/
public static void main(String[] args) {

try {
OSSInterface oss = JNDIUtil.getOSSInterface();

List list = oss.findCdmaAccNbrByWHRX("027", "1330", "%29%",new Integer(10), new Integer(1001));

for (int i = 0; i < list.size(); i++) {
System.out.println(i + ":" + list.get(i));
}
} catch (RemoteException e) {
e.printStackTrace();
} catch (CreateException e) {
e.printStackTrace();
} catch (InterfaceException e) {
e.printStackTrace();
} catch (NoDataException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}

}

}

通过客户端调用
public void testfindCdma() throws java.lang.Exception {

String url = "http://localhost:8080/axis2/services/QiangHaoService";
QiangHaoServiceStub stub = new QiangHaoServiceStub(url);
FindCdmaRequest request = (FindCdmaRequest) getTestObject(FindCdmaRequest.class);

request.setDistNbr("027");
request.setNxxNbr("1330");
request.setLineNbr("%29%");
request.setCount(10);
request.setLocalNetId(1001);
PhoneNumber[] numbers = stub.findCdma(request).get_return();
for (int i = 0; i < numbers.length; i++) {
System.out.println(numbers[i].getAccNbr() + "," + numbers[i].getWorkAreaId() + ","
+ numbers[i].getAccNbrClassId() + "," + numbers[i].getAccNbrClassName() + ","
+ numbers[i].getAgentId() + "," + numbers[i].getWorkAreaId() + ","
+ numbers[i].getWorkAreaName() + "," + numbers[i].getIsAdvance());
}
assertNotNull(stub.findCdma(request));

}

错误日志
org.apache.axis2.AxisFault: weblogic.utils.AssertionError: ***** ASSERTION FAILED *****[ Failed to generate class for com.cattsoft.ibss.hub.intf.OSSInterface_trgpb2_HomeImpl_815_WLStub ] - with nested exception:
[java.lang.reflect.InvocationTargetException - with target exception:
[java.lang.IllegalAccessError: tried to access method weblogic.rmi.internal.StubInfo.getInterfaces(Ljava/lang/ClassLoader;)[Ljava/lang/Class; from class com.cattsoft.ibss.hub.intf.OSSInterface_trgpb2_HomeImpl_815_WLStub]]
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:512)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:370)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
at com.ws.QiangHaoServiceStub.findCdma(QiangHaoServiceStub.java:186)
at test.QiangHaoServiceTest.testfindCdma(QiangHaoServiceTest.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:79)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
分享到:
评论

相关推荐

    jboss-web.xml jndi.properties oracle-ds.xml

    jboss-web.xml jndi.properties oracle-ds.xml三个文件,EJB+JPA 所需要的一些配置文件

    在jboss上部署web应用

    它还提供一些高级特性,比如集群、JMX、Web Service。它还整合了IIOP(Internet Inter-ORB Protocol)。 因为JBoss代码遵循LGPL许可,你可以在任何商业应 用中免费使用它,而不用支付费用。JBoss是纯Java的Web应用...

    CXF Web Service(前台:C#,后台:java)完整例子

    【注意:本人忘记把下面内容放入文档中】本人采用了JNDI来连接数据库。tomcat里面的配置:在%tomcat%\conf\下面有个context.xml文件。在&lt;Context&gt;&lt;/Context&gt;之间添加 auth="Container" type="javax.sql....

    Java.EE.7.Essentials

    Web Service Endpoints Provider-Based Dynamic Endpoints Endpoint-Based Endpoints Web Service Client Dispatch-Based Dynamic Client Handlers Chapter 6 : JSON Processing Streaming API ...

    Jetty中文手册

    在JNDI中配置数据源(DataSource) 内嵌Jetty服务器 内嵌Jetty教程 内嵌Jetty的HelloWorld教程 内嵌Jetty视频 优化Jetty 如何配置垃圾收集 如何配置以支持高负载 在Jetty中部署应用 部署管理器 部署绑定 热部署 ...

    金蝶BOSV6.1_业务组件API参考手册

    com.kingdee.bos.transaction.springframework.jndi com.kingdee.bos.transaction.springframework.transaction com.kingdee.bos.transaction.springframework.transaction.interceptor ...

    ALBPM基础教程.doc

    该工具支持多种接口标准,如Java、.NET、EJB、JNDI、Web Service、XML、CORBA、COM和SQL等。另外,开发人员能方便地组合用户界面,使人员参与到流程中来。BEA AquaLogic BSI Studio不要求设计Web,也不要求编写代码,可...

    Simple-WebProject

    网络项目使用的技术: Java 核心小服务程序/JSP JDBC JNDI - 获取本地数据源简单的 Web 项目,它清楚地了解如何... 您可以在 /res/shop_service_db_script 中找到数据库脚本运行项目 - 在 Tomcat 中部署它。 然后访问

    Jboss集群配置指南

    3. JNDI 3 4. EJB 3 第二部分 集群物理实现 4 1. 物理架构 4 2. 机器网址分配 4 3. 软件环境 4 第三部分 集群配置 5 1. Apache 配置 5 2. Tomcat配置 6 3. Jboss配置 6 3.1. 配置Session复制 6 3.2. 配置Clustering ...

    将 Flex 集成到 Java EE 应用程序的最佳实践(完整源代码)

    因此,需要一个 FactoryInstance 的实现类,我们编写一个 SpringFactoryInstance,以便从 Spring 的容器中查找 FlexService: 清单 9. SpringFactoryInstance class class SpringFactoryInstance extends ...

    The Java EE 6 Tutorial Basic Concepts 4th Edition

    Creating a Simple Web Service and Clients with JAX-WS 208 Types Supported by JAX-WS 217 Web Services Interoperability and JAX-WS 217 Further Information about JAX-WS 217 Chapter 13: Building ...

    spring in action英文版

     7.1 从JNDI中获取对象  7.1.1 使用传统的JNDI  7.1.2 代理JNDI对象  7.2 发送电子邮件  7.3 调度任务  7.3.1 使用Java Timer调度任务  7.3.2 使用Quartz调度器  7.3.3 按调度计划调用方法 ...

    BlazeDS开发者指南

    Accessing EJBs and other objects in JNDI 120 Part 4: Messaging Service Chapter 9: Using the Messaging Service Using the Messaging Service 122 Working with Producer components 125 Working with Consumer...

    JBoss Application Server

    The J2EE platform manages the infrastructure and supports the Web services to enable development of secure, robust and interoperable business applications.” J2EE 1.3 Technologies Enterprise ...

    personal-geekbang-lessons:个人极客时间课程代码

    完善自研MVC框架org.geektimes.web.mvc.FrontControllerServlet#initHandleMethods了org...web.mvc.FrontControllerServlet#service方法一个请求路径对应一个控制器类问题完成JNDI获取数据库源修复src/main/webapp/META...

    J2EE中文版指南 CHM格式 带全文检索

    增加一个Web组件到WAR文件中 150 配置Web客户 151 应用级配置 151 WAR级的配置 151 组件及配置 151 部署网络客户 152 运行网络客户 152 更新网络客户 152 国际化网络客户 152 第10章 Java Servlet技术 153 什么是...

    Sun权威教程--《J2EE Tutorial中文版》

    此外,简明扼要的文字说明也有助于你快速掌握J2EE平台的多项技术,包括: &lt;br&gt; ☆ Enterprise JavaBean  ☆ Java Servlet  ☆ JavaServer Pages  ☆ Java Message Service (JMS,Java消息服务) ...

    经典JAVA.EE企业应用实战.基于WEBLOGIC_JBOSS的JSF_EJB3_JPA整合开发.pdf

    第二部分详细讲解了jsf ri、jta、jndi、rmi、jms、javamail、ejb 3的session bean、message driven bean、jpa、jax-ws 2、jaas等java ee知识,这部分知识以jsf+ejb 3+jpa整合开发为重点,通过使用netbeans ide工具...

    +Flex+集成到+Java+EE+应用程序的最佳实践(完整源代码)

    因此,需要一个 FactoryInstance 的实现类,我们编写一个 SpringFactoryInstance,以便从 Spring 的容器中查找 FlexService: 清单 9. SpringFactoryInstance class class SpringFactoryInstance extends ...

Global site tag (gtag.js) - Google Analytics