Separte GUI and application code

Below is my code to separate GUI and application code. When i try to execute the code i get message applet not initiated. Can any one point what mistake i am doing in the code.
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
class ColorAction extends AbstractAction
     public ColorAction(String name, Icon icon,Color c, Component comp)
          putValue(Action.NAME, name);
          putValue(Action.SMALL_ICON,icon);
          putValue("Color",c);
          target = comp;
     public void actionPerformed(ActionEvent evt)
          Color c = (Color)getValue("Color");
          target.setBackground(c);
          target.repaint();
     private Component target;
class ActionButton extends JButton
     public ActionButton(Action a)
          setText((String)a.getValue(Action.NAME));
          Icon icon = (Icon)a.getValue(Action.SMALL_ICON);
          if(icon != null)
               setIcon(icon);
          addActionListener(a);
public class SepGUI extends JApplet
     public void init()
          JPanel panel = new JPanel();
          Action blueAction = new ColorAction("Blue",new ImageIcon("a.gif"),Color.blue,panel);
          Action yellowAction = new ColorAction("Yellow",new ImageIcon("a.gif"),Color.yellow,panel);
          Action redAction = new ColorAction("Red",new ImageIcon("a.gif"),Color.red,panel);
          panel.add(new ActionButton(yellowAction));
          panel.add(new ActionButton(blueAction));
          panel.add(new ActionButton(redAction));
          Container contentPane = getContentPane();
          contentPane.add(panel);
}

public class SepGUI extends JApplet
  public void init()
    JPanel panel = new JPanel();
    try
      Action blueAction = new ColorAction("Blue",new ImageIcon(new java.net.URL (getCodeBase(),"a.gif")),Color.blue,panel);
      Action yellowAction = new ColorAction("Yellow",new ImageIcon(new java.net.URL (getCodeBase(),"a.gif")),Color.yellow,panel);
      Action redAction = new ColorAction("Red",new ImageIcon(new java.net.URL (getCodeBase(),"a.gif")),Color.red,panel);
      panel.add(new ActionButton(yellowAction));
      panel.add(new ActionButton(blueAction));
      panel.add(new ActionButton(redAction));
    catch(Exception e){}
    Container contentPane = getContentPane();
    contentPane.add(panel);
}

Similar Messages

  • UI and Application Code?

    I've been exposed to Java but without GUI. I've just started to learn swing and event handling. Normally in developing an application, the GUI code and the application code is preferrably separated. Now my question is, how do the application code and GUI are able to interact. How do I connect them? inheritance? i hope to get some sample codes to do this. I've bought books to learn java but none seem to tell me how to...Hope to get some replies soon. Thanks in advance

    See that link over at the left that says "Tutorials"? Click on it, it will lead you to a page full of links to guess what. One of those links says "The Swing Tutorial". Need I say more?

  • J2SE GUI and application for bluetooth

    Hi
    Does anyone have any example how to combine one class which calculates or in this particular case searches for devices in vicinity (while looping in order to check enviroment constantly) with GUI created thank to NetBeans.
    Main problem is that as a novice I have no idea how to put content of variables in fields and refresh them periodically. Variables are in another class but I might try to connect them in one final class.
    Thank you for help in advance
    Regards
    lormitto

    Hi,
    Your requirements are not 100% clear. In  your message you say you are looking for SNC between SAP GUI and SAP ABAP, but the help page you posted a link for is not related to this, but explains how to use SNC for CPIC.
    If you are looking to use SNC for authenticating users of SAP GUI to SAP ABAP, then you have a number of options. If your SAP ABAP server is on Windows then SAP have a library which can be obtained for no cost to give you basic SSO using Active Directory authentication (aka Kerberos). If your SAP application server is on Unix or Linux, then you can look on SAP EcoHub for third party SAP certified products which provide this functionality. SAP have also just launched a new product which has some functionality for SAP GUI SSO, but this is not free.
    Please let me know if you have any more questions or need clarification.
    Thanks,
    Tim

  • WLSS3.0 and application code SNMP trap error

    Hi,
    I'm trying to generate SNMP traps through application code as described in the documentation at [url http://e-docs.bea.com/wlcp/wlss30/programming/snmptraps.html]. By using an SNMP manager I have verified that WLSS can send traps during startup and shutdown. My application code, however, fails to do so. When my SIP servlet is deployed, I get the following errors.
    <17.apr.2007 kl 10.02 CEST> <Notice> <SNMP Agent> <000000> <The SNMP trap version is 1>
    <17.apr.2007 kl 10.02 CEST> <Error> <SNMP> <BEA-320912> <Error during initialization while attempting to obtain MBeanServerConnection.
    java.io.IOException: Unable to resolve 'weblogic.management.mbeanservers.domainruntime'. Resolved 'weblogic.management.mbeanservers'
            at weblogic.management.remote.common.ClientProviderBase.makeConnection(ClientProviderBase.java:135)
            at weblogic.management.remote.common.ClientProviderBase.newJMXConnector(ClientProviderBase.java:79)
            at javax.management.remote.JMXConnectorFactory.newJMXConnector(JMXConnectorFactory.java:326)
            at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:247)
            at weblogic.management.snmp.agent.ServerMap.createMBeanServerConnection(ServerMap.java:262)
            Truncated. see log file for complete stacktrace
    javax.naming.NameNotFoundException: Unable to resolve 'weblogic.management.mbeanservers.domainruntime'. Resolved 'weblogic.management.mbeanservers'; remaining n
    ame 'domainruntime'
            at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)
            at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:252)
            at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:171)
            at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206)
            at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:214)
            Truncated. see log file for complete stacktrace
    >
    <17.apr.2007 kl 10.02 CEST> <Error> <SNMP> <BEA-320909> <Error during initialization while attempting to obtain the required DomainRuntimeServer.>Using the example code, I fail to obtain the SipServletSnmpTrapRuntime MBean.
    regards,
    Jegern

    Hi,
    what you show us is not teh servlet mapping but the servlet definition. The servlet mapping maps a configured servlet to a URL. You can use the property editor in JDeveloper for this. Just select the web.xml file and choose "properties" from teh context menu
    Frank

  • Calling a VB Script and Matlab code from LabVIEW GUI.

    Hi,
    Can anyone help me out in Calling a VB Script and Matlab code from LabVIEW GUI? GUI will be developed in Labview and currently we have some scripts written in VB and Matlab and we need to incorporate the same through LabVIEW. Can anyone let me know how this can be implemented? 
    Regards,
    Sharmash

    For VBScript you can call the Windows Scripting Host application using the System Exec function, or you can use IScriptControl, which is an ActiveX control. Be aware that with the IScriptControl there's a small bug. You can read more about it in this post.
    For Matlab, there's a Matlab node that you can use. You can either copy and past your Matlab script in the node, or just write a function call statement. The node simply calls Matlab. Or, you can do as suggested and use the MathScript node, which is basically an alternative to Matlab. The MatchScript node doesn't support everything that Matlab does, so you will need to check it against your script.
    Or, you can do as suggested, and rewrite it all in LabVIEW, unless you can't because these scripts are used by other applications.

  • Most all my applications are crashing. The Exception Type on all that crash: EXC_BAD_ACCESS (SIGBUS) and Exception Codes: KERN_PROTECTION_FAILURE at ... I am a newbie, does anyone have an idea what has happened?

    Most all my applications are crashing.
    The Exception Type on all that crash: EXC_BAD_ACCESS (SIGBUS) and Exception Codes: KERN_PROTECTION_FAILURE at ...
    All browsers but Safari crash
    I can't view any video media but quicktime works.
    Example: iPhoto
    Process:         iPhoto [2167]
    Path:            /Applications/iPhoto.app/Contents/MacOS/iPhoto
    Identifier:      com.apple.iPhoto
    Version:         9.1.5 (9.1.5)
    Build Info:      iPhotoProject-6150000~1
    Code Type:       X86 (Native)
    Parent Process:  launchd [254]
    Date/Time:       2011-09-05 16:25:22.327 -0500
    OS Version:      Mac OS X 10.7.1 (11B26)
    Report Version:  9
    Interval Since Last Report:          734286 sec
    Crashes Since Last Report:           427
    Per-App Interval Since Last Report:  154207 sec
    Per-App Crashes Since Last Report:   2
    Anonymous UUID:                      9AD5F8B1-380F-4563-A57D-A589708BA3D2
    Crashed Thread:  0  Dispatch queue: com.apple.main-thread
    Exception Type:  EXC_BAD_ACCESS (SIGBUS)
    Exception Codes: KERN_PROTECTION_FAILURE at 0x000000009802d0cb
    Just about everything crashes.
    Help...please?

    How old is this machine? If it's less than 90 days old you have 90 days of Free AppleCare coverage, call them! You will find the phone number in your manual. If it's out of AppleCare or you bought it used take it your local Apple Store or AASP to have it looked at. We don't have enough information to know what the problem might be. You can run some tests such as Apple Hardware Test in Extended Mode 2-3x to see if it has any hardware errors. Beyond that it's really tough to say.

  • [svn:fx-trunk] 5464: ASDoc updates for FxApplication and Application ( no code changes)

    Revision: 5464
    Author: [email protected]
    Date: 2009-03-20 11:52:50 -0700 (Fri, 20 Mar 2009)
    Log Message:
    ASDoc updates for FxApplication and Application (no code changes)
    * notes the pageTitle property is for use with the SDK HTML templates
    * update the default values for backgroundGradientColors
    QE Notes: None
    Doc Notes: Please review
    Bugs: SDK-16535, SDK-16693
    Reviewer:
    tests: checkintests
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-16535
    http://bugs.adobe.com/jira/browse/SDK-16693
    Modified Paths:
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/components/FxApplication.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/core/Application.as

  • Creating exe for application that contains ARINC and MIL Codes

    Hi all,
    I am not able to create exe for my application that contains ARINC and MIL. To be precise, the ARINC and MIL part is not working in the exe created. 
    Please tell me how to create an EXE with ARINC and MIL codes.

    Did you install the according device drivers on the target machine? And no I don't mean the instrument drivers that you use in LabVIEW but the OS device drivers from NI (resp. AIT), that will access the hardware boards and provide an interface to the LabVIEW application. I would expect them to be part of the AIT SDK kit that comes with the boards.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Menu bar and application toolbar

    is there a way to change item text on menu bar and application toolbar  eg in business partner overview(T-Code fmcacov) i want to change text 'Business Partner" to "tax Payer" on both menu bar an application toolbar. i have tried the norma way of going to change the screen but when i am on the GUI status its not going to change mode even sfter entering the access key

    Hi ,
    Open the program and click on GOTO=>ATTRIBUTES.
    Change the text to the heading which you want.
    SAVE & ACTIVATE.
    Regarding opening in change mode, the steps you have carried out are correct.
    You need to comment the existing gui-status by placing cursor on that line & click delete.
    Then click on INsert button and add new gui-status.
    Best regards,
    Prashant

  • Best Practices for NCS/PI Server and Application Monitoring question

    Hello,
    I am deploying a virtual instance of Cisco Prime Infrastructure 1.2 (1.2.1.012) on an ESX infrastructure. This is being deployed in an enterprise enviroment. I have questions around the best practices for moniotring this appliance. I am looking to monitor application failures (services down, db issues) and "hardware" (I understand this is a virtual machine, but statistics on the filesystem and CPU/Memory is good).
    Firstly, I have enabled via the CLI the snmp-server and set the SNMP trap host destination. I have created a notification receiver for the SNMP traps inside the NCS GUI and enabled the "System" type alarm. This type includes alarms like NCS_DOWN and PI database is down. I am trying to understand what the difference between enabling SNMP-SERVER HOST via the CLI and setting the Notification destination inthe GUI is? Also how can I generate a NCS_DOWN alarm in my lab. Doing NCS stop does not generate any alarms. I have not been able to find much information on how to generate this as a test.
    Secondly, how and which processes should I be monitoring from the Management Station? I cannot easily identify the main NCS procsses from the output of ps -ef when logged in the shell as root.
    Thanks guys!

    Amihan_Zerrudo wrote:
    1.) What is the cost of having the scope in a <jsp:useBean> tag set to 'session'? I am aware that there are a list of scopes like page, application, etc. and that if i use 'session' my variable will live for as long as that session is alive. (did i get this right?). You should rather look to the functional requirements instead of costs. If the bean need to be session scoped (e.g. maintain the logged in user), then do it so. If it just need to be request scoped (e.g. single page form data), then keep it request scoped.
    2.)If the JSP Page where i use that <useBean> is to be accessed hundred of times a day, will it compensate my server resources? Right now i am using the Sun Glassfish Server.It will certainly eat resources. Just supply enough CPU speed and memory to a server. You cannot expect that a webserver running at a Pentium 500MHz with 256MB of memory can flawlessly serve 100 simultaneous users at the same second. But you may expect that it can serve 100 users per 24 hour.
    3.) Can you suggest best practice in memory management given the architecture i described above?Just write code so that it doesn't unnecessarily eat memory. Only allocate memory if your application need to do so. You should rather let the hardware depend on the application requirements, not to let the application depend on the hardware specs.
    4.)Also, I have implemented connection pooling in my architecture, but my application is to be used by thousands of clients everyday.. Can the Sun Glassfish Server take care of that or will I have to purchase a powerful sever?Glassfish is just an application server software, it is not server hardware. Your concerns are rather hardware related.

  • Pf status and function codes

    Hi,
    I have a report where in i have to add a new icon with a tick symbol along with the existing execute icon ie f8.I have copied the status of the program into another before adding the new icon and to that i have added the new icon and function code.
    i have used set pf-status in the initialisation event.Now when i give the select options and press f8 it enters into the program but sy-ucomm is still empty and does not do the desired functionality.If i click the icon for test run it does not enter the program itself.Can anyone help me out on this.
    The status is activated in se41.
    Points will be rewarded.
    Please help.
    Regards,
    Sowmya.

    hi,
    just try like that used in the report: demo_list_at_user_command
    like:
    START-OF-SELECTION.
      WRITE: 'Basic List',
           / 'SY-LSIND:', sy-lsind.
    TOP-OF-PAGE.
      WRITE 'Top-of-Page'.
      ULINE.
    TOP-OF-PAGE DURING LINE-SELECTION.
      CASE sy-pfkey.
        WHEN 'TEST'.
          WRITE 'Self-defined GUI for Function Codes'.
          ULINE.
      ENDCASE.
    AT LINE-SELECTION.
      SET PF-STATUS 'TEST' EXCLUDING 'PICK'.
      PERFORM out.
      sy-lsind = sy-lsind - 1.
    AT USER-COMMAND.
      CASE sy-ucomm.
        WHEN 'FC1'.
          PERFORM out.
          WRITE / 'Button FUN 1 was pressed'.
        WHEN 'FC2'.
          PERFORM out.
          WRITE / 'Button FUN 2 was pressed'.
        WHEN 'FC3'.
          PERFORM out.
          WRITE / 'Button FUN 3 was pressed'.
        WHEN 'FC4'.
          PERFORM out.
          WRITE / 'Button FUN 4 was pressed'.
        WHEN 'FC5'.
          PERFORM out.
          WRITE / 'Button FUN 5 was pressed'.
      ENDCASE.
      sy-lsind = sy-lsind - 1.
    FORM out.
      WRITE: 'Secondary List',
           / 'SY-LSIND:', sy-lsind,
           / 'SY-PFKEY:', sy-pfkey.
    ENDFORM.
    When you run the program, the system displays the following basic list with a the page header defined in the program:
    You can trigger the AT LINE-SELECTION event by double-clicking a line. The system sets the status TEST and deactivates the function code PICK. The status TEST contains function codes FC1 to FC5. These are assigned to pushbuttons in the application toolbar. The page header of the detail list depends on the status.
    Here, double-clicking a line no longer triggers an event. However, there is now an application toolbar containing five user-defined pushbuttons. You can use these to trigger the AT USER-COMMAND event. The CASE statement contains a different reaction for each pushbutton.
    For each interactive event, the system decreases the SY-LSIND system field by one, thus canceling out the automatic increase. All detail lists now have the same level as the basic list and thus overwrite it. While the detail list is being created, SY-LSIND still has the value 1.
    Regards,
    Renjith Michael.

  • Keeping Swing calls on the EDT, app code off the EDT, and boilerplate code

    I have been reading about the EDT and Swing for a while now and I have not been able to find very good tutorials or explanations. I understand that swing calls should be on the EDT and I have seen hints about application code needing to be on its own thread, which seems obvious. I have seen code for how to do this, but it seems like in order to really enforce these rules, I'd have to setup invoke SwingUtilities.invokeLater on all my swing related functions (I have a ton of them), and then for non-swing related functions, I'd have to constantly check to make sure they are not on the EDT with javax.swing.SwingUtilities.isEventDispatchThread?

    BoBear2681 wrote:
    Also keep in mind that many very quick non-UI tasks can safely be done on the EDT. For example, if you load a very small text file (a few KB), this is usually so fast that there's no need to do it off the EDT. Just pointing out that not literally everything needs to be done off the EDT, just anything that runs long enough to produce a noticeable unresponsive pause in your GUI. Users are okay with an application taking 0.1 seconds to open a file, for example. But doing 10 seconds of number crunching, connecting to a remote server, etc. are the kinds of things you'd want to do off the EDT.That's extremely true, and I meant to touch on that but forgot (yep, my memory is so bad that I forget what I was going to type in the amount of time it takes to post a reply).
    When I first started to figure out the EDT, I became paranoid about keeping non-GUI stuff off of it. However, I've since realized that sometimes it's unavoidable, and usually it doesn't matter anyway.

  • What is the diffrence between sap events and application events

    Hi all,
    what is the diffrence between sap events and application events.Can any one tell me with examples.
    regards,

    Hi,
    Look at this,
    <b>System Events (Default)</b>
    The event is passed to the application server, but does not trigger the PAI. If you have registered an event handler method in your ABAP program for the event (using the SET HANDLER statement), this method is executed on the application server.
    Within the event handler method, you can use the static method SET_NEW_OK_CODE of the global class CL_GUI_CFW to set a function code and trigger the PAI event yourself. After the PAI has been processed, the PBO event of the next screen is triggered.
    The advantage of using this technique is that the event handler method is executed automatically and there are no conflicts with the automatic input checks associated with the screen. The disadvantage is that the contents of the screen fields are not transported to the program, which means that obsolete values could appear on the next screen. You can work around this by using the SET_NEW_OK_CODE method to trigger field transport and the PAI event after the event handler has finished.
    <b>Application Events</b>
    The event is passed to the application server, and triggers the PAI. The function code that you pass contains an internal identifier. You do not have to evaluate this in your ABAP program. Instead, if you want to handle the event, you must include a method call in a PAI dialog module for the static method DISPATCH of the global class CL_GUI_CFW. If you have defined an event handler method in your ABAP program for the event (using the SET HANDLER statement), the DISPATCH method calls it. After the event handler has been processed, control returns to the PAI event after the DISPATCH statement and PAI processing continues.
    The advantage of this is that you can specify yourself the point at which the event is handled, and the contents of the screen fields are transported to the application server beforehand. The disadvantage is that this kind of event handling can lead to conflicts with the automatic input checks on the screen, causing events to be lost.
    Hope u understood.
    Thanks&Regards,
    Ruthra.R

  • Excel format difference in GUI and NWBC

    Hi Experts,
    We have implemented Launchpad with different SAP T-codes. For IW38 tcode.
    1. If we execute in GUI and tried to save record in excel. Format is perfect with coloring of columns, without any empty rows or columns.
    2. But when we use the same T-code in NWBC, the excel being downloaded doesnt contain cloring and it shows 1 empty colomn and 1 empty row.
      End user needs same excel sheet as in GUI. Please help to solve this. Version is NWBC HTML 3.5.
    Regards,
    Dhanu.

    Hi Shrishti,
    I am sorry. I should have explained you the steps. Actually, after executing CJE2. You need to double click on report group 12KST1A for S_ALR_87013558 and 12KST1B for S_ALR_87013557.
    Now, for both the report groups. Just click on the Output type tab. I am sure that for S_ALR_87013558 report, middle one radio button must have been selected in your case. Just change it to Graphical Report Output OR it would be much better if you just make it available on selection screen by clicking on check button at the bottom.
    have a look at the screen shot.
    Just do the changes and revert back.
    Regards,
    Amit Rajoria

  • The system could not find a javax.ws.rs.ext.MessageBodyWriter or a DataSourceProvider class for the com.rest.assignment.EmpBean type and application/json mediaType.  Ensure that a javax.ws.rs.ext.MessageBodyWriter exists in the JAX-RS application for the

    Hi,
    Im trying to create a Rest WS with a @GET method that will return me an Emp object. I need the output as a JSON string.
    I have created a dynamic web project and added javax RS jars:
    When im trying to run this, i'm getting the below mentioned error:
    FlushResultHa E org.apache.wink.server.internal.handlers.FlushResultHandler handleResponse The system could not find a javax.ws.rs.ext.MessageBodyWriter or a DataSourceProvider class for the com.rest.assignment.EmpBean type and application/json mediaType.  Ensure that a javax.ws.rs.ext.MessageBodyWriter exists in the JAX-RS application for the type and media type specified.
    RequestProces I org.apache.wink.server.internal.RequestProcessor logException The following error occurred during the invocation of the handlers chain: WebApplicationException (500 - Internal Server Error)
    Please help as im stuck with this from long.
    Thanks in advance.
    Below is the code for my service class:
    package com.rest.assignment;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.util.Enumeration;
    import java.util.HashSet;
    import java.util.Properties;
    import java.util.Set;
    import javax.ws.rs.GET;
    import javax.ws.rs.Path;
    import javax.ws.rs.Produces;
    import javax.ws.rs.core.Application;
    import javax.ws.rs.core.MediaType;
    import javax.ws.rs.core.Response;
    @Path("/restService")
    public class RestService extends Application {   
        @GET
        @Path("/getEmpDetails")
        @Produces(MediaType.APPLICATION_JSON)
        public Response getStringResponse()
            EmpBean empBean = new EmpBean();
            String filePath = "C:/Program Files/IBM/workspace/HelloWorld/src/com/rest/resources/EmpData.properties";
            Properties properties = new Properties();
            try {
                properties.load(new FileInputStream(filePath));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
             Enumeration e = properties.propertyNames();
             String result="";
            String[] empDetailsArr;
            while (e.hasMoreElements()) {
              String key = (String) e.nextElement();
              String empDetails = properties.getProperty(key);
              empDetailsArr=empDetails.split(",");    
              empBean.setFirstName(empDetailsArr[0]);
              empBean.setLastName(empDetailsArr[1]);
              empBean.setEmpId(empDetailsArr[2]);
              empBean.setDesignation(empDetailsArr[3]);
              empBean.setSkillSet(empDetailsArr[4]);
              result = empDetailsArr[1];
            //return empBean;
            return Response.ok(empBean).type(MediaType.APPLICATION_JSON_TYPE).build();
        @Override
        public Set<Class<?>> getClasses() {
            Set<Class<?>> classes = new HashSet<Class<?>>();
            classes.add(RestService.class);
            classes.add(EmpBean.class);
            return classes;
    and my empBean goes like this:
    package com.rest.assignment;
    public class EmpBean {
        private String firstName;
        private String lastName;
        private String empId;
        private String designation;
        private String skillSet;
        public String getFirstName() {
            return firstName;
        public void setFirstName(String firstName) {
            this.firstName = firstName;
        public String getLastName() {
            return lastName;
        public void setLastName(String lastName) {
            this.lastName = lastName;
        public String getEmpId() {
            return empId;
        public void setEmpId(String empId) {
            this.empId = empId;
        public String getDesignation() {
            return designation;
        public void setDesignation(String designation) {
            this.designation = designation;
        public String getSkillSet() {
            return skillSet;
        public void setSkillSet(String skillSet) {
            this.skillSet = skillSet;
    Web.xml goes like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" 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/web-app_3_0.xsd">
    <display-name>restWS</display-name>
    <welcome-file-list>
      <welcome-file>index.html</welcome-file>
      <welcome-file>index.htm</welcome-file>
      <welcome-file>index.jsp</welcome-file>
      <welcome-file>default.html</welcome-file>
      <welcome-file>default.htm</welcome-file>
      <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
    <servlet>
      <servlet-name>REST</servlet-name>
      <servlet-class>com.ibm.websphere.jaxrs.server.IBMRestServlet</servlet-class>
      <init-param>
       <param-name>javax.ws.rs.Application</param-name>
       <param-value>com.rest.assignment.RestService</param-value>
      </init-param>
      <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
      <servlet-name>REST</servlet-name>
      <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>
    </web-app>
    When i try to return a string from my get method, it gives me a proper response. i get this exception when im trying to return a JSON response.

    Hi,
    Im trying to create a Rest WS with a @GET method that will return me an Emp object. I need the output as a JSON string.
    I have created a dynamic web project and added javax RS jars:
    When im trying to run this, i'm getting the below mentioned error:
    FlushResultHa E org.apache.wink.server.internal.handlers.FlushResultHandler handleResponse The system could not find a javax.ws.rs.ext.MessageBodyWriter or a DataSourceProvider class for the com.rest.assignment.EmpBean type and application/json mediaType.  Ensure that a javax.ws.rs.ext.MessageBodyWriter exists in the JAX-RS application for the type and media type specified.
    RequestProces I org.apache.wink.server.internal.RequestProcessor logException The following error occurred during the invocation of the handlers chain: WebApplicationException (500 - Internal Server Error)
    Please help as im stuck with this from long.
    Thanks in advance.
    Below is the code for my service class:
    package com.rest.assignment;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.util.Enumeration;
    import java.util.HashSet;
    import java.util.Properties;
    import java.util.Set;
    import javax.ws.rs.GET;
    import javax.ws.rs.Path;
    import javax.ws.rs.Produces;
    import javax.ws.rs.core.Application;
    import javax.ws.rs.core.MediaType;
    import javax.ws.rs.core.Response;
    @Path("/restService")
    public class RestService extends Application {   
        @GET
        @Path("/getEmpDetails")
        @Produces(MediaType.APPLICATION_JSON)
        public Response getStringResponse()
            EmpBean empBean = new EmpBean();
            String filePath = "C:/Program Files/IBM/workspace/HelloWorld/src/com/rest/resources/EmpData.properties";
            Properties properties = new Properties();
            try {
                properties.load(new FileInputStream(filePath));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
             Enumeration e = properties.propertyNames();
             String result="";
            String[] empDetailsArr;
            while (e.hasMoreElements()) {
              String key = (String) e.nextElement();
              String empDetails = properties.getProperty(key);
              empDetailsArr=empDetails.split(",");    
              empBean.setFirstName(empDetailsArr[0]);
              empBean.setLastName(empDetailsArr[1]);
              empBean.setEmpId(empDetailsArr[2]);
              empBean.setDesignation(empDetailsArr[3]);
              empBean.setSkillSet(empDetailsArr[4]);
              result = empDetailsArr[1];
            //return empBean;
            return Response.ok(empBean).type(MediaType.APPLICATION_JSON_TYPE).build();
        @Override
        public Set<Class<?>> getClasses() {
            Set<Class<?>> classes = new HashSet<Class<?>>();
            classes.add(RestService.class);
            classes.add(EmpBean.class);
            return classes;
    and my empBean goes like this:
    package com.rest.assignment;
    public class EmpBean {
        private String firstName;
        private String lastName;
        private String empId;
        private String designation;
        private String skillSet;
        public String getFirstName() {
            return firstName;
        public void setFirstName(String firstName) {
            this.firstName = firstName;
        public String getLastName() {
            return lastName;
        public void setLastName(String lastName) {
            this.lastName = lastName;
        public String getEmpId() {
            return empId;
        public void setEmpId(String empId) {
            this.empId = empId;
        public String getDesignation() {
            return designation;
        public void setDesignation(String designation) {
            this.designation = designation;
        public String getSkillSet() {
            return skillSet;
        public void setSkillSet(String skillSet) {
            this.skillSet = skillSet;
    Web.xml goes like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" 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/web-app_3_0.xsd">
    <display-name>restWS</display-name>
    <welcome-file-list>
      <welcome-file>index.html</welcome-file>
      <welcome-file>index.htm</welcome-file>
      <welcome-file>index.jsp</welcome-file>
      <welcome-file>default.html</welcome-file>
      <welcome-file>default.htm</welcome-file>
      <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
    <servlet>
      <servlet-name>REST</servlet-name>
      <servlet-class>com.ibm.websphere.jaxrs.server.IBMRestServlet</servlet-class>
      <init-param>
       <param-name>javax.ws.rs.Application</param-name>
       <param-value>com.rest.assignment.RestService</param-value>
      </init-param>
      <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
      <servlet-name>REST</servlet-name>
      <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>
    </web-app>
    When i try to return a string from my get method, it gives me a proper response. i get this exception when im trying to return a JSON response.

Maybe you are looking for

  • How to specify a radio button as disabled in Net-UI

    How do i specify a radio button to be disabled using the net-ui ?? i know i can do it in HTML using <INPUT TYPE="RADIO" NAME="btn1" VALUE="today" DISABLED> So what is the Net-UI equivalent to the same ? I could not find much information in the worksh

  • Please help with a few drivers for z60m after fresh install

    I got a bad virus(several actually) that I could not eradicate. I was advised to just wipe and reinstall the OS since it is not under warranty anymore. I could not find the recovery disk, must have been lost inthe last military move could not find a

  • Saving PDF's

    I have a PDF file that is being used on a urgent project. I have separated it into 10 individual sections. I want to upload these 10 files to Acrobat.com so that my committee members can access and edit the files. My problem is that I don't know Acro

  • SD invoice split - VF01

    Hello, Someone ask me to try to ( in some cases ) split a SD invoice in N invoices, if the actually created invoice created in VF01 has N items. As i didn't find any BADI or user-exit when i can do it, does anyone knows a way to do that ? If someone

  • DataGuard 10gr2 (10.2.0.4) AIX 5.2-primary Aix 6.1-Standby possible?

    We currently have 10.2.0.4 DG configuration running on three AIX 5.2 servers (one primary, two standbys). We will be installing some new servers that will be pre-loaded with AIX 6.1. If we were to install 10.2.0.4 on these new AIX 6.1 servers is it p