New to EJBs  exception in client code

Hi i am new to EJBs when i execute the client code it is giving the following exceptions
can any one tell me the steps to execute a simple EJB session bean. what class paths and what config and what xml files are required??
i followed so many tutorials but the problem is not solved
thanks
here is the exception i wrote the JNDI name as "HelloWorld" in the weblogic-ejb-jar.xml (i am using weblogic 8.1 application server)
Full compiler error(s):
C:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_FirstEjb_HelloClient\jsp_servlet\__helloclient.java:139: cannot resolve symbol
symbol  : class HelloHome
location: class jsp_servlet.__helloclient
        HelloHome home = (HelloHome) javax.rmi.PortableRemoteObject.narrow(obj,HelloHome.class); //[ /HelloClient.jsp; Line: 17]
        ^
C:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_FirstEjb_HelloClient\jsp_servlet\__helloclient.java:139: cannot resolve symbol
symbol  : class HelloHome
location: class jsp_servlet.__helloclient
        HelloHome home = (HelloHome) javax.rmi.PortableRemoteObject.narrow(obj,HelloHome.class); //[ /HelloClient.jsp; Line: 17]
                          ^
C:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_FirstEjb_HelloClient\jsp_servlet\__helloclient.java:139: cannot resolve symbol
symbol  : class HelloHome
location: class jsp_servlet.__helloclient
        HelloHome home = (HelloHome) javax.rmi.PortableRemoteObject.narrow(obj,HelloHome.class); //[ /HelloClient.jsp; Line: 17]
                                                                               ^
C:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_FirstEjb_HelloClient\jsp_servlet\__helloclient.java:140: cannot resolve symbol
symbol  : class Hello
location: class jsp_servlet.__helloclient
        Hello hello = home.create(); //[ /HelloClient.jsp; Line: 18]
        ^
4 errorsand the client jsp file is as follows
  <%@ page import="java.util.*"%>
<%@ page import="javax.naming.InitialContext"%>
<%@ page import="javax.naming.Context"%>
<%@page language="java" contentType="text/html"%>
<html>
    <head>
        <title>JSP Page</title>
    </head>
    <body>
        <%
            Properties props = System.getProperties();
               out.println("SREENIVAS  FIRST EJB");
          try {
               Context ctx = new InitialContext(props);
            Object obj = ctx.lookup("HelloWorld");
            HelloHome home = (HelloHome) javax.rmi.PortableRemoteObject.narrow(obj,HelloHome.class);
            Hello hello = home.create();
               out.println(hello.hello());
            hello.remove();
            ctx.close();
        } catch (Exception e) {
            e.printStackTrace();
    %></body>
</html>

i got the output
its working
the change i did is
i put all the remote,home and local interfaces in a package and added that package to a jar file.
then i added the jar file to class path.
import this package into your client class.
thats it now just deploy your ejbmodule.jar and webapplication.war in the server and test the code
bye bye

Similar Messages

  • SET NOCOUNTON causing Primary key violation exception from client code

    Hi,
    We have a stored procedure in SQL Server - 2012 which contains two insert statements as below      
    BEGIN   
    SET NOCOUNT ON;        
     if(@Status ='1')      
      Begin      
     insert into dcmnt_mstr       
      (trn_id,sub_no,usr_id,ref_id,email_id,reg_no,ordrd_date,ordr_cust_ref,email_status,chrg_status,upd_user,row_created_by)      
      values(@TranId,@SubsriberNo,@UserId,@RefId,@EmailId,'00000000',getdate(),@RefText,'0','0','Bulk Order',@AppId)      
      end      
     insert into dcmnt_bulk       
    (trn_id,reg_no,pkg_type,proc_status,upd_user)      
    values       
    (@TranId,@RegNo,@PkgType,'0','Bulk Order')      
    END 
    By using the SSMS2012 query analyzer we are able execute this SP successfully.
    But when this is executed from client code[Java Code] we are getting an error like below
    com.jnetdirect.jsql.x: Violation of PRIMARY KEY constraint 'PK_dcmnt_mstr'. 
    Cannot insert duplicate key in object 'dbo.dcmnt_mstr'. The duplicate key value is (5421e73993b46c15).
    The same is working fine from the client code once the statement SET NOCOUNT ON; is removed from the SP.
    Could some one can help to identify the root cause?
    Thank you

    It looks like the application code is examining the row count returned and retrying the insert if less than 1.  So you need to either specify SET NOCOUNT OFF (the default) or change the app code.
    Dan Guzman, SQL Server MVP, http://www.dbdelta.com

  • EJB Client Code Question

    Hi ,
    I am learning the basic EJB and trying to write my first piece of code.
    I wrote a HelloWorld.jar(EJB) and deployed it in Websphere server.
    Then I wrote a standalone java program with main method to access the EJB client. As per the tutorial..
    public void callEJB()
              try
                   java.util.Properties env = new java.util.Properties();
                   env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
                   env.put(javax.naming.Context.PROVIDER_URL,"iiop://localhost:2809/");               
                   javax.naming.Context initial = new javax.naming.InitialContext(env);
                   //Object objref =(javax.naming.Context)initial.lookup("java:comp/env/HelloWorld");                              
                   Object objref =initial.lookup("ejb/ejb/demo/HelloWorldHome");     
                   System.out.println(objref.getClass());
                   HelloWorldComponent helloRef = (HelloWorldRemote)PortableRemoteObject.narrow(objref, HelloWorldComponent.class);
              }catch(Exception e){e.printStackTrace();}
    How will my code compile???? Because HelloWorldComponent is on the application server, but my client is on a different server. It cannot find the HelloWorldComponent class right??
    What should I do now?
    Thanks.

    What you need is the interface (if you're using EJB3) or home interface class within your client. When you perform a lookup on Websphere it will return a proxy to your remote home interface, so in order to resolve it your client must have it in the classpath.
    You don't need to package the actual EJB within your client, just the interface(s) you are using, remembering that the interfaces need to be remote.
    Message was edited by:
    mtedone

  • Client code cast error:EJB returning data in Collection of Objects

    Still trying to understand this EJB stuff.....
    My BMP EJB returns data to the client in a collection of objects;
      // Home interface (CountryHome) nothing unusual here
      public Collection findAllCountries()
      //Remote interface (Country) nothing unusual here
      public CountryModel getDetails()The data object is a serialised object;
      // data object - nothing strange here
      public class CountryModel implements Serializable {
        private int countryId;
        private String countryName;
        public CountryModel () {......etc etc
        public CountryModel getDetails()  {.......etc etc
        public String toString() { ...etcWhen I try and get at the data from the collection in the client code, calling getDetails() in CountryModel causes a cast exception. How can I get at the data?
      Collection a = home.findAllCountries();
      Iterator i = a.iterator();
      while (i.hasNext()) {
        Object obj = i.next();
        Country country = (Country)
             PortableRemoteObject.narrow(obj, Country.class);
        // this fails with class cast exception.....
        System.out.println(country.getDetails());And to add to the confusion, why does calling the remote interface's getPrimaryKey() method in the client code invoke the toString() method in the CountryModel class and work?
      while (i.hasNext()) {
        Object obj = i.next();
        Country country = (Country)
             PortableRemoteObject.narrow(obj, Country.class);
        // have no idea why this works.....but it does.....
        System.out.println(country.getPrimaryKey());Thanks, lebo

    hi,
    you are getting a collection of serializable objects and not remote objects. the narow method has to be applied only for remote objects (actually it is the stub that will be received on the client side).
    so you modify your code as,
    Collection a = home.findAllCountries(); Iterator i = a.iterator(); while (i.hasNext()) {    Object obj = i.next();    Country country = (Country)obj;
    this will definitely solve the problem.
    regards
    srini

  • Error while running EJB from java client on JBOSS

    Hi
    As i am new to EJB i have created a helloworld application in ejb which is working fine when i try to call it from servlet but when i try to invoke the same ejb from java client (i.e from diff jvm) on jboss i got the following error:
    javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1099 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused]]]
         at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1399)
         at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:579)
         at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
         at javax.naming.InitialContext.lookup(InitialContext.java:351)
         at com.gl.TestClient.main(TestClient.java:39)
    Caused by: javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused]]
         at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:254)
         at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1370)
         ... 4 more
    Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused]
         at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:228)
         ... 5 more
    Caused by: java.net.ConnectException: Connection refused
         at java.net.PlainSocketImpl.socketConnect(Native Method)
         at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
         at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
         at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
         at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
         at java.net.Socket.connect(Socket.java:519)
         at java.net.Socket.connect(Socket.java:469)
         at java.net.Socket.<init>(Socket.java:366)
         at java.net.Socket.<init>(Socket.java:266)
         at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:69)
         at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:62)
         at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:224)
         ... 5 more
    Following is my code:
    Home Interface:
    package com.gl;
    import javax.ejb.CreateException;
    public interface testHome extends EJBHome {
         String JNDI_NAME = "testBean";
         public     test create()
         throws java.rmi.RemoteException,CreateException;
    Remote Interface:
    package com.gl;
    import java.rmi.RemoteException;
    import javax.ejb.EJBObject;
    public interface test extends EJBObject {
         public String welcomeMessage() throws RemoteException;
    Bean:
    package com.gl;
    import java.rmi.RemoteException;
    import javax.ejb.EJBException;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    public class testbean implements SessionBean {
         public void ejbActivate() throws EJBException, RemoteException {
              // TODO Auto-generated method stub
         public void ejbPassivate() throws EJBException, RemoteException {
              // TODO Auto-generated method stub
         public void ejbRemove() throws EJBException, RemoteException {
              // TODO Auto-generated method stub
         public void setSessionContext(SessionContext arg0) throws EJBException,
                   RemoteException {
              // TODO Auto-generated method stub
         public void ejbCreate(){}
         public String welcomeMessage(){
              return "Welcome to the World of EJB";
    ejb-jar.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
    <ejb-jar>
    <enterprise-beans>
    <session>
    <ejb-name>testBean</ejb-name>
    <home>com.gl.testHome</home>
    <remote>com.gl.test</remote>
    <ejb-class>com.gl.testbean</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    </session>
    </enterprise-beans>
    </ejb-jar>
    jboss.xml:
    <?xml version='1.0' ?>
    <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.2//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd">
    <jboss>
    <enterprise-beans>
    <entity>
    <ejb-name>testBean</ejb-name>
    <jndi-name>testBean</jndi-name>
    </entity>
    </enterprise-beans>
    </jboss>
    Client code:
    package com.gl;
    import java.util.Properties;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.rmi.PortableRemoteObject;
    public class TestClient {
         public static void main(String[] args) throws Exception{
                   try{
                   /*     Properties props=new Properties();
                        props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
                        props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
                        props.put(Context.PROVIDER_URL, "jnp://localhost:1099");
                   Properties props = new Properties();
    props.put(Context.INITIAL_CONTEXT_FACTORY,
    "org.jnp.interfaces.NamingContextFactory");
    props.put(Context.PROVIDER_URL, "localhost:1099");
                        System.out.println("Properties ok");
                        //env.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.jboss.naming.HttpNamingContextFactory");
                        //env.put(Context.PROVIDER_URL,"http://localhost:8080");
                        //env.put(Context.SECURITY_PRINCIPAL, "");
                        //env.put(Context.SECURITY_CREDENTIALS, "");
                        Context ctx=new InitialContext(props);
                        System.out.println("context ok");
                        //testHome home = (testHome)ctx.lookup("testBean");
                        Object obj = ctx.lookup ("testBean");
                        System.out.println("ojb = " + obj);
                        testHome ejbHome = (testHome)PortableRemoteObject.narrow(obj,testHome.class);
                   test ejbObject = ejbHome.create();
                   String message = ejbObject.welcomeMessage();
                        System.out.println("home ok");
                        System.out.println("remote ok");
                        System.out.println(message);
                        catch(Exception e){e.printStackTrace();}
    I am able to successfully deployed my ejb on JBOSS but i m getting above error when i am trying to invoke ejb from java client.
    kindly suggest me something to solve this issue.
    Regards
    Gagan
    Edited by: Gagan2914 on Aug 26, 2008 3:28 AM

    Is it a remote lookup? Then maybe this will help:
    [http://wiki.jboss.org/wiki/JBoss42FAQ]
    - Roy

  • EJB Exception Layer Design Feedback

    I am in the process of creating a EJB layer talking to EIS Tier via JCA adapter. The EJBs are all stateless. The EJBs would be used by servlets, ejbs, or jsps. The EJBs are stateless in nature. I would like to make sure the exception hierarchy I have is considered good design practice and if there are suggestions on how I may improve it. I decided to go for unchecked exception all through my design (this I don't want to change -- pretty sure about this).
    So, here is how I designed my exception class. One of my goals was to keep the exception handling very simple at the client-side and not inundate customers with too many types of exceptions. I decided to go for a has-A type relationship to model much of the exceptions because I couldn’t really classify some of them to be a is-A. All exceptions thrown by my EJB layer would be contained within MyApplicationException. A getCause() will give insight into the cause at a very fine level. A getMessage() would suffice for most situations. Whereever exceptions are being thrown, the cause is being stored.
    java.lang.Exception
    --java.lang.RuntimeException
    ___ --MyBaseException
    _______+----MyApplicationException (this is the container for all my exceptions)
    _______+----MyConfigException
    I created a exceptionhelper class that handles most of the exceptions and throws the right exception depending on the cause. For brevity sake, I am not including all code details in the sample below.
    At the EIS Tier level, we have AutomationExceptions or Windows exception being thrown. These exceptions get thrown by the Windows code that is running in the EIS Tier (server). These exceptions are caught by the EJB code, then we do some processing like looking up the windows error code and producing the right message. The exception is then thrown back to the client with more information (MyApplicationException->getCause() would return AutomationException)
    In the EJB code I have something like this….
    try {
    serverConn.connectToEISTier()
    } catch (AutomatedException e) {
    throw new MyApplicationException(“Custom Message.”, ExceptionHelper.handleAutomatedException(e)); }
    At the EJB level
    •we have create, and naming exceptions thrown either on failed lookup or something failing when creating the ejbs or there might be programming errors or there might be missing resources when EJB is trying to connect and possibly encounters data retrieval failures or Some sort of configuration error might be there in the deployment descriptor (user did soemthing wrong - wrong value for environment entry). All these are caught, and converted into runtime exception namely MyApplicationException. Where classification is deemed necessary we for e.g convert then contained exception to say configexception.
    try {  
         lookup the context()
    } catch(NamingException ex){
    Cause = new myConfigException(“lookup failed because ….”);
    Throw new MyApplicationException(cause);
    At the transport level: some communication exception happened.
    At the client level:
    Client might be calling the apis wrongly and breaching the contract, or possibly supplied wrong credentials.
    Please share feedback / thoughts.

    There is an interesting article that discusses EJB Exception Layering:
    http://www-128.ibm.com/developerworks/java/library/j-ejbexcept.html
    As a rule of thumb: in every layer, create two types of exceptions that extend from the appropriate class (application exceptions and system exceptions). The next layer catches these and handles them appropriately. This way, you hide the implementation of the layers. An example where this is implemented is Spring.
    To summarize, I like your idea, but I define exceptions for every layer and not put them in one hiearchy.
    Regards,
    Lonneke

  • I unable to run ejb with application client using oc4j j2ee container

    Hi,
    I have installe oracle9i (1.0.2.2) oc4j j2ee container.
    I unable to run the ejbs . please help me how to run ejbs with application client and which files are shall configure.
    See the client application is :
    public static void main (String []args)
    try {
    //Hashtable env = new Hashtable();
    //env.put("java.naming.provider.url", "ormi://localhost/Demo");
    //env.put("java.naming.factory.initial", "com.evermind.server.ApplicationClientInitialContextFactory");
    //env.put(Context.SECURITY_PRINCIPAL, "guest");
    //env.put(Context.SECURITY_CREDENTIALS, "welcome");
    //Context ic = new InitialContext (env);
    System.out.println("\nBegin statelesssession DemoClient.\n");
    Context context = new InitialContext();
    Object homeObject = context.lookup("java:comp/env/DemoApplication");
    DemoHome home= (DemoHome)PortableRemoteObject.narrow(homeObject, DemoHome.class);
    System.out.println("Creating Demo\n");
    Demo demo = home.create();
    System.out.println("The result of demoSelect() is.. " +demo.sayHello());
    }catch ( Exception e )
    System.out.println("::::::Error:::::: ");
    e.printStackTrace();
    System.out.println("End DemoClient....\n");
    When I am running client application I got this type of Exception
    java.lang.SecurityException : No such domain/application: sampledemo
    at com.evermind.server.rmi.RMIConnection.connect(RMIConnection.java : 2040)
    at com.evermind.server.rmi.RMIConnection.connect(RMIConnection.java : 1884)
    at com.evermind.server.rmi.RMIConnection.lookup(RMIConnection.java : 1491)
    at com.evermind.server.rmi.RMIServer.lookup(RMIServer.java : 323)
    at com.evermind.server.rmi.RMIContext.lookup(RMIConext.java : 106)
    at com.evermind.server.administration.LazyResourceFinder.lookup(LazyResourceFinder.java : 59)
    at com.evermind.server.administration.LazyResourceFinder.getEJBHome(LazyResourceFinder.java : 26)
    at com.evermind.server.Application.createContext(Application.java: 653)
    at com.evermind.server.ApplicationClientInitialContext.getInitialContext(ApplicationClientInitialContextFactory.java :179 )
    at javax.naming.spi.NamingManager.getInitialContext(NamingManger.java : 246)
    at javax.naming.InitialContext.getDefaultInitialCtx(InitialContext.java : 246)
    at javax.naming.InitialContext.init(InitialContext.java : 222)
    at javax.naming.InitialContext.<init>(InitialContext.java : 178)
    at DemoClient.main(DemoClient.java : 23)
    .ear file is copied into applications directory.
    I have configured server.xml file like this
    <application name="sampledemo" path="../applications/demos.ear" />
    demos.ear file Contains following files
    application.xml
    demobean.jar
    Manifest.mf
    demobean.jar file contains following files
    application-client.xml
    Demo.class
    DemoBean.class
    DemoHome.class
    ejb-jar.xml
    jndi.properties
    Mainifest.mf
    Please give me your valuable suggestions. Which are shall i configure .
    Thanks & Regards,
    Badri

    Hi Badri,
    ApplicationClientInitialContextFactory is for clients which got deployed inside OC4J container..
    For looking up EJB from a stand alone java client please use RMIInitialContextFactory..So please change ur code....
    Also please check ur server.xml
    Since you have specified your ejb domain as "sampledemo"
    you have to use that domian only for look up..But it seems that you are looking up for "Demo" domain instead of "sampledemo" domain...So change your code to reflect that..
    Code snippet for the same is :
    Hashtable env = new Hashtable();
    env.put("java.naming.provider.url", "ormi://localhost/sampledemo");
    env.put("java.naming.factory.initial", "om.evermind.server.rmi.RMIInitialContextFactory");
    env.put(Context.SECURITY_PRINCIPAL, "guest");
    env.put(Context.SECURITY_CREDENTIALS, "welcome");
    Context ic = new InitialContext (env);
    Hope this helps
    --Venky                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • New to EJB encounter javax.naming.NoInitialContextException

    HI, I am using j2ee 1.4 sdk to test my first EJB,
    in client code:
    InitialContext initialContext = new InitialContext();
    // lookup InterestCalculator EJB
    Object homeObject =
    initialContext.lookup( "InterestCalculator" );a Exception throwed!
    I think it is because I need to setup JNDI environment, but I don't know how to
    do it.
    Can anybody give me some tips?

    Hi,
    Use the following:
    Properties env = new Properties();
    env.put("java.naming.factory.initial", "com.sun.jndi.cosnaming.CNCtxFactory");
    env.put("java.naming.provider.url", url);
    initial = new InitialContext(env);
    objref = initial.lookup(jndiname);where
    URL refers to the application server running on a machine with hostname (e.g. ashost) and with an ORB-port (e.g. 3700 as default port). For example,
    iiop://ashost:3700
    JNDIName matches in the deployment file. In the example, it is rmiconverter which can be found as
    <jndi-name>rmiconverter</jndi-name> in the file,
    <install_dir>/samples/rmi-iiop/simple/src/sun-ejb-jar.xml.
    -Amol

  • Problem while invoking webservice-method in client-code

    Hi,
    I had written webservice-client-code (using uddi-ext.jar, as i am using uddi for publishing webservices.) which is invoking webservice method successfully with complex datatypes(both for return type and input paramters).
    But while calling following webservice-method from my client-code:
    public ComplexType[] getData(String[] p_str1, String[] p_str2)
    it is throwing exception
    The Exception is:
    [ERROR] - 27 Mar 2007 12:34:38 -failed to invoke operation 'getData' due to an error in the soap layer (SAAJ); nested exception is: Message[failed to deserialize xml:weblogic.xml.schema.binding.DeserializationException: mapping lookup failure. type=['java:language_builtins.lang']:ArrayOfString schema context=TypedSchemaContext{javaType=[Ljava.lang.String;}]
    Although I had done correct registration of mapping of ArrayOfString in client-code:
    registry = m_Service.getTypeMappingRegistry();
                   m_TypeMapping = registry.getTypeMapping(SOAPConstants.URI_NS_SOAP_ENCODING );
                   m_TypeMapping.register( ArrayOfStringHolder.class,
    new QName( "java:language_builtins.lang", "ArrayOfString" ),
    new ArrayOfStringCodec(),
    new ArrayOfStringCodec());
    But some how it doesnt works.
    I had searched on google as well but didnt find any reliable solutions.
    Please advice.
    Edited by meetmrdeepak at 03/27/2007 2:43 AM
    Edited by meetmrdeepak at 03/27/2007 2:45 AM

    See item A.1 of the [RMI FAQ|http://java.sun.com/j2se/1.5.0/docs/guide/rmi/faq.html].

  • What's wrong with my DII client code?

    I have the following WSDL for my ASP/IIS web service...
    <?xml version='1.0' encoding='UTF-8' ?>
    <!-- Generated 10/31/03 by Microsoft SOAP Toolkit WSDL File Generator, Version 3.00.1325.0 -->
    <definitions
         name='DCIS'
         targetNamespace='http://ds_00119/DCIS/wsdl/'
         xmlns:wsdlns='http://ds_00119/DCIS/wsdl/'
         xmlns:typens='http://ds_00119/DCIS/type/'
         xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
         xmlns:xsd='http://www.w3.org/2001/XMLSchema'
         xmlns:stk='http://schemas.microsoft.com/soap-toolkit/wsdl-extension'
         xmlns:dime='http://schemas.xmlsoap.org/ws/2002/04/dime/wsdl/'
         xmlns:ref='http://schemas.xmlsoap.org/ws/2002/04/reference/'
         xmlns:content='http://schemas.xmlsoap.org/ws/2002/04/content-type/'
         xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
         xmlns='http://schemas.xmlsoap.org/wsdl/'>
         <types>
              <schema
                   targetNamespace='http://ds_00119/DCIS/type/'
                   xmlns='http://www.w3.org/2001/XMLSchema'
                   xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/'
                   xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
                   elementFormDefault='qualified'>
                   <import namespace='http://schemas.xmlsoap.org/soap/encoding/'/>
                   <import namespace='http://schemas.xmlsoap.org/wsdl/'/>
                   <import namespace='http://schemas.xmlsoap.org/ws/2002/04/reference/'/>
                   <import namespace='http://schemas.xmlsoap.org/ws/2002/04/content-type/'/>
              </schema>
         </types>
         <message name='DCIS.CTXD'>
              <part name='bstrUser' type='xsd:string'/>
              <part name='bstrPassword' type='xsd:string'/>
              <part name='bstrName' type='xsd:string'/>
              <part name='bstrAddress' type='xsd:string'/>
              <part name='bstrPhone' type='xsd:string'/>
         </message>
         <message name='DCIS.CTXDResponse'>
              <part name='Result' type='xsd:string'/>
         </message>
         <portType name='DCISSoapPort'>
              <operation name='CTXD' parameterOrder='bstrUser bstrPassword bstrName bstrAddress bstrPhone'>
                   <input message='wsdlns:DCIS.CTXD'/>
                   <output message='wsdlns:DCIS.CTXDResponse'/>
              </operation>
         </portType>
         <binding name='DCISSoapBinding' type='wsdlns:DCISSoapPort' >
              <stk:binding preferredEncoding='UTF-8'/>
              <soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/>
              <operation name='CTXD'>
                   <soap:operation soapAction='http://ds_00119/DCIS/action/DCIS.CTXD'/>
                   <input>
                        <soap:body
                             use='encoded'
                             namespace='http://ds_00119/DCIS/message/'
                             encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
                             parts='bstrUser bstrPassword bstrName bstrAddress bstrPhone'/>
                   </input>
                   <output>
                        <soap:body
                             use='encoded'
                             namespace='http://ds_00119/DCIS/message/'
                             encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
                             parts='Result'/>
                   </output>
              </operation>
         </binding>
         <service name='DCIS' >
              <port name='DCISSoapPort' binding='wsdlns:DCISSoapBinding' >
                   <soap:address location='http://ds_00119/DCIS/DCIS.ASP'/>
              </port>
         </service>
    </definitions>
    and the following client code...
    import javax.xml.namespace.*;
    import javax.xml.rpc.*;
    import javax.activation.*;
    import javax.mail.*;
    import com.sun.xml.messaging.saaj.*;
    import java.net.*;
    import java.util.*;
    import java.rmi.*;
    public class DIIClient
         public static void main(String[] args)
              try
                   String namespace = "http://ds_00119/DCIS/wsdl/";
                   String endpointURL = "http://ds_00119/DCIS/dcis.asp";
                   String portName = "DCISSoapPort";
                   String functionName = "CTXD";
                   String[] paramNames = {"bstrUser","bstrPassword","bstrName","bstrAddress","bstrPhone"};
                   String[] paramValues = new String[] {"x","y","a","b","c"};
                   String xsdStringType = "<xsd:string>";
                   ServiceFactory factory = ServiceFactory.newInstance();          
                   Call call = factory.createService(new QName("DCIS")).createCall();
                   call.setTargetEndpointAddress(endpointURL);
                   call.setPortTypeName(new QName(namespace, portName));
                   call.setOperationName(new QName(namespace, functionName));
                   call.setProperty(Call.SOAPACTION_USE_PROPERTY, new Boolean(true));
                   call.setProperty(Call.SOAPACTION_URI_PROPERTY, "http://ds_00119/DCIS/");
                   call.setProperty(Call.ENCODINGSTYLE_URI_PROPERTY, "");
                   call.setProperty(Call.OPERATION_STYLE_PROPERTY, "rpc");
                   for(int i=0; i<5; i++)
                        call.addParameter(paramNames, new QName(xsdStringType),ParameterMode.IN);
                   call.setReturnType(new QName(xsdStringType));          
                   String returnValue = (String) call.invoke(paramValues);
                   System.out.println(returnValue);
              catch(Exception ex)
              ex.printStackTrace();
    when I run this I get:
    java.rmi.RemoteException: WSDLReader:The operation requested in the Soap message with soapAction http://ds_00119/DCIS/action/DCIS isn't defined in the WSDL file. This may be because it is in the wrong namespace or has incorrect case
         at com.sun.xml.rpc.client.dii.BasicCall.invoke(BasicCall.java:369)
         at DIIClient.main(DIIClient.java:45)
    I've tried everything I can think of for the soapAction string and just can't get it to work. What am I doing wrong here?
    I know the service works because I've been using C++ and VB clients for months, but I need to get a Java client up and running soon.
    I've only been looking at Java WS clients for a day, so if anyone knows of a better way to do this then please tell me! I've tried 4 completely different implementations so far and none of them worked.
    Chris

    Dear Chris,
    The problem is in your code itself or the way u've created this web service.
    I'm sending you some sample code. Just change the values of variables and delete unwanted lines according to you. Just go step by step.
    Here is the code
    import javax.xml.rpc.Call;
    import javax.xml.rpc.Service;
    import javax.xml.rpc.JAXRPCException;
    import javax.xml.namespace.QName;
    import javax.xml.rpc.ServiceFactory;
    import javax.xml.rpc.ParameterMode;
    public class DllClient {
    private static String qnameService = "IPSProv_pipeService";
    private static String qnamePort = "IPSProv_pipeIFPort";
    private static String BODY_NAMESPACE_VALUE =
    "urn:Foo";
    private static String ENCODING_STYLE_PROPERTY =
    "javax.xml.rpc.encodingstyle.namespace.uri";
    private static String NS_XSD =
    "http://www.w3.org/2001/XMLSchema";
    private static String URI_ENCODING =
    "http://schemas.xmlsoap.org/soap/encoding/";
    public static void main(String[] args) {
    System.out.println("Endpoint address = http://218.248.33.59:8080/ipsprovPipeService/provision?WSDL");
    try {
    ServiceFactory factory =
    ServiceFactory.newInstance();
    Service service =
    factory.createService(
    new QName(qnameService));
    QName port = new QName(qnamePort);
    Call call = service.createCall(port);
    call.setTargetEndpointAddress("http://215.246.33.59:8080/ipsprovPipeService/provision?WSDL");
    call.setProperty(Call.SOAPACTION_USE_PROPERTY,
    new Boolean(true));
    call.setProperty(Call.SOAPACTION_URI_PROPERTY,
    call.setProperty(ENCODING_STYLE_PROPERTY,
    URI_ENCODING);
    QName QNAME_TYPE_STRING =
    new QName(NS_XSD, "string");
    call.setReturnType(QNAME_TYPE_STRING);
    call.setOperationName(
    new QName(BODY_NAMESPACE_VALUE,"sp_mgmnt"));
    call.addParameter("String_1", QNAME_TYPE_STRING,
    ParameterMode.IN);
    call.addParameter("String_2", QNAME_TYPE_STRING,
    ParameterMode.IN);
    call.addParameter("String_3", QNAME_TYPE_STRING,
    ParameterMode.IN);
    call.addParameter("String_4", QNAME_TYPE_STRING,
    ParameterMode.IN);
    String[] params = { "A","B"};
    String result = (String)call.invoke(params);
    System.out.println(result);
    } catch (Exception ex) {
    ex.printStackTrace();
    Plz show me the code after u make changes in it and do reply whether it works or not.
    Regards,
    Piyush

  • EJB Exception : getEnvironment is deprecated

    (Note : this question has been posted in 81beta.server.ejb also)
    Hi All,
    I am getting EJB Exception while deploying my ear file which contains a simple
    stateless session bean (jar module) and a jsp accessing the SSB. (WLS 8.1)
    Here is my code snippet that looks up SSB.
    Hashtable ht = new Hashtable();
    ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
    ht.put(Context.PROVIDER_URL,"t3://192.168.66.39:7001");
    try { Context ctx = new InitialContext(ht);
    DemoHome1 d1 = (DemoHome1)ctx.lookup("java:comp/env/ejb1");
    Demo1 demo = d1.create();
    String str1 = demo.demoSelect();
    System.out.println("Result from DemoBean : " + str1); }
    Here is my <ejb-ref> element in web.xml
    <ejb-ref>
    <ejb-ref-name>ejb1</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <home>ejb.demo.DemoHome1</home>
    <remote>ejb.demo.Demo1</remote>
    <ejb-link>../Demo.jar#DemoBean</ejb-link>
    </ejb-ref>
    And the exception is here
    <Jul 17, 2003 10:24:45 AM IST> <Error> <HTTP> <BEA-101019> <[ServletContext(id=5950347,name=sampletest,context-path=/sampletest)]
    Servlet failed with IOException java.rmi.RemoteException: EJB Exception: ; nested
    exception is: java.lang.RuntimeException: [EJB:010183]javax.ejb.EJBContext.getEnvironment
    is deprecated in EJB 1.1. EJB 1.1 compliant containers are not required to implement
    this method. Use java:comp/env instead. at weblogic.ejb20.internal.EJBRuntimeUtils.throwRemoteException(EJBRuntimeUtils.java:103)
    at weblogic.ejb20.internal.BaseEJBHome.handleSystemException(BaseEJBHome.java:304)
    at weblogic.ejb20.internal.BaseEJBObject.preInvoke(BaseEJBObject.java:140) at
    weblogic.ejb20.internal.StatelessEJBObject.preInvoke(StatelessEJBObject.java:70)
    at ejb.demo.DemoBean_c3ndjf_EOImpl.demoSelect(DemoBean_c3ndjf_EOImpl.java:28)
    at jsp_servlet.__sampletest._jspService(__sampletest.java:144) at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1053)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:387)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:431)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6291)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:97) at
    weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3575)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2573)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:178) at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:151)
    Caused by: java.lang.RuntimeException: [EJB:010183]javax.ejb.EJBContext.getEnvironment
    is deprecated in EJB 1.1. EJB 1.1 compliant containers are not required to implement
    this method. Use java:comp/env instead. at weblogic.ejb20.internal.BaseEJBContext.getEnvironment(BaseEJBContext.java:279)
    at ejb.demo.DemoBean1.setSessionContext(DemoBean1.java:48) at ejb.demo.DemoBean_c3ndjf_Impl.setSessionContext(DemoBean_c3ndjf_Impl.java:111)
    at weblogic.ejb20.manager.StatelessManager.createBean(StatelessManager.java:267)
    at weblogic.ejb20.pool.StatelessSessionPool.createBean(StatelessSessionPool.java:157)
    at weblogic.ejb20.pool.StatelessSessionPool.getBean(StatelessSessionPool.java:109)
    at weblogic.ejb20.manager.StatelessManager.preInvoke(StatelessManager.java:140)
    at weblogic.ejb20.internal.BaseEJBObject.preInvoke(BaseEJBObject.java:130) ...
    15 more
    >
    Anybody faced the same kind of problem and have an idea about the solution? Please.
    Thanks Prema

    Thanks for your Help, Rob.
    Problem because of ctx.getEnvironment() in my setSessionContext()
    Thanks
    Prema
    Rob Woollen <[email protected]> wrote:
    The error is coming from your EJB, not a webapp. Somewhere in your EJB,
    you're calling EJBContext.getEnvironment.
    -- Rob
    Prema wrote:
    Rob Woollen <[email protected]> wrote:
    Your EJB called the EJB 1.0! method EJBContext.getEnvironment. As
    the
    exception mentions, wee don't implement that method anymore and throw
    a
    RuntimeException.
    You should be using java:/comp/env to get to environment properties.
    -- Rob
    Prema wrote:
    (Note : this question has been posted in 81beta.server.ejb also)
    Hi All,
    I am getting EJB Exception while deploying my ear file which containsa simple
    stateless session bean (jar module) and a jsp accessing the SSB. (WLS8.1)
    Here is my code snippet that looks up SSB.
    Hashtable ht = new Hashtable();
    ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
    ht.put(Context.PROVIDER_URL,"t3://192.168.66.39:7001");
    try { Context ctx = new InitialContext(ht);
    DemoHome1 d1 = (DemoHome1)ctx.lookup("java:comp/env/ejb1");
    Demo1 demo = d1.create();
    String str1 = demo.demoSelect();
    System.out.println("Result from DemoBean : " + str1); }
    Here is my <ejb-ref> element in web.xml
    <ejb-ref>
    <ejb-ref-name>ejb1</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <home>ejb.demo.DemoHome1</home>
    <remote>ejb.demo.Demo1</remote>
    <ejb-link>../Demo.jar#DemoBean</ejb-link>
    </ejb-ref>
    And the exception is here
    <Jul 17, 2003 10:24:45 AM IST> <Error> <HTTP> <BEA-101019> <[ServletContext(id=5950347,name=sampletest,context-path=/sampletest)]
    Servlet failed with IOException java.rmi.RemoteException: EJB Exception:; nested
    exception is: java.lang.RuntimeException: [EJB:010183]javax.ejb.EJBContext.getEnvironment
    is deprecated in EJB 1.1. EJB 1.1 compliant containers are not requiredto implement
    this method. Use java:comp/env instead. at weblogic.ejb20.internal.EJBRuntimeUtils.throwRemoteException(EJBRuntimeUtils.java:103)
    at weblogic.ejb20.internal.BaseEJBHome.handleSystemException(BaseEJBHome.java:304)
    at weblogic.ejb20.internal.BaseEJBObject.preInvoke(BaseEJBObject.java:140)at
    weblogic.ejb20.internal.StatelessEJBObject.preInvoke(StatelessEJBObject.java:70)
    at ejb.demo.DemoBean_c3ndjf_EOImpl.demoSelect(DemoBean_c3ndjf_EOImpl.java:28)
    at jsp_servlet.__sampletest._jspService(__sampletest.java:144) at
    weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1053)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:387)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:431)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6291)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:97)at
    weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3575)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2573)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:178) atweblogic.kernel.ExecuteThread.run(ExecuteThread.java:151)
    Caused by: java.lang.RuntimeException: [EJB:010183]javax.ejb.EJBContext.getEnvironment
    is deprecated in EJB 1.1. EJB 1.1 compliant containers are not requiredto implement
    this method. Use java:comp/env instead. at weblogic.ejb20.internal.BaseEJBContext.getEnvironment(BaseEJBContext.java:279)
    at ejb.demo.DemoBean1.setSessionContext(DemoBean1.java:48) at ejb.demo.DemoBean_c3ndjf_Impl.setSessionContext(DemoBean_c3ndjf_Impl.java:111)
    at weblogic.ejb20.manager.StatelessManager.createBean(StatelessManager.java:267)
    at weblogic.ejb20.pool.StatelessSessionPool.createBean(StatelessSessionPool.java:157)
    at weblogic.ejb20.pool.StatelessSessionPool.getBean(StatelessSessionPool.java:109)
    at weblogic.ejb20.manager.StatelessManager.preInvoke(StatelessManager.java:140)
    at weblogic.ejb20.internal.BaseEJBObject.preInvoke(BaseEJBObject.java:130)...
    15 more
    Anybody faced the same kind of problem and have an idea about the
    solution?
    Please.
    Thanks Prema
    Hi,
    I tried using JNDI name directly.
    DemoHome1 d1 = (DemoHome1) ctx.lookup("DemoBean");
    //DemoBean is my JNDI name
    It is still displaying same error. What's wrong ? What's the exactway of
    looking up an ejb from a web module in WLS 8.1 ?
    Thanks in advance
    Prema
    >

  • Certificate Exception - applet client to java server with SSL

    Hi,
    I'm having some trouble getting SSL working and hope
    someone can shed some light. I've been plowing through
    these forums for a couple of days - seems lots of folks
    have had this problem but I can't find a clear solution.
    I've written a server in java. The client is an applet.
    This is an internet app so I have no control over
    configuring clients. I'm trying to prove SSL communication from the applet to my server. This is
    commercial software so the customer would put their own
    keys on the machine and resign the applet before deploying.
    I've created a keystore with keytool. Then I self-
    signed it. Then I signed my applet jarfile. I've even tried exporting the certificate and importing using the java plug-in control panel
    (obviously not something I can do in the real world but
    just wanted to see if that was it). I start up my server
    and navigate to a web page to start the applet. For
    development purposes, I'm doing this all on one machine. I'm running jdk 1.4.1_02. We're requiring the
    Sun plug-in as our client java VM.
    Once the client starts to connect, I get this error in
    the plug-in console:
    java.security.cert.CertificateException: Couldn't find trusted certificate
    On my server, I get:
    Wed May 14 16:27:46 EDT 2003 [EXCEPTION]: javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
    javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
         at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.a(DashoA6275)
         at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.b(DashoA6275)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.b(DashoA6275)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.j(DashoA6275)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
         at com.sun.net.ssl.internal.ssl.AppInputStream.read(DashoA6275)
         at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:406)
         at sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:446)
         at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:180)
         at java.io.InputStreamReader.read(InputStreamReader.java:167)
         at java.io.BufferedReader.fill(BufferedReader.java:136)
         at java.io.BufferedReader.readLine(BufferedReader.java:299)
         at java.io.BufferedReader.readLine(BufferedReader.java:362)
         at com.pactolus.webBroker.psWebLegClientThread.run(psWebLegClientThread.java:130)
         at java.lang.Thread.run(Thread.java:536)
    The client code is pretty simple:
    SSLSocketFactory factory = (SSLSocketFactory)
        SSLSocketFactory.getDefault();
    tcpSocket = (SSLSocket) factory.createSocket(addr,
                                                 iPortNbr);
    tcpSocket.setUseClientMode(true);
    tcpSocket.startHandshake();followed by a thread kick-off which will listen on the
    socket for incoming messages.
    The server code is:
    SSLContext sslCtxt = SSLContext.getInstance("SSL");
    KeyManagerFactory kmf = KeyManagerFactory.getInstance
       ("SunX509");
    KeyStore ks = KeyStore.getInstance("JKS");
    char[] password = keyPassword.toCharArray();
    ks.load(new FileInputStream(keyFile), password);
    kmf.init(ks, password);
    sslCtxt.init(kmf.getKeyManagers(), null, null);
    SSLServerSocketFactory factory = 
        sslCtxt.getServerSocketFactory();
    secureTCPSocket = (SSLServerSocket)
        factory.createServerSocket(port);
    secureTCPSocket.setNeedClientAuth(false);followed by a thread kick-off which will listen for
    connections and spin-off other threads to manage each
    client socket.
    I'm pretty much at my wits end. As I said, seems lots of
    folks have had this problem but I haven't yet seen a
    firm answer.
    If anyone can shed some light on this so I can get my
    proof of conecept going, I would really appreciate it -and buy you a couple of beers!
    Thanks,
    Scott Johnson

    Problem resolved! It was the certificate. I can get it working in a test scenario by using the test certs file
    provided with the jdk on the client and server sides.
    So, does this mean that I MUST use a certificate from
    one of the known authorities as delivered with the JDK?
    My applet will be used by internet clients. I'm requiring
    the sun plug-in. Is it true there is no way to get
    a certificate I've created to be presented to the client
    so it can choose to add it to it's trusted authorities?
    I am required to use, say, a Verisign certificate?
    I can get my sample working but only if I place a
    jssecacerts (a copy of the samplecacerts) where both the client and server can get at it. In the real world, I can't do that on the client.
    Presumably the client will only have the cacerts that was delivered with the Sun plug-in. I'm restricted, then, to using a server key file signed with a certificate from
    one of the providers found in the cacerts file? Or, can
    I present to the client a certificate which it can
    choose to accept as trusted and place in it's cacerts file? Any info would be appreciated - I've already
    committed those duke bucks!
    Scott
    Hi,
    I'm having some trouble getting SSL working and hope
    someone can shed some light. I've been plowing
    through
    these forums for a couple of days - seems lots of
    folks
    have had this problem but I can't find a clear
    solution.
    I've written a server in java. The client is an
    applet.
    This is an internet app so I have no control over
    configuring clients. I'm trying to prove SSL
    communication from the applet to my server. This is
    commercial software so the customer would put their
    own
    keys on the machine and resign the applet before
    deploying.
    I've created a keystore with keytool. Then I self-
    signed it. Then I signed my applet jarfile. I've
    even tried exporting the certificate and importing
    using the java plug-in control panel
    (obviously not something I can do in the real world
    but
    just wanted to see if that was it). I start up my
    server
    and navigate to a web page to start the applet. For
    development purposes, I'm doing this all on one
    machine. I'm running jdk 1.4.1_02. We're requiring
    the
    Sun plug-in as our client java VM.
    Once the client starts to connect, I get this error
    in
    the plug-in console:
    java.security.cert.CertificateException: Couldn't find
    trusted certificate
    On my server, I get:
    Wed May 14 16:27:46 EDT 2003 [EXCEPTION]:
    javax.net.ssl.SSLHandshakeException: Received fatal
    alert: certificate_unknown
    javax.net.ssl.SSLHandshakeException: Received fatal
    alert: certificate_unknown
    at
    com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.a(Dasho
    6275)
    at
    com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.b(Dasho
    6275)
    at
    com.sun.net.ssl.internal.ssl.SSLSocketImpl.b(DashoA627
    at
    com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA627
    at
    com.sun.net.ssl.internal.ssl.SSLSocketImpl.j(DashoA627
    at
    com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA627
    at
    com.sun.net.ssl.internal.ssl.AppInputStream.read(Dasho
    6275)
    at
    sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDec
    der.java:406)
    at
    sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDeco
    er.java:446)
    at
    sun.nio.cs.StreamDecoder.read(StreamDecoder.java:180)
    at
    java.io.InputStreamReader.read(InputStreamReader.java:
    67)
    at
    java.io.BufferedReader.fill(BufferedReader.java:136)
    at
    java.io.BufferedReader.readLine(BufferedReader.java:29
    at
    java.io.BufferedReader.readLine(BufferedReader.java:36
    at
    com.pactolus.webBroker.psWebLegClientThread.run(psWebL
    gClientThread.java:130)
         at java.lang.Thread.run(Thread.java:536)
    The client code is pretty simple:
    SSLSocketFactory factory = (SSLSocketFactory)
    SSLSocketFactory.getDefault();
    tcpSocket = (SSLSocket) factory.createSocket(addr,
    iPortNbr);
    tcpSocket.setUseClientMode(true);
    tcpSocket.startHandshake();followed by a thread kick-off which will listen on
    the
    socket for incoming messages.
    The server code is:
    SSLContext sslCtxt = SSLContext.getInstance("SSL");
    KeyManagerFactory kmf = KeyManagerFactory.getInstance
    ("SunX509");
    KeyStore ks = KeyStore.getInstance("JKS");
    char[] password = keyPassword.toCharArray();
    ks.load(new FileInputStream(keyFile), password);
    kmf.init(ks, password);
    sslCtxt.init(kmf.getKeyManagers(), null, null);
    SSLServerSocketFactory factory = 
    sslCtxt.getServerSocketFactory();
    secureTCPSocket = (SSLServerSocket)
    factory.createServerSocket(port);
    secureTCPSocket.setNeedClientAuth(false);followed by a thread kick-off which will listen for
    connections and spin-off other threads to manage each
    client socket.
    I'm pretty much at my wits end. As I said, seems lots
    of
    folks have had this problem but I haven't yet seen a
    firm answer.
    If anyone can shed some light on this so I can get my
    proof of conecept going, I would really appreciate it
    -and buy you a couple of beers!
    Thanks,
    Scott Johnson

  • Calling EJB from app client

    Hello, everybody,
    I'm very new at EJB and I'm trying to learn it.
    I have created Enterprise Application using Netbeans IDE, I have EJB and APP client. What I want is to connect to my MySql database and get some info from table.
    For e.g. Login and Password.
    How can I call EJB from my client app which connects to my database and gets information I need?

    What server you are using?
    if you use jboss AS ,here is a simple Main class how to connect EJB and access ejb methods:
    package com.david.ejb.client;
    import java.util.Properties;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.rmi.PortableRemoteObject;
    import com.david.ejb.domain.Person;
    import com.david.ejb.domain.PersonRemote;
    public class Main {
         public static void main(String[] args) {
              try {
                   Context ctx = getInitialContext();
                   Object obj = ctx.lookup("PersonSessionRemote/remote");
                PersonRemote pr=(PersonRemote)PortableRemoteObject.narrow(obj, PersonRemote.class);
                Person p=new Person();
                p.setName("david");
                pr.addPerson(p);
                pr.findPerson(1);
                   // System.out.print(br.find(pk).getAuthor_name());
              } catch (Exception ex) {
                   ex.printStackTrace();
         private static Context getInitialContext() throws NamingException {
              Properties p = new Properties();
              p.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.NamingContextFactory");
              p.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
              p.setProperty(Context.PROVIDER_URL, "jnp://localhost:1099");
              return new InitialContext(p);
    }Person is ant @Entity and PersonRemote is remote interfaces, to connect database you have to make datasource file at jboss-4.2.3.GA\server\default\deploy
    simle mysql-ds.xml looks like this:
    datasources>
       <local-tx-datasource>
          <jndi-name>some name</jndi-name>
          <connection-url>jdbc:mysql://localhost:3306/dbname</connection-url>
          <driver-class>com.mysql.jdbc.Driver</driver-class>
          <user-name>root</user-name>
          <password>root password</password>
          <min-pool-size>5</min-pool-size>
          <max-pool-size>100</max-pool-size>
          <idle-timeout-minutes>15</idle-timeout-minutes>
          <exception-sorter-class-name>com.mysql.jdbc.integration.jboss.ExtendedMysqlExceptionSorter</exception-sorter-class-name>
          <valid-connection-checker-class-name>com.mysql.jdbc.integration.jboss.MysqlValidConnectionChecker</valid-connection-checker-class-name>
       </local-tx-datasource>
    </datasources>also at resources/META-INF directory you must have persistence.xml like this
    <persistence>
         <persistence-unit name="SimpleEjb">
              <jta-data-source>java:/some name</jta-data-source>
              <properties>
                   <property name="hibernate.hbm2ddl.auto" value="update" />
                   <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
                   <property name="hibernate.show_sql" value="true"/>
                   <property name="hibernate.format_sql" value="true"/>
              </properties>
         </persistence-unit>
    </persistence>

  • Client code generation question

    I am starting to use OEPE to develop JAX-WS services and my first exercise is the HelloService of the J2EE 6 tutorial. The client code of the example is the following:
    import javax.xml.ws.WebServiceRef;
    import helloservice.endpoint.HelloService;
    import helloservice.endpoint.Hello;
    public class HelloClient {
    public static void main(String[] args) {
    try {
    HelloClient client = new HelloClient();
    client.doTest(args);
    } catch(Exception e) {
    e.printStackTrace();
    public void doTest(String[] args) {
    try {
    System.out.println("Retrieving the port from the following service: " + service);
    HelloService service = new HelloService();
    Hello port = service.getHelloPort();
    System.out.println("Invoking the sayHello operation on the port.");
    String name;
    if (args.length > 0) {
    name = args[0];
    } else {
    name = "No Name";
    String response = port.sayHello(name);
    System.out.println(response);
    } catch(Exception e) {
    e.printStackTrace();
    I have create a web service project and added a web service client for the Hello Service. The above code does not work because the code generated for HelloService is an interface and not as a class. In order to get the example working, I had to use the HelloServiceLocator instead of the HelloService one.
    HelloServiceLocator helloSvcLocator = new HelloServiceLocator();
    Hello port = helloSvcLocator.getHelloPort();
    Did I miss something ?
    Fred

    Fred,
    Sorry for the slow response.
    Just to confirm, you're using this URL?
    http://java.sun.com/webservices/docs/2.0/tutorial/doc/.
    I'm going through the tutorial and most of this seems like it should work through OEPE with some caveats.
    Some initial thoughts:
    In OEPE we don't support java web service clients without using WLS directly or build tools built on top of WLS.
    WLS builds on top of Glassfish web service API calls with its own API calls or ANT tasks.
    For Hello you can deploy this web service from a web service enabled project to a running WLS instance and test through Test Client by right clicking on the file and choosing Run As.
    For HelloClient to work some libraries need to be adjusted if you're using projects within OEPE and WLS since it's initial grammar doesn't allow it to run on WLS.
    Regards,
    Andrew

  • Note 947091 - Persistance Exception on Client-"Entity key already exists."

    Persistance Exception on Client-"Entity key already exists."
    I am using SP18.
    Tell me what is the <b>correction steps</b> for this PROGRAM ERROR.
    did SP19 already solve this problem??
    Message was edited by:
            yzme yzme
    Message was edited by:
            yzme yzme

    <b>step 1) when i sync the application , i will get this </b>
    Exception while proccessing method SMARTSYNC : java.lang.IllegalStateException: No Context available for ConversationId 47AF7ABD0FEF894BBF49E61E6732223E : No Context available for ConversationId 47AF7ABD0FEF894BBF49E61E6732223E 
    • Exception while proccessing method SMARTSYNC : java.lang.IllegalStateException: No Context available for ConversationId 47AF7ABD0FEF894BBF49E61E6732223E : No Context available for ConversationId 47AF7ABD0FEF894BBF49E61E6732223E 
    • Exception while proccessing method SMARTSYNC : java.lang.IllegalStateException: No Context available for ConversationId 47AF7ABD0FEF894BBF49E61E6732223E : No Context available for ConversationId 47AF7ABD0FEF894BBF49E61E6732223E 
    <b>step 2)i modify on the values 1st time, and sync</b>
    Persistance Exception on Client-"Entity key already exists."
    <b>step 3)after that i modify same row with different values</b>
    Creation on Field cZFLIGHT2_010_PAYMENTSUM with value 1600 is not allowed because SyncBo of Row 0001213668 is CHANGED_GLOBAL_INSYNC and CreateInputQualifyType is FORBIDDEN
    b)step 4) try to check the merep_mon, consequtive row with action "M" and no "D"</b>
    try to check the worklist with seq no 8
    msg: No download data from R/3 found in downloader
    <b>step 5) try to sync again</b>
    • Synchronization started 
    • Connection set up (without proxy) to: http://emi-sap:50100/meSync/servlet/meSync?~sysid=N01& 
    • Successfully connected with server. 
    • Processing of inbound data began. 
    • Exception while proccessing method SMARTSYNC : java.lang.IllegalStateException: No Context available for ConversationId 47AF7ABD0FEF894BBF49E61E6732223E : No Context available for ConversationId 47AF7ABD0FEF894BBF49E61E6732223E 
    • Exception while proccessing method SMARTSYNC : java.lang.IllegalStateException: No Context available for ConversationId 47AF7ABD0FEF894BBF49E61E6732223E : No Context available for ConversationId 47AF7ABD0FEF894BBF49E61E6732223E 
    • Exception while proccessing method SMARTSYNC : java.lang.IllegalStateException: No Context available for ConversationId 47AF7ABD0FEF894BBF49E61E6732223E : No Context available for ConversationId 47AF7ABD0FEF894BBF49E61E6732223E 
    • Exception while proccessing method SMARTSYNC : java.lang.IllegalStateException: No Context available for ConversationId 47AF7ABD0FEF894BBF49E61E6732223E : No Context available for ConversationId 47AF7ABD0FEF894BBF49E61E6732223E 
    • Exception while proccessing method SMARTSYNC : java.lang.IllegalStateException: No Context available for ConversationId 47AF7ABD0FEF894BBF49E61E6732223E : No Context available for ConversationId 47AF7ABD0FEF894BBF49E61E6732223E 
    • Exception while proccessing method SMARTSYNC : java.lang.RuntimeException: Inbound processing of container with index 7 failed: Cannot insert as entity already exists for IClassDescriptor/Key: sZFLIGHT2_010/1213683 : r0001213682 : Inbound processing of container with index 7 failed: Cannot insert as entity already exists for IClassDescriptor/Key: sZFLIGHT2_010/1213683 : r0001213682
    anyone can pls tell me if my coding got problem, i just have to modify the row values, and upload it, or do i need to do anything on the uploader/or SyncBoDelta
    my code for modifying values,
    i have change the values of "STREET" to <b>"ANG MO KIO"</b>
    http://i192.photobucket.com/albums/z231/yzme/d1.gif
    but the data in server still <b>"HEAVEN ST"</b>
    http://i192.photobucket.com/albums/z231/yzme/d1.gif
    public String modifyRecordAmt(String eventName,boolean didNavigate){
                             String syncBoName="ZFLIGHT2";
                             String syncKey="0001213682";
                             tableViewBean.setString(syncBoName +" "+syncKey);
                             System.out.println("SyncBoName: " +syncBoName + " syncKey: " +syncKey);
                             tcp = TableContentProvider.instance(syncBoName);
                             tcp.modifyTable(syncBoName,syncKey);                                   return JSP_DETAIL_SYNCBOINSTANCE;
    public void modifyRecordAmt(String syncBoName,String syncKey){
                System.out.println("modifyRecordAmt");
                SyncBoDescriptor sbd=null;
                sbd=descriptorFacade.getSyncBoDescriptor(syncBoName);
                System.out.println("bp 1");
                SyncBo sb=null;
                SyncBo sb2=null;
                try{
                   System.out.println("bp 2");
                     sb=dataFacade.getSyncBo(sbd,syncKey);
                     //sb2=dataFacade.getSyncBo(sbd,"010");
                   System.out.println("bp 3");
                }catch(PersistenceException pex){
                     System.out.println("Exception in modifyRecordLoc:" +pex.getMessage());
                SmartSyncTransactionManager transactionManager;
                try{
                   System.out.println("bp 4");
                     transactionManager=dataFacade.getSmartSyncTransactionManager();
                   System.out.println("bp 5");
                     if(!transactionManager.isTransactionStarted()){
                        System.out.println("bp 6");
                          transactionManager.beginTransaction();
                        System.out.println("bp 7");
                          boolean b1,b2,b3,b4,b5,b6,b7,b8;
                          //b1=setHeaderFieldValue2(sb,"CARRID","AA");
                         //b2=setHeaderFieldValue2(sb,"CONNID","0017");
                          //b3=setHeaderFieldValue2(sb2,"FLDATE","2005-10-10");
                          //b4=setHeaderFieldValue2(sb2,"COUNTRYFR","US");
                          //b5=setHeaderFieldValue2(sb2,"CITYFROM","NEW YORK");
                         // b6=setHeaderFieldValue2(sb2,"AIRPFROM","JFK");
                         // b7=setHeaderFieldValue2(sb2,"SEATSOCC","375");
                         b8=setHeaderFieldValue2(sb,"PAYMENTSUM","1600");
                         //b8=setHeaderFieldValue2(sb,"CITYTO","YORK");
                        System.out.println("bp 8");
                        System.out.println("b8=" +b8);
                        //System.out.println(b3 +" " +" "+b4 +" "+b5 +" " +b6 +" "+b7 +" " +b8);
                          transactionManager.commit();
                        System.out.println("bp 9");
                }catch(Exception e){
                     System.out.println("Exception in modifyRecordAmt2:" +e.getMessage());
         public boolean setHeaderFieldValue2(
              SyncBo sb,
              String headerFieldName,
              Object value) {
              SyncBoDescriptor sbd = sb.getSyncBoDescriptor();
              //RowDescriptor trd = sbd.getTopRowDescriptor();
              System.out.println("bp 10");
              RowDescriptor trd=sbd.getRowDescriptor("010");
              System.out.println("bp 11");
              FieldDescriptor fd = trd.getFieldDescriptor(headerFieldName);
              System.out.println("fd:" +fd.getFieldName());
              if (fd != null) {
              BasisFieldType bft = fd.getFieldType();
              //Row header = sb.getTopRow();
              System.out.println("bp 12");
              //Row header = null;
              Row[] header=null;
              //try {
                   //header = sb.getRow("0001211181");
                   //header=sb.getTopRow();
                   header=getItemInstances(sb,"010");
                   if(header==null){
                        System.out.println("is null");
                   }else{
                        System.out.println("not null");
              //} catch (PersistenceException e1) {
                   // TODO Auto-generated catch block
              //     System.out.println("Exception getRow:" +e1.getMessage());
              //     e1.printStackTrace();
              System.out.println("bp 13");
              try {
    //             Integer operator
              if (bft == BasisFieldType.N) {
                   System.out.println("Numeric");
              NumericField nf = header[0].getNumericField(fd);
              if (nf != null) {
              BigInteger ii = new BigInteger(value.toString());
              nf.setValue(ii);
              return true;
              } else {
              return false;
    //             Character operator
              if (bft == BasisFieldType.C) {
                   System.out.println("Character");
              CharacterField cf = header[0].getCharacterField(fd);
              if (cf != null) {
              cf.setValue(value.toString());
              return true;
              } else {
              return false;
    //             Decimal operator
              if (bft == BasisFieldType.P) {
                   System.out.println("Decimal");
              DecimalField df = header[0].getDecimalField(fd);
              System.out.println("bp 1.1");
              if (df != null) {
                   System.out.println("bp 1.2");
              BigDecimal bd = new BigDecimal(value.toString());
              System.out.println("bp 1.3");
              df.setValue(bd);
              System.out.println("bp 1.4");
              return true;
              } else {
                   System.out.println("bp 1.5");
              return false;
    //             Similar operation for time and date operator fields
              if (bft == BasisFieldType.D) {
                   System.out.println("Date");
              DateField df = header[0].getDateField(fd);
              if (df != null) {
              if (value.toString().equals("0")) {
              Date dat = Date.valueOf("0000-00-00");
              df.setValue(dat);
              } else if (!value.toString().equals("")) {
              Date dat = Date.valueOf(value.toString());
              df.setValue(dat);
              } else {
              Calendar cal = Calendar.getInstance();
              java.sql.Date bd =
              new java.sql.Date(cal.getTime().getTime());
              df.setValue(bd);
              return true;
              } else {
              return false;
    //             Similar operation for time and date operator fields
              } catch (SmartSyncException ex) {
              System.out.println(ex.getMessage());
              } catch (PersistenceException e) {
              System.out.println(e.getMessage());
              return false;
    how to check in the table if the data is uploaded to the Middleware RDB ??
    anyone

Maybe you are looking for

  • HP Officejet 6500 driver for use as WIA-Scanner

    Hello, im using the HP Officejet 6500. I want to use it with the Morena Java API. I establish an access to the device and it is succeding. But as type of device I get WIACamera and what I need is Scanner or WIAScanner. Is there a driver which provide

  • Trigger is not updateing the :new value in the table

    Hi, I've greated a row trigger that will trigger on insert statements. The last thing the trigger will do is to update the :NEW.role_id value in the inserted row, see the trigger bellow. The trigger was mutation so I had to add the 'PRAGMA AUTONOMOUS

  • GL Account/BAPI_ACC_DOCUMENT_POST

    Hi all,    I am using BAPI_ACC_DOCUMENT_POST to post a document. The document gets successfully posted and uploaded in SAP. My input flat file has posting key 06 40 11 50 depending on whether it is a debit or credit line item. But in the BAPI there i

  • Passing internal tables dynamically to a subroutine

    Hi All, How to pass internal tables dynamically to a subroutine? In subroutine logic i'm fetching data from MARA table for all entries in the internal table passed to the subroutine. Based on some condition the internal table varies. I'm placing the

  • Correct format of arguments to ProcessBuilder

    I am having trouble formatting the arguments correctly to launch a windows application using ProcessBuilder. I created a 'shortcut' in windowsXP with the following parameters: TARGET:"C:\Program Files\VirtualDubMod\VirtualDubMod.exe"  /s"R:\Barr0001\