Ejb-ql - important

The ejb-ql in the ejb-jar.xml
select object(d) from Dept d, IN (d.employees) e where e.ename = ?1
produces the following SQL after deployment.
<!-- Generated SQL: "SELECT d.DEPTNO FROM DEPT3055A d , EMP3055A e , EMP3055A tmp__0 WHERE (e.ENAME = ? ) AND ((d.deptno = tmp__0.Dept_deptno AND tmp__0.Emp_empno = e.empno)) -->
which has 2 fields which are wrong. Namely Emp_empno and Dept_deptno . It should have been empno and deptno. Because of which I am getting invalid column names exception.
Can some one help?

Jeff,
Thanks for the reply.
The tables seen are specified by my self.
But, now I have got a solution. I have overridden the "finder-method"s query option with my own query. Since the container seems to generate the query wrongly when I go for more than one table. If I over ride the finder-method with my own query, then it goes on successfully.
Regards
Amirtharaj

Similar Messages

  • Javax.ejb,CreateException import not found

    I've upgraded from WL 8.1 to 10.3 and have an error "javax.ejb,CreateException import not found". javax.ejb used to be in weblogic.jar in 8.1 however, this path is empty in the version from 10.3. Where did it go? Do I need a new lib added to my build path?

    javax.ejb.* is in j2ee.jar
    if you use weblogic6.0, you need download ejb20.jar from http://www.weblogic.com
    if you use weblogic6.1 ,you need't this file.

  • EJB project import/migration fail

    Hi, after import/migrate project on NWDS 7.2 this is the migration detail
    Extended Operation failure:
    org.eclipse.wst.common.componentcore.internal.operation.FacetProjectCreationOperation
    I do not understand where is the problem. Someone can help me?
    Regards

    Hi Ian,
    I am also getting the same issue. Can you please let me know the solution of the same.
    Regards,
    Anand

  • Importing EJB Model in NWDS

    Hi,<br>
    There is a simple Stateless Session Bean which uses an external library (JAR); and there is only 1 business method with just 1 line of code:
    RecordEx r = null;
    <br>
    RecordEx is one of the library classes;<br><br>
    While trying to import this as an EJB Model in Web Dynpro DC in NWDS (7.1 EHP1 SP01 Preview Version), it fails with a NoClassDefFoundError;<br>
    Below are the steps followed;<br><br>
    1. Create an External Library DC "ext"<br>
          1.1 Add the third party library to this DC<br>
          1.2 Create public parts ppC (Compilation) & ppA (Assembly) and add the library to both of these<br>
          1.3 Build the DC<br>
    2. Create an Enterprise Application DC "util"<br>
          2.1 Add Buildtime dependency to ppA public part of "ext" DC<br>
          2.2 Build & deploy<br>
    3. Create EJB Module DC "ejb"<br>
          3.1 Add Buildtime dependency to ppC public part of "ext" DC<br>
          3.2 Create a Session Bean (Stateless - Transaction: Container - Local Interface) <br>
          3.3 Create 1 business method, and create an object of one of the library classes in it<br>
          3.4 Add the business method to Local Interface<br>
          3.5 Check Component Properties > Permissions > Entity Forwarding<br>
          3.6 Build the DC - there are no build errors; default client & ejbjar public parts are created;<br>
    4. Create an Enterprise Application DC "app"<br>
          4.1 Add the "ejb" as Referenced Project<br>
          4.2 Add "util" as Used DC with Deploy Time & Runtime dependencies; (informs "util" EAR DC has no public parts)<br>
          4.3 Create a Compilation public part "EjbClasses" > Reference Entities > Select client public part of "ejb" DC<br>
          4.4 Build & Deploy the DC<br>
    5. Create a Web Dynpro DC "wd"<br>
          5.1 Add dependency to the "app" EAR DC<br>
          5.2 Add Buildtime dependency to ppC public part of "ext" DC<br>
          5.3 Add "util" as Used DC with Deploy Time & Runtime dependencies;<br>
          5.4 Import EJB Model Wizard > Select "app" EAR > Display 1 business method<br>
          5.5 But when that method is selected & click Next, nothing happens in NWDS. The Wizard windows stays like that with no processing<br><br>
    And the NWDS log has this NoClassDefFoundError:<br>
    <br>
    !MESSAGE Unhandled event loop exception
    <br>!STACK 0
    <br>java.lang.NoClassDefFoundError: com/sap/mdm/extension/data/RecordEx
    <br>     at java.lang.Class.getDeclaredMethods0(Native Method)
    <br>     at java.lang.Class.privateGetDeclaredMethods(Class.java:2395)
    <br>     at java.lang.Class.getMethod0(Class.java:2642)
    <br>     at java.lang.Class.getMethod(Class.java:1579)
    <br>     at com.sap.tc.webdynpro.model.ejb.importer.EJBCMIRuntimeMetadataFactory.createEJBModelInfo(EJBCMIRuntimeMetadataFactory.java:223)<br>
         at com.sap.tc.cm.ejb.modeltype.importer.dialog.EJBModelCreationDialog.afterEJBSelectPage(EJBModelCreationDialog.java:374)<br>
         at com.sap.tc.cm.ejb.modeltype.importer.dialog.EJBModelCreationDialog.nextPressed(EJBModelCreationDialog.java:172)<br>
         at com.sap.ide.cmi.core.internal.newmodelwizard.NewModelWizardDialog.nextPressed(NewModelWizardDialog.java:64)<br>
         at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:369)<br>
         at com.sap.ide.cmi.core.internal.newmodelwizard.NewModelWizardDialog.buttonPressed(NewModelWizardDialog.java:88)<br>
         at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:618)<br>
         at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:227)<br>
         at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)<br>
         at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)<br>
         at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)<br>
         at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)<br>
         at org.eclipse.jface.window.Window.runEventLoop(Window.java:820)<br>
         at org.eclipse.jface.window.Window.open(Window.java:796)<br>
         at com.sap.ide.cmi.core.internal.services.CreationServiceUI.createModel(CreationServiceUI.java:76)<br>
         at com.sap.ide.cmi.core.browser.actions.CreateModelAction.run(CreateModelAction.java:60)<br>
         at com.sap.ide.tools.core.viewerfwk.internal.actions.BaseSelectionSingleAction.run(BaseSelectionSingleAction.java:39)<br>
         at com.sap.ide.tools.core.viewerfwk.internal.actions.BaseSelectionAction.runInternal(BaseSelectionAction.java:78)<br>
         at com.sap.ide.tools.core.viewerfwk.internal.actions.BaseSelectionAction.run(BaseSelectionAction.java:70)<br>
         at org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent(BaseSelectionListenerAction.java:168)<br>
         at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:546)<br>
         at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:490)<br>
         at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:402)<br>
         at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)<br>
         at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)<br>
         at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)<br>
         at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)<br>
         at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)<br>
         at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)<br>
         at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)<br>
         at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)<br>
         at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)<br>
         at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)<br>
         at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)<br>
         at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)<br>
         at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169)<br>
         at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)<br>
         at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)<br>
         at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)<br>
         at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)<br>
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br>
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br>
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br>
         at java.lang.reflect.Method.invoke(Method.java:592)<br>
         at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:508)<br>
         at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)<br>
         at org.eclipse.equinox.launcher.Main.run(Main.java:1173)<br>
         at org.eclipse.equinox.launcher.Main.main(Main.java:1148)
    <br>-----<br>
    Please let me know if any step is missed or if something is done incorrectly;<br><br>
    Thank you very much,<br>
    - Harish<br>
    Edited by: Harish Gali on Apr 30, 2010 11:37 AM

    informs "util" EAR DC has no public parts
    this is probably the issue. see if you can make the external library show up in the public part of the util DC
    Edited by: Christian Loos on May 3, 2010 1:03 PM

  • Import javax.ejb cannot be resolved

    Hi,
    There are some libraries missing in the following code.
    package era.budget;
    import javax.ejb.*;
    import era.budget.BudgetVO;
    public class BudgetItemVO implements java.io.Serializable
         private Integer itemId;
         private BudgetVO budget;
         private int type;
         private String itemDetails;
         private int amount;
    // -------------- BEGIN GET/SET METHODS --------------
    public BudgetItemVO(Integer id)
              this.itemId = id;
         public BudgetItemVO()
         public Integer getItemId()
              return itemId;
    public BudgetVO getBudget()
              return budget;
         public void setBudget(BudgetVO budget)
              this.budget=budget;
    public int getType()
              return type;
         public void setType(int id)
         this.type=id;
    public String getItemDetails()
              return this.itemDetails;
    public void setItemDetails(String details)
              this.itemDetails=details;
    public int getAmount()
              return this.amount;
    public void setAmount(int amount)
    this.amount=amount;
    As aresult of these missing libraries there are some compilation errors..Some of the errors are as follows
         1)The import javax.ejb cannot be resolved     
         2)EntityBean cannot be resolved to a type     
    3)EntityContext cannot be resolved to a type     
    4)EJBLocalObject cannot be resolved to a type     
    Thanx & Regards
    Maria.

    try: in your project properties choose 'Java Build Path' and add javaee.jar (from J2EE_HOME\lib) as external jar

  • Error in deploying a simple EJB 3.0

    Hi ,
    I am getting the following error while deploying my simple ejb of version 3.0 in Weblogic 9.2.
    Exception preparing module: EJBModule(build) [EJB:011023]An error occurred while reading the deployment descriptor. The error was: Error processing annotations: java.lang.NullPointerException.
    During my evaluation of Weblogic 9.2 for EJB 3.0 , I have got the following questions.
    EJB Specification states that EJB's in EJB 3.0 can be developed and deployed without the need of deployment descriptors. I have created a simple EJB with two file Env.java and EnvBean.java and the source code is given below.
    a) I just complied these class files and when I was trying to deploy without ejb-jar.xml and weblogic-ejb-jar.xml, the console was not at all allowing me to deploy.Why is this so?
    b) After I created a META-INF file under root of classes directory by placing ejb-jar.xml with empty <enterprise-beans> element, console was allowing me to deploy with errors in parsing ejb-jar.xml. The error was either session/entity/mdb is a required under <enterprise-beans> element. Why is this required when there are several examples stating <enterprise-beans> element can be empty.
    c) Later I updated ejb-jar.xml with <session> element under <enterprise-beans> with the following values. I got the above error when deployed with this change.
    I had been struggling to deploy this simple bean for almost a day.Pleas point me if there is any documentation that solves my stated problem or if there is a solution.Thanks in advance.
    regards
    Karim
    ejb-jar.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" version="3.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">
    <enterprise-beans>
    <session>
    <description>This is the stateless ejb</description>
    <display-name>Env Bean</display-name>
    <ejb-name>EnvBean</ejb-name>
    </session>
    </enterprise-beans>
    </ejb-jar>
    Env.java
    package examples ;
    public interface Env {
    public void display();
    EnvBean.java
    package examples;
    import javax.ejb.Remote;
    import javax.ejb.Stateless;
    @Stateless
    @Remote(Env.class)
    public class EnvBean implements Env {
    public void display() {
    System.out.println("Welcome to EJB 3.0");
    }

    Presumably you're using the EJB3 tech preview, and not a vanilla WebLogic 9.2 install, right?
    Can you post the full stack trace?
    -Patrick

  • I m not getting connected to oracle 9i database using my ejb...

    hi i have made a simple ejb which simply connects to a database of oracle 9i using a datasource on oracle 10g application server...but now my problem is that when i am trying to deploy the ejb ..it is not getting deployed...it shows the following error..
    Deployment failed:nested exception
    resolution:
    base exception:
    com.evermind.server.rmi.OrionRemoteException
    Disconnected:Connection reset. Disconnected:Connection reset.
    the code i am using for EJB class is as follows
    package Simpapp;
    import javax.ejb.*;
    import java.sql.*;
    import javax.naming.*;
    import javax.sql.DataSource;
    public class SimpappBean implements SessionBean {
        static final String DATASOURCE = "bajaj";
        static final String SQL = "select * from login ";
        DataSource ds;
        public String upper (String input) throws java.rmi.RemoteException {
         try {
             Connection conn = ds.getConnection ("bajaj10g","bajaj10g");
             Statement sql = conn.createStatement ();
             //sql.setString (1, input);
             ResultSet results = sql.executeQuery (SQL);
             if (results.next () == false) {
              System.out.println ("No rows for "+ input);
                  throw new java.rmi.RemoteException ("SQL failure");
             } // if
             String result = results.getString ("username");
             results.close ();
             sql.close ();
             conn.close ();
             if (result == null) {
              System.out.println ("NULL result for "+ input);
                  throw new java.rmi.RemoteException ("SQL failure");
             } else
              return (result);
         } catch (SQLException sqle) {
             System.err.println ("While executing SQL: " +
              sqle.getMessage ());
             throw new java.rmi.RemoteException ("SQL failure");
            } catch (Exception e) {
             System.err.println ("Unknown Exception: " +
              e.getMessage ());
             throw new java.rmi.RemoteException ("Bean Exception: " +
              e.getMessage ());
         } // catch
        } // simpapp
        public void ejbCreate () {
             try {
             Context ctx = new InitialContext ();
             ds = (DataSource) ctx.lookup (DATASOURCE);
         } catch (Exception e) {
             System.out.println ("While creating Bean " +
              e.getMessage ());
         } // catch
        } // ejbCreate
        public void ejbRemove () {}
        public void ejbActivate () {}
        public void ejbPassivate () {}
        public void setSessionContext (SessionContext ctx) {}
    } // SimpappBeancan any body suggest me where lies the problem???
    all my Home ,Remote classes are doing well when they are used for any other simple helloworld type of program

    Is that the only Oracle client installed? If you have another one hanging around it could be using the wrong tnsnames file.

  • PHP using soap to call EJB

    Hello everybody,
    I've a problem to call a EJB form a PHP script.
    There is a Apache with PHP 5.2.0 and a SAP NetWeaver Application Server 7.10 / AS Java 7.10 running on the system.
    I wanted to use soap to call a method in an EJB. It's only a test EJB:
    [code]
    package beans;
    import javax.ejb.Stateless;
    import javax.jws.WebService;
    import javax.jws.WebMethod;
    @WebService(name="HelloWorldEARBean",serviceName="HelloWorldEARBeanService",targetNamespace="http://beans/",portName="HelloWorldEARBeanPort") @Stateless public class HelloWorldEARBean {
      @WebMethod public String sayHello(String testStr){
                return "Hello Mr. "+testStr;
      @WebMethod public String getReturn(String inputStr){
                return "the return value is"+inputStr;
    [/code]
    I tried it with the PEAR SOAP in the following script:
    [code]
    <?php
    require_once 'SOAP/Client.php';
    $wsdl_url     = 'http://localhost:50000/HelloWorldEARBeanService/HelloWorldEARBean?wsdl';
    $WSDL = new SOAP_WSDL($wsdl_url);
    $client = $WSDL->getProxy();
    $client->__trace(1);
    $options=array('namespace' => 'http://beans/',
      'style' => 'rpc',
      'soapaction' => 'sayHello');
    $NAME = "Bob"; 
    $parameters=array(
         'parameters', $NAME
    $result = $client->getReturn($parameters);
    echo "<pre>";
    print_r($params);
    echo "</pre>";
    echo "<h2>return</h2>";
    echo "<pre>";
    print_r($result);
    echo "</pre>";
    echo '<h2>Request</h2>';
    echo '<pre>' . htmlspecialchars($client->__getlastrequest(), ENT_QUOTES) . '</pre>';
    echo '<h2>Response</h2>';
    echo '<pre>' . htmlspecialchars($client->__getlastresponse(), ENT_QUOTES). '</pre>';
    ?>
    [/code]
    The AS distributes the following WSDL:
    [code]
    - <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://beans/" xmlns:tns="http://beans/">
    - <wsdl:types>
    - <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0" targetNamespace="http://beans/">
      <xs:element name="getReturn" type="tns:getReturn" />
      <xs:element name="getReturnResponse" type="tns:getReturnResponse" />
      <xs:element name="sayHello" type="tns:sayHello" />
      <xs:element name="sayHelloResponse" type="tns:sayHelloResponse" />
    - <xs:complexType name="sayHello">
    - <xs:sequence>
      <xs:element name="arg0" type="xs:string" minOccurs="0" />
      </xs:sequence>
      </xs:complexType>
    - <xs:complexType name="sayHelloResponse">
    - <xs:sequence>
      <xs:element name="return" type="xs:string" minOccurs="0" />
      </xs:sequence>
      </xs:complexType>
    - <xs:complexType name="getReturn">
    - <xs:sequence>
      <xs:element name="arg0" type="xs:string" minOccurs="0" />
      </xs:sequence>
      </xs:complexType>
    - <xs:complexType name="getReturnResponse">
    - <xs:sequence>
      <xs:element name="return" type="xs:string" minOccurs="0" />
      </xs:sequence>
      </xs:complexType>
      </xs:schema>
      </wsdl:types>
    - <wsdl:message name="sayHelloIn">
      <wsdl:part name="parameters" element="tns:sayHello" />
      </wsdl:message>
    - <wsdl:message name="sayHelloOut">
      <wsdl:part name="sayHelloResponse" element="tns:sayHelloResponse" />
      </wsdl:message>
    - <wsdl:message name="getReturnIn">
      <wsdl:part name="parameters" element="tns:getReturn" />
      </wsdl:message>
    - <wsdl:message name="getReturnOut">
      <wsdl:part name="getReturnResponse" element="tns:getReturnResponse" />
      </wsdl:message>
    - <wsdl:portType name="HelloWorldEARBean">
    - <wsdl:operation name="sayHello" parameterOrder="parameters">
      <wsdl:input message="tns:sayHelloIn" />
      <wsdl:output message="tns:sayHelloOut" />
      </wsdl:operation>
    - <wsdl:operation name="getReturn" parameterOrder="parameters">
      <wsdl:input message="tns:getReturnIn" />
      <wsdl:output message="tns:getReturnOut" />
      </wsdl:operation>
      </wsdl:portType>
    - <wsdl:binding name="HelloWorldEARBeanBinding" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" type="tns:HelloWorldEARBean">
      <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
    - <wsdl:operation name="sayHello">
      <soap:operation soapAction="" />
    - <wsdl:input>
      <soap:body parts="parameters" use="literal" />
      </wsdl:input>
    - <wsdl:output>
      <soap:body use="literal" />
      </wsdl:output>
      </wsdl:operation>
    - <wsdl:operation name="getReturn">
      <soap:operation soapAction="" />
    - <wsdl:input>
      <soap:body parts="parameters" use="literal" />
      </wsdl:input>
    - <wsdl:output>
      <soap:body use="literal" />
      </wsdl:output>
      </wsdl:operation>
      </wsdl:binding>
    - <wsdl:service name="HelloWorldEARBeanService">
    - <wsdl:port name="HelloWorldEARBeanPort" binding="tns:HelloWorldEARBeanBinding">
      <soap:address xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" location="http://localhost:50000/HelloWorldEARBeanService/HelloWorldEARBean" />
      </wsdl:port>
      </wsdl:service>
      </wsdl:definitions>
    [/code]
    By the following output it's obvious that the AS or the EJB (webservice) doesn't receive the parameter send by the PHP script. Look at the output:
    return value:
    the return value is null
    [code]
    Request:
    POST /HelloWorldEARBeanService/HelloWorldEARBean HTTP/1.0
    User-Agent: PEAR-SOAP 0.8.0RC4-devel
    Host: localhost
    Content-Type: text/xml; charset=UTF-8
    Content-Length: 438
    SOAPAction: ""
    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
    >
    <SOAP-ENV:Body>
    <getReturn xmlns="http://beans/">
    <item>parameters</item>
    <item>Bob</item></getReturn>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    Response:
    HTTP/1.1 200 OK
    server: SAP NetWeaver Application Server 7.10 / AS Java 7.10
    content-type: text/xml; charset=utf-8
    date: Wed, 14 Feb 2007 15:51:53 GMT
    connection: close
    <?xml version="1.0" encoding="utf-8"?>
    <SOAP-ENV:Envelope xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <SOAP-ENV:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
    <wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <wsu:Created>2007-02-14T15:51:53Z</wsu:Created>
    <wsu:Expires>2007-02-14T15:52:23Z</wsu:Expires></wsu:Timestamp></wsse:Security></SOAP-ENV:Header>
    <SOAP-ENV:Body><ns2:getReturnResponse xmlns:ns2='http://beans/'>
    <return>the return value is null</return></ns2:getReturnResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
    [/code]
    I used different soap interfaces for PHP like nusoap and the integrated soap interface of PHP 5.
    Further I experimented with different parameters inside the function call
    that results in small differencies at the xml-request.
    Thanks.

    Hi
    I've solved the problem now. I just have to add
    @SOAPBinding(style=SOAPBinding.Style.RPC)
    in the EJB, that's all.
    Here is the complete code, ... maybe some other guys have this problem too, so I will post the working code:
    At first the EJB:
    package beans;
    import javax.ejb.Stateless;
    import javax.jws.WebParam;
    import javax.jws.WebService;
    import javax.jws.WebMethod;
    import javax.jws.soap.SOAPBinding;
    import beans.HelloWorldEARBean;
    @WebService(name="HelloWorldEARBean",serviceName="HelloWorldEARBeanService",targetNamespace="http://beans/",portName="HelloWorldEARBeanPort")
    @SOAPBinding(style=SOAPBinding.Style.RPC)
    @Stateless public class HelloWorldEARBean {
         @WebMethod public String sayHello(@WebParam(name="testStr") String testStr){
                return "Hello Mr. "+testStr;
    2. the local XML:
    <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://beans/" xmlns:tns="http://beans/">
      <wsdl:types>
        <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0" targetNamespace="http://beans/">
          <xs:element name="sayHello" type="tns:sayHello"/>
          <xs:element name="sayHelloResponse" type="tns:sayHelloResponse"/>
          <xs:complexType name="sayHello">
              <xs:element name="testStr" type="xs:string" minOccurs="0"/>
          </xs:complexType>
          <xs:complexType name="sayHelloResponse">
              <xs:element name="return" type="xs:string" minOccurs="0"/>
          </xs:complexType>
        </xs:schema>
      </wsdl:types>
      <wsdl:message name="sayHelloIn">
        <wsdl:part name="parameters" element="tns:sayHello"/>
      </wsdl:message>
      <wsdl:message name="sayHelloOut">
        <wsdl:part name="sayHelloResponse" element="tns:sayHelloResponse"/>
      </wsdl:message>
      <wsdl:portType name="HelloWorldEARBean">
        <wsdl:operation name="sayHello" parameterOrder="parameters">
          <wsdl:input message="tns:sayHelloIn"/>
          <wsdl:output message="tns:sayHelloOut"/>
        </wsdl:operation>
      </wsdl:portType>
      <wsdl:binding name="HelloWorldEARBeanBinding" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" type="tns:HelloWorldEARBean">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="sayHello">
          <soap:operation soapAction=""/>
          <wsdl:input>
            <soap:body parts="parameters" use="literal"/>
          </wsdl:input>
          <wsdl:output>
            <soap:body use="literal"/>
          </wsdl:output>
        </wsdl:operation>
      </wsdl:binding>
      <wsdl:service name="HelloWorldEARBeanService">
        <wsdl:port name="HelloWorldEARBeanPort" binding="tns:HelloWorldEARBeanBinding">
          <soap:address xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" location="http://localhost:50000/HelloWorldEARBeanService/HelloWorldEARBean"/>
        </wsdl:port>
      </wsdl:service>
    </wsdl:definitions>
    3. the PHP script:
    see next post
    Thank you very much for your help.

  • How to connect the EJB webservices using kxmlrpc in J2ME

    Hi all,
    I am trying to develope a program in J2ME using kxmlrpc. I am having the EJB web serivce as server and its working fine , the webservice coding is as follows and i am using Sun application sever for web services
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.ArrayList;
    import javax.ejb.EJBException;
    import javax.ejb.Stateless;
    import javax.jws.WebService;
    import javax.jws.WebMethod;
    import javax.jws.WebParam;
    import javax.sql.*;
    @Stateless()
    @WebService()
    public class test1 {
    /* Sample Web Service Operation */
    @WebMethod(operationName="sample_operation")
    public String operation(@WebParam(name="param_name") String param) {
    // implement the web service operation here
    System.out.println("test the xml rpc");
    param="helloworld";
    return param;
    Any body please help me how to call this web sevices method in J2ME client using kxmlrpc, i tried but it shows execption. And i want to know which url i want ot give inthe XmlRpcclient() and what are all the parameters to be given in xmlrpcclient.execute(). Anybody please help me on this and my kxml coding is as follows:
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.io.*;
    import java.io.*;
    import java.util.*;
    import org.kxmlrpc.*;
    public class kxmlrpc_demo extends MIDlet implements CommandListener {
    private List list;
    private Command exitCommand;
    private String[] menuItems;
    private Display display;
    private Alert response;
    private XmlRpcClient xmlrpc;
    private Vector params, xmlArray;
    public kxmlrpc_demo() {
    //Initialize the User Interface
    menuItems = new String[] {"Timestamp", "Randomizer", "AddressBook"};
    list = new List( "Select a service", List.IMPLICIT, menuItems, null );
    exitCommand = new Command( "Exit", Command.EXIT, 1 );
    response = new Alert("Service Return", null, null, AlertType.INFO);
    response.setTimeout( Alert.FOREVER );
    //Add commands
    list.addCommand( exitCommand );
    list.setCommandListener( this );
    //obtain a reference to the device's UI
    display = Display.getDisplay( this );
    }//end MyMidlet()
    public void startApp() {
    display.setCurrent( list );
    }//end startApp()
    public void pauseApp() {
    }//end pauseApp()
    public void destroyApp( boolean unconditional ) {
    //clean up
    list = null;
    exitCommand = null;
    display = null;
    }//end destroyApp
    public void commandAction( Command com, Displayable dis ) {
    if ( dis == list && com == List.SELECT_COMMAND ) {
    switch( list.getSelectedIndex() )
    case 0:
    try
    xmlrpc = new XmlRpcClient( "http://localhost:4116/test1Service/test1?Tester" );
    params = new Vector();
    String serverTime = (String) xmlrpc.execute( "sysTime.getSystemTime", params );
    response.setString( serverTime.toString() );
    display.setCurrent( response );
    catch ( Exception ex )
    response.setString( ex.toString() );
    ex.printStackTrace(); // DEBUG
    display.setCurrent( response );
    }//end try/catch
    break;
    case 1:
    try
    xmlrpc = new XmlRpcClient( "http://localhost:4116/test1Service/test1?Tester" );
    System.out.println("url"+xmlrpc.getURL());
    params = new Vector();
    xmlArray = new Vector();
    xmlArray.addElement( "param_name" );
    // xmlArray.addElement( "5" );
    // xmlArray.addElement( "12" );
    params.addElement( xmlArray );
    String serverTime = (String) xmlrpc.execute( "sample-operation", params);
    System.out.println("servertime: "+serverTime);
    response.setString( serverTime.toString() );
    display.setCurrent( response );
    catch ( Exception ex )
    response.setString( ex.toString() );
    ex.printStackTrace(); // DEBUG
    display.setCurrent( response );
    }//end try/catch
    break;
    case 2:
    response.setString( "Not implemented yet." );
    display.setCurrent( response );
    break;
    }//end switch( list.getSelectedIndex() )
    else if ( com == exitCommand ) {
    destroyApp( true );
    notifyDestroyed();
    }//end if ( dis == list && com == List.SELECT_COMMAND )
    }//end CommandAction( Command, Displayable )
    }//end MyMidlet
    Thanks in advance.
    regards
    Senthil K

    Any body please help me on this. I am really struggling on this

  • 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

  • Problem with EJB

    hi,
    i am using sun application since i am learning EJB.
    i am getting this error while running a sample EJB code...
    i have deployed ejb successfully and trying to run a client code.
    D:\Users\j2ee\headfirst>java headfirst.AdviceClient
    Nov 21, 2006 3:00:29 PM com.sun.corba.ee.spi.logging.LogWrapperBase doLog
    INFO: "IOP00710299: (INTERNAL) Successfully created IIOP listener on the specifi
    ed host/port: all interfaces/3683"
    WHAT IS THIS
    javax.naming.NameNotFoundException: AdviceBean not found
    at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.
    java:185)
    at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.ja
    va:157)
    at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.ja
    va:161)
    at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialCont
    extProviderImpl.java:101)
    at sun.reflect.GeneratedMethodAccessor64.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(Reflecti
    veTie.java:123)
    at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispa
    tchToServant(CorbaServerRequestDispatcherImpl.java:648)
    at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispa
    tch(CorbaServerRequestDispatcherImpl.java:192)
    at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest
    Request(CorbaMessageMediatorImpl.java:1709)
    at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest
    (CorbaMessageMediatorImpl.java:1569)
    at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(C
    orbaMessageMediatorImpl.java:951)
    at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.call
    back(RequestMessage_1_2.java:181)
    at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest
    (CorbaMessageMediatorImpl.java:721)
    at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.dispatc
    h(SocketOrChannelConnectionImpl.java:469)
    at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.doWork(
    SocketOrChannelConnectionImpl.java:1258)
    at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.
    run(ThreadPoolImpl.java:409)
    D:\Users\j2ee\headfirst>
    REMOTE INTERFACE :
    package headfirst;
    import javax.ejb.*;
    import java.rmi.RemoteException;
    public interface Advice extends EJBObject
    public String getAdvice() throws RemoteException;
    HOME INTERFACE :
    package headfirst;
    import javax.ejb.*;
    import java.rmi.RemoteException;
    public interface AdviceHome extends EJBHome
    public Advice create()throws CreateException,RemoteException;
    BEAN :
    package headfirst;
    import javax.ejb.*;
    public class AdviceBean implements SessionBean
    private SessionContext ctx;
    private String[] adviceStrings={"Visualise yourself", "Work Hard", "Early to bed Early to rise makes a man healthy wealthy and wise",
    "Rest Dont work today", "Take a cup of tea"};
    public void ejbActivate()
    System.out.println("ejb activate");
    public void ejbPassivate()
    System.out.println("ejb passivate");
    public void ejbRemove()
    System.out.println("ejb remove");
    public void setSessionContext(SessionContext ctx)
    this.ctx=ctx;
    System.out.println("Session Context");
    //This is the business method
    public String getAdvice()
    System.out.println("Inside get Advice");
    int random=(int)(Math.random()*adviceStrings.length);
    return adviceStrings[random];
    //You must have ejbCreate() method It is a EJB rule. It does not come from SessionBean Interface.
    public void ejbCreate()
    System.out.println("ejb create");
    CLIENT CODE :
    package headfirst;
    import javax.naming.*;
    import javax.rmi.*;
    import java.rmi.*;
    import java.util.Properties;
    public class AdviceClient
    public static void main(String[] args)
    new AdviceClient().go();
    public void go()
    try{
    AdviceHome home=null;
    Advice advisor=null;
    Properties props=System.getProperties();
    Context ic=new InitialContext(props);
    Object o=ic.lookup("ejb/AdviceBean");
    home=(AdviceHome)PortableRemoteObject.narrow(o,AdviceHome.class);
    advisor=home.create();
    System.out.println(advisor.getAdvice()+"displayed");
    catch(Exception e)
    System.out.println(" WHAT IS THIS ");
    e.printStackTrace();
    could you help me out ...please....

    Looks like you are running a standalone java client, as opposed to JavaEE application client. You may find helpful info in Glassfish EJB FAQ:
    https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html
    -cheng

  • EJB 3.0 entity found within JDeveloper but not on OAS 10.1.3

    I'm tearing my hair out with this!
    Basically I have an entity bean with a primary key annotated with @Id, a stateful session bean facade which has an EntityManager injected through @Resource, and a java client in JDeveloper which calls this bean through a lookup.
    In JDeveloper 10.1.3 it works fine, no problems. I deploy the app, along with a JSP version of this client, to Oracle AS 10.1.3.0 - the deploy goes through without a problem. Whenever I try to use the JSP to test that it's working, I get a NPE in the server logs - but it only points to the compiled JSP class, and therefore not corresponding to a line in the actual JSP!
    Here is the error stack trace:
    06/10/12 12:01:51 java.lang.NullPointerException
    06/10/12 12:01:51 at usernametest.jspService(_usernametest.java:121)
    06/10/12 12:01:51 at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
    06/10/12 12:01:51 at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:416)
    06/10/12 12:01:51 at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:478)
    06/10/12 12:01:51 at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:401)
    06/10/12 12:01:51 at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    06/10/12 12:01:51 at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:719)
    06/10/12 12:01:51 at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:376)
    06/10/12 12:01:51 at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:870)
    06/10/12 12:01:51 at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:451)
    06/10/12 12:01:51 at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:299)
    06/10/12 12:01:51 at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:187)
    06/10/12 12:01:51 at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
    06/10/12 12:01:51 at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303
    06/10/12 12:01:51 at java.lang.Thread.run(Thread.java:595)
    Does this look obvious to anyone? All I am asking is a general idea to what the problem might be. I have been looking at this for 2 weeks and keep going round in circles. If anyone here has any idea that would be much appreciated.
    I will supply other code (JSP, bean) if necessary, as this isn't a Java forum ;)
    Thanks in advance
    Paul

    Hi Lonneke,
    Here is the bean class:
    import java.util.List;
    import javax.annotation.Resource;
    import javax.ejb.Stateful;
    import javax.persistence.EntityManager;
    import javax.persistence.Query;
    @Stateful(name="cart")
    public class CartBean implements CartRemote, CartLocal {
    @Resource
    protected EntityManager manager;
    public CartBean() {
    public User getUser(String username){
    User user = manager.find(User.class, username);
    return user;
    public List<Ereq> getEreqs(String username) {
    Query query = manager.createNativeQuery("SELECT p.BAAN_ACTIVITY_CODE, p.CLIENT_REF_NO, p.DELIVERY_SITE, p.EREQ_MESSAGE, p.EREQ_REF_NO, p.EREQ_STATUS, " +
    "p.LAB_REF_NO, p.ORDER_DATE, p.PROJECT_CODE, p.PURCHASED_ORDER_NUMBER, p.REQUIRED_DATE, p.USER_FULLNAME " +
    "FROM Processed_Ereq p, Ereq_User_Link e, Users u " +
    "WHERE p.ereq_ref_no = e.ereq_ref_no " +
    "AND e.user_id = u.user_id " +
    "AND u.username= '" + username + "'", Ereq.class);
    return query.getResultList();
    Here is the JSP:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page import="sun.misc.BASE64Encoder,java.util.regex.*" %>
    <%@ page import="com.evotec.ereq.CartLocal" %>
    <%@ page import="com.evotec.ereq.User" %>
    <%@ page import="javax.naming.InitialContext" %>
    <%@ page import="java.util.List" %>
    <%@ page import="java.util.ArrayList" %>
    <%!String m_username = "pbarrett";%>
    <%!String emailAddress = "";%>
    <%
    try {
    InitialContext ctx = new InitialContext();
    //CartLocal cart = (CartLocal) session.getAttribute("Cart");
    //if (cart==null) {
    CartLocal cart = (CartLocal) ctx.lookup("java:comp/env/cart");
    //session.setAttribute("Cart", cart);
    //ereqs = cart.getEreqs(m_username);
    User user = cart.getUser(m_username);
    emailAddress = user.getEmailAddress();
    %>
    <html>
    <body>
    you are: <%= m_username %><BR>
    your email address is: <%= emailAddress %><BR>
    </body>
    </html>
    <%
    catch (NullPointerException e){
    e.printStackTrace();
    %>
    Any help is welcome
    Thanks
    Paul

  • EJB 3.0 EntityManager null on JBoss 4.2

    Hi ,
    I am developing an application in EBJ 3.0.
    My application is properly deployed on JBoss 4.2 application server but when I am trying to persist data I am getting EntityManaget always null.
    My Mail Id is : [email protected]
    following is my code Please help me...........
    My datasource for oracle
    D:\jboss-4.2.2.GA\server\default\deploy\oracle-ds.xml
    <datasources>
    <local-tx-datasource>
    <jndi-name>OracleDS</jndi-name>
    <connection-url>jdbc:oracle:thin:@serverIp:1521:SID</connection-url>
    <!--
    Here are a couple of the possible OCI configurations.
    For more information, see http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/java.920/a96654/toc.htm
    <connection-url>jdbc:oracle:oci:@youroracle-tns-name</connection-url>
    or
    <connection-url>jdbc:oracle:oci:@(description=(address=(host=youroraclehost)(protocol=tcp)(port=1521))(connect_data=(SERVICE_NAME=yourservicename)))</connection-url>
    Clearly, its better to have TNS set up properly.
    -->
    <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
    <user-name>V2RND</user-name>
    <password>V2RND</password>
    <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
    <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
    <!-- Checks the Oracle error codes and messages for fatal errors -->
    <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
    <!-- sql to call when connection is created
    <new-connection-sql>some arbitrary sql</new-connection-sql>
    -->
    <!-- sql to call on an existing pooled connection when it is obtained from pool - the OracleValidConnectionChecker is prefered
    <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
    -->
    <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml -->
    <metadata>
    <type-mapping>Oracle9i</type-mapping>
    </metadata>
    </local-tx-datasource>
    </datasources>
    Entity Bean
    com.ntpl.v2hralign.master.entity.Department
    package com.ntpl.v2hralign.master.entity;
    import java.io.Serializable;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.Id;
    import javax.persistence.Table;
    @Entity
    @Table(name="MASTER_DEPARTMENT")
    public class Department implements Serializable {
    @Id
    @Column(name="DEPT_ID")
    private int deptId;
    @Column(name="DEPT_NAME")
    private String deptName;
    private static final long serialVersionUID = 1L;
    public Department() {
    super();
    public int getDeptId() {
    return this.deptId;
    public void setDeptId(int deptId) {
    this.deptId = deptId;
    public String getDeptName() {
    return this.deptName;
    public void setDeptName(String deptName) {
    this.deptName = deptName;
    Remote Interface
    package com.ntpl.v2hralign.master.session;
    import javax.ejb.Remote;
    @Remote
    public interface DepartmentRemote {
    public void createDepartment(int deptId, String deptName);
    package com.ntpl.v2hralign.master.session;
    import javax.annotation.Resource;
    import javax.ejb.Stateless;
    import javax.naming.InitialContext;
    import javax.persistence.EntityManager;
    import javax.persistence.EntityManagerFactory;
    import javax.persistence.Persistence;
    import javax.persistence.PersistenceContext;
    import javax.persistence.PersistenceContextType;
    import org.hibernate.mapping.Component;
    import org.jboss.aspects.Injected;
    import com.ntpl.v2hralign.master.entity.Department;
    @Stateless
    public class DepartmentSession implements DepartmentRemote {
    @PersistenceContext EntityManager entityManager;
    //@Injected protected EntityManager entityManager;
    /*EntityManagerFactory emf = Persistence.createEntityManagerFactory("V2HRAlign");
    EntityManager entityManager = emf.createEntityManager();*/
    /*protected EntityManager entityManager;
    public EntityManager getEntityManager() {
    if (entityManager == null){
    try{
    System.out.println("hi dear not yet get anaything");
    entityManager = (EntityManager)(new InitialContext()).lookup("java:comp/ejb/EntityManager");
    } catch (Exception e){};
    return entityManager;
    @Override
    public void createDepartment(int deptId, String deptName) {
    //entityManager = getEntityManager();
    Department department = new Department();
    department.setDeptId(deptId);
    department.setDeptName(deptName);
    System.out.println("entityManager="+entityManager);
    entityManager.persist(department);
    persistence.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
    <persistence-unit name="V2HRAlign">
    <jta-data-source>java:/OracleDS</jta-data-source>
    <class>com.ntpl.v2hralign.master.entity.Department</class>
    <properties>
    <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect"/>
    <property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver"/>
    <property name="hibernate.hbm2ddl.auto" value="create"/>
    <property name="hibernate.show_sql" value="true" />
    </properties>
    </persistence-unit>
    </persistence>
    Client Program
    package com.ntpl.v2hralignclient.master.client;
    import javax.ejb.EJB;
    import com.ntpl.v2hralign.master.session.DepartmentRemote;
    import com.ntpl.v2hralign.master.session.DepartmentSession;
    public class DepartmentClient {
    * @param args
    @EJB
    public static DepartmentRemote department = new DepartmentSession();
    public static void main(String[] args) {
    department.createDepartment(1, "Software");
    Error -------------------------------
    entityManager=null
    Exception in thread "main" java.lang.NullPointerException
    at com.ntpl.v2hralign.master.session.DepartmentSession.createDepartment(DepartmentSession.java:54)
    at com.ntpl.v2hralignclient.master.client.DepartmentClient.main(DepartmentClient.java:20)
    ---------------------------------------------------------------------------------------------------------------------------------------

    the problem is in your client code. you are instantiating the EJB locally. that is not what you want. you should be looking up the remote ejb using a Context object. look for information on setting up a client program to contact jboss using jndi.

  • EJB 3.0 stateless bean + web client (beginner)

    Hello,
    I've just read the Sun tutorial on EJBs in Java EE 5 and I'm trying to get something nice and simple to work. My code is below:
    Bank.java:
    package beans;
    import javax.ejb.Remote;
    @Remote
    public interface Bank {
         public void transfer(long source, long destination, long amount);
    }BankBean.java:
    package beans;
    import javax.ejb.EJBException;
    import javax.ejb.Stateless;
    @Stateless
    public class BankBean implements Bank {
         public void transfer(long source, long destination, long amount)
              System.out.println("This method is not yet implemented.");
              throw new EJBException("Method not implemented.");
    }index.jsp (web project):
    <%!
    private Bank bank = null;
    public void jspInit()
        try {
            InitialContext ic = new InitialContext();
            bank = (Bank) ic.lookup(Bank.class.getName());
        } catch (Exception ex) {
            System.out.println("Couldn't create bean." + ex.getMessage());
    %>Everything compiles with no errors or warnings, but an exception is thrown. The message is "beans.Bank not found".
    I have not modified any .xml files, I don't recall the tutorial saying I have to.
    I'm using Eclipse 3.2 WTP and it doesn't recognize that I have any Session beans... not 100% sure that EJB 3.0 is supported by it. I ended up creating a basic Java project to store the beans because an EJB project was saying that I need at least one bean.
    Thank you in advance for suggestions.
    Pavel

    While looking up why don't you use the fully
    qualified jndi name"java:/comp/ejb...."?
    What's the benefit of that?It's portable. Any direct access of a global JNDI namespace is not portable.
    Also, it's "java:comp/env", not "java:/comp/env".
    >
    Is it possible to use annotations in JSPs?No, annotations are not supported in JSPs for Java EE 5. In the web tier
    they can be used in certain managed classes such as servlets.
    Regarding your original posting, how exactly did you deploy the ejb? If you
    got a message saying the ejb-jar had no ejbs, that sounds like the root of
    the problem. If the ejb-jar only contains a single EJB 3.0 bean and that
    bean uses EJB 3.0 annotations instead of a deployment descriptor, make
    sure there is no ejb-jar.xml. It's possible that Eclipse packaged an
    EJB 2.1 - based ejb-jar.xml descriptor inside the ejb-jar. In that case,
    the app server will assume it is an EJB 2.1 app and not process any
    annotations.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • EJb 3.0 com.ibm.mq.jms.MQQueueConnectionFactory

    Hi All
    I see this error
    [EJB:011013]The Message-Driven EJB attempted to connect to the JMS connection fa
    ctory with the JNDI name:xxxx.ccerqcf. However, the object with th
    e JNDI name xxxx.ccerqcf is not a JMS connection factory. NestedEx
    ception Message is :com.ibm.mq.jms.MQQueueConnectionFactory
    When using MDB/ EJB 3.0 in WLS 10.0 Mp2
    When I use EJB 2.x I don't see the issue, can ejb 3.o read weblogic-ejb-jar.xml for its connection factory?
    Is there any debug flag to see a better exception
    This is a MDB intended to listen to message from IBM MQ server using a foreign server configured in the console
    Edited by: user12297324 on Mar 15, 2010 3:47 PM
    Edited by: user12297324 on Mar 15, 2010 4:04 PM

    EJB 2.0
    import javax.ejb.*;
    import javax.jms.*;
    public class FOTSysInqMsgBean implements MessageDrivenBean, MessageListener
    //     private static Logger logger = Logger.getLogger(FOTSysInqMsgBean.class);
         MessageDrivenContext messageDrivenContext;
         public void ejbActivate(){}
         public void ejbRemove(){}
         public void ejbPassivate(){}
         public void ejbCreate() throws CreateException {}
         // This is the key onMessage method
         public void onMessage(Message msg)
              //if (logger.isInfoEnabled()) logger.info("Enter MDB onMessage");
    //          byte buf[] = new byte[1000];
    //          int      length      = 0;
              String      inString = null;
              String jmsMsgId = null;
              try
                   if(msg instanceof TextMessage)
                        TextMessage tm = (TextMessage) msg;
                        inString = tm.getText();
                        jmsMsgId = tm.getJMSMessageID();
                        System.out.print(inString);
                        //MQMessageFormatter.parse(inString, jmsMsgId);
                   //else
                        //System.out.println("Is not instanceOf TextMessage");
                   //     if (logger.isInfoEnabled()) logger.info("Not instanceOf TextMessage");
         catch(Exception ex)
              System.out.println("Error IncomingMessage is *********************" +ex);
              //if (logger.isInfoEnabled())
              //     logger.info("FOTSysInqMsgBean === " + ex + " === in Bean class Message method");
         //if (logger.isInfoEnabled()) logger.info("IncomingMessage:" + inString);
         //     if (logger.isInfoEnabled()) logger.info("Exit MDB onMessage");
              //System.out.println("IncomingMessage is *********************" +inString);
         public void setMessageDrivenContext(MessageDrivenContext messageDrivenContext)
              this.messageDrivenContext = messageDrivenContext;
    EJB 3.0
    package foo;
    import javax.annotation.Resource;
    //import javax.ejb.*;
    import javax.ejb.MessageDriven;
    import javax.ejb.ActivationConfigProperty;
    import javax.ejb.MessageDrivenContext;
    import javax.ejb.TransactionAttribute;
    import javax.ejb.TransactionAttributeType;
    import javax.jms.MessageListener;
    import javax.jms.Message;
    import javax.jms.TextMessage;
    * MDB asynchronously feeds the new added reviews to subscribers.
    @MessageDriven
    ( name = "FOTSysInqMsgBean3", //,mappedName = "wholesale.ccer.fjms.maint.rsps.q1",
    activationConfig = {
    @ActivationConfigProperty(propertyName = "destinationType",
              propertyValue = "javax.jms.Queue")
    EJB 3.0
    public class FOTSysInqMsgBean3 implements MessageListener
    //     MessageDrivenContext messageDrivenContext;
         @Resource MessageDrivenContext messageDrivenContext;
         //public void ejbActivate(){}
         //public void ejbRemove(){}
         //public void ejbPassivate(){}
         //public void ejbCreate() throws CreateException {}
         // This is the key onMessage method
         public void onMessage(Message msg)
         //     if (logger.isInfoEnabled()) logger.info("Enter MDB onMessage");
    //          byte buf[] = new byte[1000];
    //          int      length      = 0;
              String      inString = null;
              String jmsMsgId = null;
              try
                   if(msg instanceof TextMessage)
                        TextMessage tm = (TextMessage) msg;
                        inString = tm.getText();
                        jmsMsgId = tm.getJMSMessageID();
                   //     if (logger.isInfoEnabled()) logger.info("MQ Message Class:" + msg.getClass());
              //          if (logger.isInfoEnabled()) logger.info("MQ Message Object:" + msg);
              //          if (logger.isInfoEnabled()) logger.info("MQ Message Id:" + jmsMsgId);
                   //     MQMessageFormatter.parse(inString, jmsMsgId);
                   else
                        //System.out.println("Is not instanceOf TextMessage");
              //          if (logger.isInfoEnabled()) logger.info("Not instanceOf TextMessage");
         catch(Exception ex)
              //System.out.println("Error IncomingMessage is *********************" +ex);
              //if (logger.isInfoEnabled())
         //          logger.info("FOTSysInqMsgBean === " + ex + " === in Bean class Message method");
    //     if (logger.isInfoEnabled()) logger.info("IncomingMessage:" + inString);
         //     if (logger.isInfoEnabled()) logger.info("Exit MDB onMessage");
              //System.out.println("IncomingMessage is *********************" +inString);
         /*public void setMessageDrivenContext(MessageDrivenContext messageDrivenContext)
              this.messageDrivenContext = messageDrivenContext;
    both uses the same weblogic-ejb-jar.xml

Maybe you are looking for

  • Keeps telling me my session has timed out

    Everytime I try to use my ITunes,it tells me my session has timed out...

  • XP Home or Vista Ultimate

    Just wondering, which one should I install onto BootCamp?

  • NQS ERROR15018

    Answers error: " nQSError: 15018: Incorrectly defined logical table source (for fact table Fact_Sales) does not contain mapping for [Dim_Times.CALENDAR_YEAR]. (HY000) " Could any one guide how to resolve this issue. All the joins in PHYSICAL and BMM

  • How to incorporate a Document(link) for a query for documentation purposes

    Hello Everybody, we have on our project very complex queries, where the Queries need to be explained to the user, especially what it means when (s)he enters certain values in the popup and what then the rows and columns of the query then actually sta

  • Flex datagrid dataprovider

    Hi All :D I have a datagrid with an arrayCollection as its data provider. One of the columns, named address, is the concatenation of three addresses from my arrayCollection (address1, address2, address3) My problem is I do not know how to implement t