Problems on SharingReference

Hi,
in a webdypro-application i want to use portalservice via it's API. As in some SAP-documents i filled in the SharingReference in the projekt properties. But in deployment i always get the following warning/error:
Application local/ZZTest cannot be started. Reason: it has hard reference to resource com.sap.portal.usermapping.user_mapping with type application, which is not active on the server.
I want to have access to the usermapping-Service of the portal. Eg. with that code-line:
IUserMappingService iUmService = (IUserMappingService)WDPortalUtils.getServiceReference(IUserMappingService.KEY);
Could anyone give me hint to solve the problem.
Thanks.
Regards André

Hi Ayyapparaj,
thanks, but i does not help:
The referenced application ''tc/je/usermanagement/api'' can''t be started. Check the causing exception for details. Hint: Is the referenced application deployed correctly on the server?
How did you get this name for the reference ?
Regards
André

Similar Messages

  • Jsp bean:setvalue problem

    i use bean in my jsp page.but the problem is that i didn't get the value.i doubt whether the value actully passed to data.my bean is follows:
    package abc;
    public class hai
    private int a;
    public void sethai(int x)
    a=x;
    public int gethai()
         return a;
    my files are as follows
    1) simple.html
    <html>
    <head>
    </head>
    <body>
    <form action="simple1.jsp" method="post" name="form1" target="_self">
    Number:<input name="num" type="text"><br>
    <input name="sub" type="submit" value="sub"></form>
    </body>
    </html>
    2)simple1.jsp
    <html>
    <head></head>
    <%@ page import="abc.*" errorPage="" %>
    <jsp:useBean id="obj" class="abc.hai" scope="session">
    <jsp:setProperty name="obj" property="*"/>
    </jsp:useBean>
    <% out.println(request.getParameter("num"));%>
    <body>number:
    <jsp:getProperty name="obj" property="hai" />
    </body>
    </html>
    the output i got is the value 0
    pls replay me

    Hi Marty,
    Here is my portalapp.xml file:
    <?xml version="1.0" encoding="utf-8"?>
    <application>
      <application-config>
        <property name="PrivateSharingReference" value="com.sap.portal.htmlb"/>
        <property name="SharingReference" value="htmlb"/>
      </application-config>
      <components>
        <component name="DynPageOne">
          <component-config>
            <property name="ClassName" value="com.mycompany.basicexample.DynPageOne"/>
            <property name="SecurityZone" value="com.mycompany.basicexample.DynPageOne/low_safety"/>
          </component-config>
          <component-profile>
            <property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>
            <property name="com.sap.portal.reserved.iview.IsolationMode" value="URL"/>
          </component-profile>
        </component>
      </components>
      <services/>
    </application>
    I also created a getter method in my bean to return a static value and that value is returned correctly.  Any more ideas?

  • FileUpload problem

    Hello all,
    I'm using the FileUpload component in a JSPDynPage but it does not seem to work for me. The problem is a lot like the one Patrick O'Neill asked about. I used the HTMLB example but for some strange reason variable fu remains NULL. Please have a look at my code and explain to me what the problem is. The JSP contains a file upload component and a button to start the upload event.
    This is the java code I used (testprogram):
    import com.sapportals.htmlb.enum.ButtonDesign;
    import com.sapportals.htmlb.event.Event;
    import com.sapportals.htmlb.page.DynPage;
    import com.sapportals.htmlb.page.PageException;
    import com.sapportals.portal.htmlb.page.JSPDynPage;
    import com.sapportals.portal.htmlb.page.PageProcessorComponent;
    import com.sapportals.portal.prt.component.IPortalComponentContext;
    import com.sapportals.portal.prt.component.IPortalComponentProfile;
    import com.sapportals.portal.prt.component.IPortalComponentRequest;
    // for htmlb upload
    import java.io.File;
    import com.sapportals.htmlb.rendering.IFileParam;
    import com.sapportals.htmlb.FileUpload;
    // for debugging
    import com.sapportals.portal.prt.runtime.PortalRuntime;
    import com.sapportals.portal.prt.logger.ILogger;
    import com.sapportals.portal.prt.logger.Level;
    import bean.FileUploadBean;
    public class FileUploadExample extends PageProcessorComponent {
        public DynPage getPage() {
            return new RealJSPDynPage();
        public class RealJSPDynPage extends JSPDynPage {
              FileUploadBean myBean;
              private ILogger defaultLogger = PortalRuntime.getLogger();
            public RealJSPDynPage() {
            public void doInitialization() {
                   // Get the request, context and profile from portal platform
                    IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
                    IPortalComponentContext myContext = request.getComponentContext();
                    IPortalComponentProfile myProfile = myContext.getProfile();
                   defaultLogger.setActive(true);
                   defaultLogger.setLevel(Level.ALL);
                    // Initialization of bean
                    FileUploadBean myBean = new FileUploadBean();
                    setBeanFromProfile(myProfile, myBean);
                    // Put the bean into the application context
                    myContext.putValue("myBeanName", myBean);
            public void doProcessAfterInput() throws PageException {
                   // Get the request, context and profile from portal platform
                    IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
                    IPortalComponentContext myContext = request.getComponentContext();
                    IPortalComponentProfile myProfile = myContext.getProfile();
                    // Get the bean from application context
                    myBean = (FileUploadBean) myContext.getValue("myBeanName");
                    setBeanFromProfile(myProfile, myBean);
             public void doProcessBeforeOutput() throws PageException {
                        setJspName("fileupload.jsp");
              public void onClick(Event event) throws PageException {
                   myBean.setText("I was clicked");
                 String ivSelectedFileName;
                   FileUpload fu = (FileUpload) this.getComponentByName("myfileupload");
                   // debug info message, other option is: severe
                   defaultLogger.info(this, "Hello this is a test");
                   if (fu == null) {
                        // error
                        defaultLogger.severe(this, "strange error");
    //       this is the temporary file
                   if (fu != null) {
    //       Output to the console to see size and UI.
                      System.out.println(fu.getSize());
                      System.out.println(fu.getUI());
                      defaultLogger.info(this, String.valueOf(fu.getSize()));
                      defaultLogger.info(this, fu.getUI());
    //       Get file parameters and write it to the console
                      IFileParam fileParam = fu.getFile();
                      System.out.println(fileParam);
    //       Get the temporary file name
                      File f = fileParam.getFile();
                      String fileName = fileParam.getFileName();
                      defaultLogger.info(this, fileName);
    //       Get the selected file name and write ti to the console
                      ivSelectedFileName = fu.getFile().getSelectedFileName();
                      System.out.println("selected filename: "+ivSelectedFileName);
                      defaultLogger.info(this, "selected filename: "+ivSelectedFileName);
              private void setBeanFromProfile(IPortalComponentProfile myProfile, FileUploadBean myBean) {
                        // FileUpload properties
                        myBean.setSize(myProfile.getProperty("size"));
                        myBean.setMaxLength(myProfile.getProperty("maxLength"));
                        myBean.setAccept(myProfile.getProperty("accept"));
                        // Button properties
                        myBean.setDisabled(myProfile.getProperty("disabled"));
                         myBean.setDesign(ButtonDesign.getEnumByString(myProfile.getProperty("design")));
                         myBean.setEncode(myProfile.getProperty("encode"));
                         myBean.setText(myProfile.getProperty("text"));
                         myBean.setTooltip(myProfile.getProperty("tooltip"));
                         myBean.setWidth(myProfile.getProperty("width"));
    This is the JSP:
    <%--- FileUpload.jsp --%>
    <%@ taglib uri= "tagLib" prefix="hbj" %>
    <%--- Get the Bean named myBeanName from the application context --%>
    <jsp:useBean id="myBeanName" scope="application" class="bean.FileUploadBean" />
    <hbj:content id="myContext" >
      <hbj:page title="Template for a portal component">
       <hbj:form id="myFormId" encodingType="multipart/form-data">
         <hbj:fileUpload
                      id="myFileUpload"
                      size="<%=myBeanName.getSize() %>"
                      maxLength="<%=myBeanName.getMaxLength() %>"
                      accept="<%=myBeanName.getAccept()%>">
         </hbj:fileUpload>
         <hbj:button
              id="MyButton"
              text="<%=myBeanName.getText() %>"
              width="<%=myBeanName.getWidth() %>"
              tooltip="<%=myBeanName.getTooltip() %>"
              onClick="click"
              design="<%=myBeanName.getDesign().getStringValue() %>"
              disabled="<%=myBeanName.isDisabled() %>"
              encode="<%=myBeanName.isEncode() %>">
         </hbj:button>
       </hbj:form>
      </hbj:page>
    </hbj:content>
    The Bean:
    package bean;
    import com.sapportals.htmlb.enum.ButtonDesign;
    public class FileUploadBean
         // FileUpload
         public String size;
         public String maxLength;
         public String accept;
         public String getSize() {
              return size;
         public void setSize(String size) {
              this.size = size;
         public String getMaxLength() {
              return maxLength;
         public void setMaxLength(String maxLength) {
              this.maxLength = maxLength;
         public String getAccept() {
              return accept;
         public void setAccept(String accept) {
              this.accept = accept;
         // Button
         public String disabled;
         public ButtonDesign design;
         public String encode;
         public String text;
         public String tooltip;
         public String width;
         // constructor
    //     public ButtonBean() {
         public String isDisabled() {
              return disabled;
         public void setDisabled(String disabled) {
              this.disabled = disabled;
         public ButtonDesign getDesign() {
              return design;
         public void setDesign(ButtonDesign design) {
              this.design = design;
         public String isEncode() {
              return encode;
         public void setEncode(String encode) {
              this.encode = encode;
         public String getText() {
              return text;
         public void setText(String text) {
              this.text = text;
         public String getTooltip() {
              return tooltip;
         public void setTooltip(String tooltip) {
              this.tooltip = tooltip;
         public String getWidth() {
              return width;
         public void setWidth(String width) {
              this.width = width;
    and the Portalapp.xml
    <?xml version="1.0" encoding="utf-8"?>
    <application>
      <application-config>
        <property name="startup" value="true"/>
        <property name="SharingReference" value="htmlb"/>
      </application-config>
      <components>
        <component name="FileUpload">
          <component-config>
            <property name="ClassName" value="FileUploadExample"/>
            <property name="SecurityZone" value="com.sap.portal.pdk/low_safety"/>
          </component-config>
          <component-profile>
            <property name="maxLength" value="125000">
              <property name="personalization" value="dialog"/>
            </property>
            <property name="accept" value="Accept">
              <property name="personalization" value="dialog"/>
            </property>
            <property name="size" value="50">
              <property name="personalization" value="dialog"/>
            </property>
            <property name="width" value="250">
              <property name="personalization" value="dialog"/>
              <property name="type" value="number"/>
            </property>
            <property name="disabled" value="FALSE">
              <property name="personalization" value="dialog"/>
              <property name="type" value="boolean"/>
            </property>
            <property name="encode" value="True">
              <property name="personalization" value="dialog"/>
              <property name="type" value="boolean"/>
            </property>
            <property name="tooltip" value="Initial Tooltip">
              <property name="personalization" value="dialog"/>
            </property>
            <property name="text" value="Initial Button Text">
              <property name="personalization" value="dialog"/>
            </property>
            <property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>
            <property name="design" value="STANDARD">
              <property name="personalization" value="dialog"/>
              <property name="type" value="select[STANDARD,SMALL,EMPHASIZED]"/>
            </property>
          </component-profile>
        </component>
      </components>
      <services/>
    </application>

    Hi Raymond,
    within your JSP, you have given the ID "myFileUpload" whereas within your coding you try to retrieve a component with ID "myfileupload". That's all so far.
    Some additinal hints:
    When referring to another thread, please give the link; in this case, you talked about Problem with FileUpload component
    If you give (non) working examples, please reduce them to an absolute minimum, so that they show what they should show, but nothing more. This does not only hold on SDN but for all bug tracking systems. People get ill from reading 1000 lines of code where 10 would do
    And for formatting on SDN, you can use [ code ] and [/ code ] (without spaces), makes life easier too.
    And don't forget to press the yellow star button on helping answers...
    So far for today
    Hope it helps
    Detlev

  • Problems while migrating PDK applications from Portal 7.1 to Portal 7.3

    Hi All,
    I am facing a problem while migrating a PDK application from Portal 7.1 to Portal 7.3.
    Since Portal 7.3 doesnt support PAR files any more it provided with a tool to convert the PAR to an EAR file and deploy the resultant EAR to the new portal.
    I converted the PAR into EAR and deployed the file but the application is not executing. When I looked into the log files i found the following exception. The application is not able to identify the tag "documentBody". I checked the protalapp.xml and the "SharingReference" is properly maintained in the file but the error message suggests that its not able to fine the reference to the tagLib uri maintained in the portalapp.xml
    Now my question is why is it not able to obtain a reference to the taglib? Did any one face similar problem previously. Can you please provide me with any document for migrating / developing PDK application for Portal 7.3
    Parser [PRT] - JspParseException is thrown while parsing JSP file </SAP/sap/POD/J00/j2ee/cluster/apps/TestOrg.co.uk/TestOrg~cas~ptlsvc/servlet_jsp/CASPortalService/root/WEB-INF/pagelet/CASFramework.jsp> :
    com.sap.engine.services.servlets_jsp.jspparser_api.exception.JspParseException: Cannot parse custom tag with short name [documentBody].
    at com.sap.engine.services.servlets_jsp.jspparser_api.jspparser.syntax.JspElement.customTagAction(JspElement.java:969)
    at com.sap.engine.services.servlets_jsp.jspparser_api.jspparser.syntax.JspElement.action(JspElement.java:228)
    at com.sap.engine.services.servlets_jsp.jspparser_api.jspparser.syntax.ElementCollection.action(ElementCollection.java:59)
    at com.sap.engine.services.servlets_jsp.jspparser_api.jspparser.syntax.JspElement.customTagAction(JspElement.java:994)
    at com.sap.engine.services.servlets_jsp.jspparser_api.jspparser.syntax.JspElement.action(JspElement.java:228)
    at com.sap.engine.services.servlets_jsp.jspparser_api.jspparser.syntax.ElementCollection.action(ElementCollection.java:59)
    at com.sap.engine.services.servlets_jsp.jspparser_api.jspparser.syntax.JspElement.customTagAction(JspElement.java:994)
    at com.sap.engine.services.servlets_jsp.jspparser_api.jspparser.syntax.JspElement.action(JspElement.java:228)
    at com.sap.engine.services.servlets_jsp.jspparser_api.jspparser.syntax.ElementCollection.action(ElementCollection.java:59)
    at com.sap.engine.services.servlets_jsp.jspparser_api.jspparser.syntax.ElementCollection.action(ElementCollection.java:69)
    at com.sap.engine.services.servlets_jsp.jspparser_api.jspparser.GenerateJavaFile.generateJavaFile(GenerateJavaFile.java:72)
    at com.sap.engine.services.servlets_jsp.server.jsp.JSPProcessor.parse(JSPProcessor.java:272)
    at com.sap.engine.services.servlets_jsp.server.jsp.JSPProcessor.generateJavaFile(JSPProcessor.java:196)
    at com.sap.engine.services.servlets_jsp.server.jsp.JSPProcessor.parse(JSPProcessor.java:128)
    at com.sap.engine.services.servlets_jsp.jspparser_api.JSPChecker.getClassName(JSPChecker.java:377)
    at com.sap.engine.services.servlets_jsp.jspparser_api.JSPChecker.compileAndGetClassName(JSPChecker.java:306)
    at com.sap.engine.services.servlets_jsp.jspparser_api.JSPChecker.getClassNameForProduction(JSPChecker.java:236)
    Thanks in advance
    PK

    Hi Amit,
    Thanks for your reply. I could see some progress after "thoroughly" going through those links. Thanks a lot (gave points too )
    Now I am facing another problem. The application did deploy successfully but with a warning. When i checked the warning it says that the deployment was successful but can not be started.
    The log file has the following error message.
    Global [startApp] operation of application [newsint.co.uk/newsint~cas~ptlsvc] finished with errors for [5] ms on server process [2721950] [
    >>> Errors <<<
    1). com.sap.engine.services.deploy.exceptions.ServerDeploymentException: Application newsint.co.uk/newsint~cas~ptlsvc cannot be started. Reason: it has hard reference to the following resources, which are currently not available on the system: hard to SAPPORTAL/com.sapportals.htmlb (public) (f=true, cl=false); .
    In order to start the application, components that provide the missing resources should be successfully deployed.
    at com.sap.engine.services.deploy.server.ReferenceResolver.isResolved(ReferenceResolver.java:137)
    at com.sap.engine.services.deploy.server.LifecycleController.startReferencedComponents(LifecycleController.java:173)
    at com.sap.engine.services.deploy.server.application.StartTransaction.beginCommon(StartTransaction.java:200)
    at com.sap.engine.services.deploy.server.application.StartTransaction.begin(StartTransaction.java:166)
    at com.sap.engine.services.deploy.server.application.ApplicationTransaction.makeAllPhasesOnOneServer(ApplicationTransaction.java:421)
    at com.sap.engine.services.deploy.server.application.ParallelAdapter.makeAllPhases(ParallelAdapter.java:465)
    at com.sap.engine.services.deploy.server.application.StartTransaction.makeAllPhases(StartTransaction.java:605)
    at com.sap.engine.services.deploy.server.DeployServiceImpl.makeGlobalTransaction(DeployServiceImpl.java:1828)
    I dont understand why is SAPPORTAL/com.sapportals.htmlb is not available. As per my understanding it is some thing that should be available with the portal server by default.
    Any hints from any one?
    thanks in advance
    PK

  • Sharingreference and jar?

    hi,
    i am new to portal development and have a couple of questions.
    i wrote a program and it is expecting a jar file named for example umapi.jar. so i included this jar in the javabuild path of the project and compiled it. also i found that we should mention this in PORTALAPP.XML file as follows:
    sharingreference="usermanagement"
    how could i know that the alias for umapi.jar is usermanagement.
    for example if i am using PRTCORESERVICE.jar for source code compilation, what should i put in  sharingreference?
    any tips and tricks?
    thanks

    ok, thanks again.. last clarification to close the thread
    ok..so can you tell me now, what should i put in the sharingreference of my portal application, which is using "PRTCORESERVICE.jar".
    also,please tell me the steps how you found that.
    Daniel,
    you said "You have to simply check what are the names".. i know only name of a jar file, how could i get the name of the PAR that contains this JAR, so that i could open the portalapp.xml file and find it out.
    Kai,
    you told to open a jar file using winzip or something, would a jar file really contains portalapp.xml file at all? i dont think so.
    my problem is, i know only name of jar that i want, how could i know the name of par file that contains this jar, so that i could open the portalapp.xml file to find the "string" that i should use in my custom portal app.
    sorry, if i am askign silly questions, but it is a million dollor question for me. hope you understand.
    thank you
    Message was edited by: yogi
    Message was edited by: yogi

  • Which SharingReference I need to add at a portal service for these packages

    Hello,
    I have written a portal service, not at the Dynpro, environment which uses these imports:
    com.sap.tc.webdynpro.progmodel.api.IWDNode;
    com.sap.tc.webdynpro.progmodel.api.IWDNodeElement;
    com.sap.tc.webdynpro.services.sal.url.api.IWDCachedWebResource;
    com.sap.tc.webdynpro.services.sal.url.api.WDURLException;
    com.sap.tc.webdynpro.services.sal.url.api.WDWebResource;
    com.sap.tc.webdynpro.services.sal.url.api.WDWebResourceType;
    Which SharingReference do I need to add in order for this to be recognized from the service?

    Hello Valery and Maksim,
    I am familiar with this post yet I have two problems that it doesn't solve:
    1. The reason we are not migrating from Local Dynpro projects to DCs is because of language issues currently handled by SAP. Our GUI is written in Hebrew and at the migration process all the text appearing on the GUI simply vanishes. So, at the moment let's assume we are working with Local Dynpro projects and not DCs.
    2. The second problem we are facing involves from the first one: Since we are not working with DCs yet and since SAP doesn't support local Dynpro projects at the DTR, CBS, CMS even if I will develop such DC it will stay locally and I will be able to use it only from projects at my workspace, other developers won't be able to share it.
    So, at the moment, even if creating a portal service is not the best solution it is the only temporary solution I see right now, unless you have other suggestions...

  • WSDL Web Services Client and EAR deploy problem

    Hi!
    I have allready posted this on "Web AS General", with no result.
    So I hope this forum is a better choise.
    Environment:
    SAP EP / SAP NW04 / SPS14
    NW DevStudio
    I just deployed an ear file (first time ...) with SDM.
    The ear file represents an auto generated web services client on basis of a WSDL file.
    (done from web services perspective in NWDS choosing "New Deployable Proxy Project")
    When running a test I get the following error:
    "Could not find portal application Unknown provider of external application: J2EE::sap.com/NWTPINWSClient"
    .. where NWTPINWSClient is the name of the EAR - file
    The test code contains this:
    The portalapp.xml has the following tag:
    <application-config>
    <property name="SharingReference" value="J2EE::sap.com/NWTPINWSClient">
    </property>
    </application-config>
    I'm new to this, so please feel free to consider newbie misstakes.
    BRGRDS
    Peter M

    Can you/anybody post solution. I have the same problem.
    Thanks
    Srinivas

  • Problems with custom taglib (PD4ML)

    I'm tying to convert html to pdf with PD4ML taglb in a
    portal. But I get a NullpointerException when I try to
    use the taglib.
    I'm running 6.20 SP2
    Configuration as follows:
    PORTAL-INF/Pagelet/
    convert.jsp  (see below)
    PORTAL-INF/lib
    pd4ml_demo.jar (included in the .classpath)
    pd4ml_tl_demo.jar
    PORTAL-INF/taglib/
    pd4ml.tld
    In the portalapp.xml
    <application>
      <application-config>
        <property name="SharingReference" value="knowledgemanagement,htmlb,com.sap.km.bs.ui.wdf,com.sap.km.cm.ui.flex,com.sap.portal.usermanagement,com.sap.portal.useragent,com.sap.portal.pagebuilder,org.zefer.pd4ml"/>
        <property name="ServicesReference" value="com.sap.netweaver.coll.appl.room"/>
        <property name="releasable" value="false"/>
        <property name="startup" value="true"/>
        <property name="ClassLoadingPolicy" value="CoreAccessInAPI,transitive"/>
        <property name="DeploymentPolicy" value="5.0"/>
        <property name="SharingReference" value="knowledgemanagement, landscape, htmlb, exportalJCOclient, exportal,pd4ml"/>
    </application-config>
    <component name="pd4ml">
      <component-config>
       <property name="ComponentType" value="jspnative"/>
       <property name="JSP" value="pagelet/convert.jsp"/>
       <property name="SecurityZone" value="com.tetrapak.neworbis.dist.PORTAL-INF/low_safety"/>
      </component-config>
      <component-profile>
        <property name="pd4ml" value="../taglib/pd4ml.tld"/>
      </component-profile>
    </component>
    convert.jsp
    <%@ taglib uri="../taglib/pd4ml.tld" prefix="pd4ml"%><%@page
    contentType="text/html; charset=ISO8859_1"%><pd4ml:transform
          screenWidth="400"
          pageFormat="A5"
          pageOrientation="landscape"
          pageInsets="100,100,100,100,points"
          enableImageSplit="false">
      <html>
          <head>
               <title>pd4ml test</title>
                <style type="text/css">
                      body
                </style>
          </head>
          <body>
               <img src="images/logos.gif" width="125" height="74">
                <p>
                Hello, World!
    <pd4ml:page_break/>
                <table width="100%" style="background-color: #f4f4f4; color: #000000">
                <tr>
                     <td>
                      Hello, New Page!
                     </td>
                </tr>
                </table>
          </body>
      </html>
    </pd4ml:transform>
    Exception from system log (pd4ml in debug mode)
    Exception ID:01:04_13/06/05_0003
    com.sapportals.portal.prt.component.PortalComponentException: Error in service call of Portal Component
    Component : com.tetrapak.neworbis.pd4ml
    Component class : pagelet._sapportalsjsp_convert
    User : SELOFBERGM
         at com.sapportals.portal.prt.core.PortalRequestManager.handlePortalComponentException(PortalRequestManager.java:853)
         at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:311)
         at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:138)
         at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:191)
         at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:217)
         at com.sapportals.portal.prt.pom.PortalNode.service(PortalNode.java:580)
         at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:301)
         at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:138)
         at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:191)
         at com.sapportals.portal.prt.core.PortalRequestManager.runRequestCycle(PortalRequestManager.java:670)
         at com.sapportals.portal.prt.connection.ServletConnection.handleRequest(ServletConnection.java:229)
         at com.sapportals.portal.prt.dispatcher.Dispatcher$doService.run(Dispatcher.java:555)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sapportals.portal.prt.dispatcher.Dispatcher.service(Dispatcher.java:415)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.inqmy.services.servlets_jsp.server.InvokerServlet.service(InvokerServlet.java:126)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.inqmy.services.servlets_jsp.server.RunServlet.runSerlvet(RunServlet.java:149)
         at com.inqmy.services.servlets_jsp.server.ServletsAndJspImpl.startServlet(ServletsAndJspImpl.java:833)
         at com.inqmy.services.httpserver.server.RequestAnalizer.checkFilename(RequestAnalizer.java:672)
         at com.inqmy.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:314)
         at com.inqmy.services.httpserver.server.Response.handle(Response.java:173)
         at com.inqmy.services.httpserver.server.HttpServerFrame.request(HttpServerFrame.java:1288)
         at com.inqmy.core.service.context.container.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:36)
         at com.inqmy.core.cluster.impl5.ParserRunner.run(ParserRunner.java:55)
         at com.inqmy.core.thread.impl0.ActionObject.run(ActionObject.java:46)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.inqmy.core.thread.impl0.SingleThread.run(SingleThread.java:148)
    Caused by: com.sapportals.portal.prt.component.PortalComponentException: Original exception:
         at pagelet._sapportalsjsp_convert.doContent(_sapportalsjsp_convert.java:105)
         at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:209)
         at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114)
         at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:301)
         at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:138)
         at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:191)
         at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:217)
         at com.sapportals.portal.prt.pom.PortalNode.service(PortalNode.java:580)
         at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:301)
         at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:138)
         at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:191)
         at com.sapportals.portal.prt.core.PortalRequestManager.runRequestCycle(PortalRequestManager.java:670)
         at com.sapportals.portal.prt.connection.ServletConnection.handleRequest(ServletConnection.java:229)
         at com.sapportals.portal.prt.dispatcher.Dispatcher$doService.run(Dispatcher.java:555)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sapportals.portal.prt.dispatcher.Dispatcher.service(Dispatcher.java:415)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.inqmy.services.servlets_jsp.server.InvokerServlet.service(InvokerServlet.java:126)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.inqmy.services.servlets_jsp.server.RunServlet.runSerlvet(RunServlet.java:149)
         at com.inqmy.services.servlets_jsp.server.ServletsAndJspImpl.startServlet(ServletsAndJspImpl.java:833)
         at com.inqmy.services.httpserver.server.RequestAnalizer.checkFilename(RequestAnalizer.java:672)
         at com.inqmy.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:314)
         at com.inqmy.services.httpserver.server.Response.handle(Response.java:173)
         at com.inqmy.services.httpserver.server.HttpServerFrame.request(HttpServerFrame.java:1288)
         at com.inqmy.core.service.context.container.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:36)
         at com.inqmy.core.cluster.impl5.ParserRunner.run(ParserRunner.java:55)
         at com.inqmy.core.thread.impl0.ActionObject.run(ActionObject.java:46)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.inqmy.core.thread.impl0.SingleThread.run(SingleThread.java:148)
    Caused by: java.lang.NullPointerException
         at org.zefer.pd4ml.taglib.PD4MLTransformerTag.doStartTag(PD4MLTransformerTag.java:87)
         at pagelet._sapportalsjsp_convert.doContent(_sapportalsjsp_convert.java:47)
         at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:209)
         at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114)
         at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:301)
         at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:138)
         at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:191)
         at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:217)
         at com.sapportals.portal.prt.pom.PortalNode.service(PortalNode.java:580)
         at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:301)
         at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:138)
         at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:191)
         at com.sapportals.portal.prt.core.PortalRequestManager.runRequestCycle(PortalRequestManager.java:670)
         at com.sapportals.portal.prt.connection.ServletConnection.handleRequest(ServletConnection.java:229)
         at com.sapportals.portal.prt.dispatcher.Dispatcher$doService.run(Dispatcher.java:555)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sapportals.portal.prt.dispatcher.Dispatcher.service(Dispatcher.java:415)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.inqmy.services.servlets_jsp.server.InvokerServlet.service(InvokerServlet.java:126)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.inqmy.services.servlets_jsp.server.RunServlet.runSerlvet(RunServlet.java:149)
         at com.inqmy.services.servlets_jsp.server.ServletsAndJspImpl.startServlet(ServletsAndJspImpl.java:833)
         at com.inqmy.services.httpserver.server.RequestAnalizer.checkFilename(RequestAnalizer.java:672)
         at com.inqmy.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:314)
         at com.inqmy.services.httpserver.server.Response.handle(Response.java:173)
         at com.inqmy.services.httpserver.server.HttpServerFrame.request(HttpServerFrame.java:1288)
         at com.inqmy.core.service.context.container.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:36)
         at com.inqmy.core.cluster.impl5.ParserRunner.run(ParserRunner.java:55)
         at com.inqmy.core.thread.impl0.ActionObject.run(ActionObject.java:46)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.inqmy.core.thread.impl0.SingleThread.run(SingleThread.java:148)
    [email protected]a4 #
    Any ideas or suggestions to solve this problem would be much appreciated.
    Tanks
    M.Lofberg

    Hi Karsten,
    as I have just written in detail within the OSS message mentioned in this thread earlier, I'm really estonished about SAP's perception of what role specifications and standards play within the J2EE world. And as is seen within this thread as well as in many others (or what you can learn when talking to J2EE developers, getting in touch with SAP), this perception is not something which raises SAP's standing among these (in my opinion: important, also for SAP) people.
    > it's not a bug but intended
    Being generous, I would call it an "intended bug"...
    > (for whatever reason)
    If at least there would be someone giving a real reason, one could start discussing if this reason is so unalterable that we developers can say "OK, it's not nice, but that's a reason I can acknowledge".
    The problem arises when someone states "it's intended - for whatever reason". It's not personally, Karsten. But that's the same attitude I got yesterday with the OSS message. Someone closes the message, saying "it works that way". Period. No reason. Nothing. And that's really poor! (I don't expect you to give me the reasons, and it's not your task to do, especially not within some nonsignificant SDN thread. But people closing an OSS message, which reports a violation of the JSP specification should! Anyhow, this combination "not a bug ... intended ... for whatever reason" stands for a special SAP attitude I experience the whole two years I'm working now in this area, and I can say: This is no fun.)
    To be not only criticising: On a first glance
    public ServletResponse getResponse() {
      return componentRequest.getServletResponse(false);
    could do it, maybe. <i>Maybe</i> there is some possible problem arising, but nobody told so far...
    For the reponse object, it seems that this parameter <i>answering</i> (and the logic behind it) could be considered as a problem. Looking at the exampe given - why shouldn't the taglib write something into the (original) response (without the runtime skipping all further content processing)? Maybe this could be the point where the discussion could start (mainly, among SAP development!).
    Best regards,
    and no hard feelings
    Detlev

  • A problem with threads

    I am trying to implement some kind of a server listening for requests. The listener part of the app, is a daemon thread that listens for connections and instantiates a handling daemon thread once it gets some. However, my problem is that i must be able to kill the listening thread at the user's will (say via a sto button). I have done this via the Sun's proposed way, by testing a boolean flag in the loop, which is set to false when i wish to kill the thread. The problem with this thing is the following...
    Once the thread starts excecuting, it will test the flag, find it true and enter the loop. At some point it will LOCK on the server socket waiting for connection. Unless some client actually connects, it will keep on listening indefinatelly whithought ever bothering to check for the flag again (no matter how many times you set the damn thing to false).
    My question is this: Is there any real, non-theoretical, applied way to stop thread in java safely?
    Thank you in advance,
    Lefty

    This was one solution from the socket programming forum, have you tried this??
    public Thread MyThread extends Thread{
         boolean active = true;          
         public void run(){
              ss.setSoTimeout(90);               
              while (active){                   
                   try{                       
                        serverSocket = ss.accept();
                   catch (SocketTimeoutException ste){
                   // do nothing                   
         // interrupt thread           
         public void deactivate(){               
              active = false;
              // you gotta sleep for a time longer than the               
              // accept() timeout to make sure that timeout is finished.               
              try{
                   sleep(91);               
              }catch (InterruptedException ie){            
              interrupt();
    }

  • A problem with Threads and MMapi

    I am tring to execute a class based on Game canvas.
    The problem begin when I try to Play both a MIDI tone and to run an infinit Thread loop.
    The MIDI tone "Stammers".
    How to over come the problem?
    Thanks in advance
    Kobi
    See Code example below:
    import java.io.IOException;
    import java.io.InputStream;
    import javax.microedition.lcdui.Graphics;
    import javax.microedition.lcdui.Image;
    import javax.microedition.lcdui.game.GameCanvas;
    import javax.microedition.media.Manager;
    import javax.microedition.media.MediaException;
    import javax.microedition.media.Player;
    public class MainScreenCanvas extends GameCanvas implements Runnable {
         private MainMIDlet parent;
         private boolean mTrucking = false;
         Image imgBackgound = null;
         int imgBackgoundX = 0, imgBackgoundY = 0;
         Player player;
         public MainScreenCanvas(MainMIDlet parent)
              super(true);
              this.parent = parent;
              try
                   imgBackgound = Image.createImage("/images/area03_bkg0.png");
                   imgBackgoundX = this.getWidth() - imgBackgound.getWidth();
                   imgBackgoundY = this.getHeight() - imgBackgound.getHeight();
              catch(Exception e)
                   System.out.println(e.getMessage());
          * starts thread
         public void start()
              mTrucking = true;
              Thread t = new Thread(this);
              t.start();
          * stops thread
         public void stop()
              mTrucking = false;
         public void play()
              try
                   InputStream is = getClass().getResourceAsStream("/sounds/scale.mid");
                   player = Manager.createPlayer(is, "audio/midi");
                   player.setLoopCount(-1);
                   player.prefetch();
                   player.start();
              catch(Exception e)
                   System.out.println(e.getMessage());
         public void run()
              Graphics g = getGraphics();
              play();
              while (true)
                   tick();
                   input();
                   render(g);
          * responsible for object movements
         private void tick()
          * response to key input
         private void input()
              int keyStates = getKeyStates();
              if ((keyStates & LEFT_PRESSED) != 0)
                   imgBackgoundX++;
                   if (imgBackgoundX > 0)
                        imgBackgoundX = 0;
              if ((keyStates & RIGHT_PRESSED) != 0)
                   imgBackgoundX--;
                   if (imgBackgoundX < this.getWidth() - imgBackgound.getWidth())
                        imgBackgoundX = this.getWidth() - imgBackgound.getWidth();
          * Responsible for the drawing
          * @param g
         private void render(Graphics g)
              g.drawImage(imgBackgound, imgBackgoundX, imgBackgoundY, Graphics.TOP | Graphics.LEFT);
              this.flushGraphics();
    }

    You can also try to provide a greater Priority to your player thread so that it gains the CPU time when ever it needs it and don't harm the playback.
    However a loop in a Thread and that to an infinite loop is one kind of very bad programming, 'cuz the loop eats up most of your CPU time which in turn adds up more delays of the execution of other tasks (just as in your case it is the playback). By witting codes bit efficiently and planning out the architectural execution flow of the app before start writing the code helps solve these kind of issues.
    You can go through [this simple tutorial|http://oreilly.com/catalog/expjava/excerpt/index.html] about Basics of Java and Threads to know more about threads.
    Regds,
    SD
    N.B. And yes there are more articles and tutorials available but much of them targets the Java SE / EE, but if you want to read them here is [another great one straight from SUN|http://java.sun.com/docs/books/tutorial/essential/concurrency/index.html] .
    Edited by: find_suvro@SDN on 7 Nov, 2008 12:00 PM

  • J2ME problem with threads

    Hi all,
    I would like to ask you for a help. I need to write a small program at my university. I started to write a midlet which function would be to countdown time for sports activities. I woul like to start a new thread - the one that counts down - and at the same time make the main thread sleep. After the "countdown" thread finishes, the main thread wakes up and waits for user input. The problem is that when the "countdown" thread finishes his work, I've got Uncaught exception java/lang/NullPointerException. error and the midlet halts.
    Below you can find the code
    import java.lang.*;
    import java.util.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    public class intervals extends MIDlet implements CommandListener
    public Display ekran;
    private SweepCanvas sweeper;
    private Form rundy;
    private TextField round0, round1, round2, round3, round4, round5, round6, round7, round8;
    private long czas,x;
    private Command exitCommand;
    private Command addRound;
    private Command delRound;
    private Command start;
    private TextField repeat;
    private Form odliczanie;
    private Alert ostrz;
    Licznik thread;
    String test;
    StringItem test1;
    int parz,i,j,k;
    static int l;
    int ilrund;
    int ilpowt;
    Item sec;
    long sec1;
    public intervals()
        rundy = new Form("Interwa&#322;y sportowe");
        exitCommand = new Command("Wyj&#347;cie", Command.EXIT, 2);
        addRound = new Command("Dodaj","Dodaj rund&#281;", Command.ITEM,1);
        delRound = new Command("Usu&#324;","Usu&#324; ostatni&#261; rund&#281;", Command.ITEM,1);
        start = new Command("Start", Command.ITEM,1);
        odliczanie = new Form("Odliczanie");
        TextField dodaj(TextField kolej)
            kolej=new TextField("Podaj czas (s) rundy "+parz,null, 4, TextField.NUMERIC);//stworzenie nowej instancji do wybierania czasu trwania rundy
            if(rundy.size()==0)
                rundy.insert(rundy.size(),kolej);
                else
                    rundy.insert(rundy.size()-1, kolej);
            return kolej;
        void odliczanie(TextField round)
            monitor m=new monitor();
            k=Integer.parseInt(round.getString());
            ekran.setCurrent(odliczanie);
            thread=new Licznik(k,odliczanie);
            thread.start();
            ekran.setCurrent(rundy);
    public void startApp()// throws MIDletStateChangeException
        rundy.deleteAll();
        repeat = new TextField("Podaj ilo&#347;&#263; powtórze&#324;",null,1,TextField.NUMERIC);
        rundy.addCommand(addRound);
        rundy.addCommand(exitCommand);
        rundy.setCommandListener(this);
        Canvas obrazek = new MyCanvas();
        ekran = Display.getDisplay(this);
        ekran.setCurrent(obrazek);
        czas=System.currentTimeMillis();
        while (System.currentTimeMillis()<czas+1000)
            continue;
        ekran.setCurrent(rundy);
    public void pauseApp()
    public void destroyApp(boolean unconditional)
        notifyDestroyed();
    public void commandAction(Command c, Displayable s)
        if (c == exitCommand)
            destroyApp(false);
            notifyDestroyed();
        else if(c==addRound)
            if(rundy.size()==0)//Sprawdzenie ilo&#347;ci elementów w celu poprawnego wy&#347;wietlania liczby rund w formie
                parz=1;
                else
                parz=rundy.size();
            switch(parz)
                case 1:
                    round0=dodaj(round0);break;
                case 2:
                    round1=dodaj(round1);break;
                case 3:
                   round2= dodaj(round2);break;
                case 4:
                    round3=dodaj(round3);break;
                case 5:
                    round4=dodaj(round4);break;
                default:
                    ostrz=new Alert("Uwaga","Maksymalna liczba rund wynosi 9", null, AlertType.INFO);
                    ostrz.setTimeout(3000);
                    ekran.setCurrent(ostrz);
            if(rundy.size()==1)
                rundy.append(repeat);
                rundy.addCommand(start);
            rundy.addCommand(delRound);
        else if(c==delRound)
            if(rundy.size()!=0)
                rundy.delete(rundy.size()-2);
                if (rundy.size()==1)
                    rundy.deleteAll();
                if(rundy.size()==0)
                    rundy.removeCommand(delRound);
                    rundy.removeCommand(start);
        else if(c==start)
            ilrund=rundy.size()-1;
            if(this.repeat.size()>0)
                ilpowt=Integer.parseInt(this.repeat.getString());
            ekran = Display.getDisplay(this);
            for (i=1; i<=ilpowt;i++)
                odliczanie= new Form("Odliczanie");
                 for (j=0;j<ilrund;j++)
                    switch(j)
                         case 0:
                             odliczanie(round0);
                             break;
                         case 1:
                             odliczanie(round1);
                             break;
                         case 2:
                             odliczanie(round2);
                             break;
                         case 3:
                             odliczanie(round3);
                             break;
                         case 4:
                             odliczanie(round4);
                             break;
                         case 5:
                             odliczanie(round5);
                             break;
                         case 6:
                             odliczanie(round6);
                             break;
                         case 7:
                             odliczanie(round7);
                             break;
                         case 8:
                             odliczanie(round8);
                             break;
    class Licznik extends Thread
        int czas1,k;
        Form forma;
        monitor m;
        public Licznik(int k,Form formap)
            czas1=k;
            forma=formap;
        public synchronized void run()
            while(czas1>0)
                forma.deleteAll();
                forma.append("Czas pozosta&#322;y (s): "+czas1);
                try{Thread.sleep(1000);} catch(InterruptedException e){e.printStackTrace();}
                czas1--;
            if(czas1<=0)
                m.put();
        }and monitor class
    public class monitor
    boolean busy=false;
    synchronized void get()
        if(!busy)
            try
                wait();
            }catch(InterruptedException e){e.printStackTrace();}
        notify();
    synchronized void put()
        if(busy)
            try
            wait();
            }catch(InterruptedException e){e.printStackTrace();}
        busy=true;
        notify();
    }Can anybody help me with this?

    Groovemaker,
    Your Licznik class has a member m of type monitor, which has not been instantiated (in other words is null) hence, when calling m.put() you get NullPointerException. Please also mind, that using Thread.sleep(1000) is not an accurate way of measuring time.
    If I may, please use recommended for Java class naming conventions - some of your names use lower case, while other don't which is confusing to the reader.
    Daniel

  • Problem with threads within applet

    Hello,
    I got an applet, inside this applet I have a singleton, inside this singleton I have a thread.
    this thread is running in endless loop.
    he is doing something and go to sleep on and on.
    the problem is,
    when I refresh my IE6 browser I see more than 1 thread.
    for debug matter, I did the following things:
    inside the thread, sysout every time he goes to sleep.
    sysout in the singleton constructor.
    sysout in the singleton destructor.
    the output goes like this:
    when refresh the page, the singleton constructor loading but not every refresh, sometimes I see the constructor output and sometimes I dont.
    The thread inside the singleton is giving me the same output, sometime I see more than one thread at a time and sometimes I dont.
    The destructor never works (no output there).
    I don't understand what is going on.
    someone can please shed some light?
    thanks.
    btw. I am working with JRE 1.1
    this is very old and big applet and I can't convert it to something new.

    Ooops. sorry!
    I did.
         public void start() {
         public void stop() {
         public void destroy() {
              try {
                   resetAll();
                   Configuration.closeConnection();
                   QuoteItem.closeConnection();
              } finally {
                   try {
                        super.finalize();
                   } catch (Throwable e) {
                        e.printStackTrace();
         }

  • Problem with Threads and a static variable

    I have a problem with the code below. I am yet to make sure that I understand the problem. Correct me if I am wrong please.
    Code functionality:
    A timer calls SetState every second. It sets the state and sets boolean variable "changed" to true. Then notifies a main process thread to check if the state changed to send a message.
    The problem as far I understand is:
    Assume the timer Thread calls SetState twice before the main process Thread runs. As a result, "changed" is set to true twice. However, since the main process is blocked twice during the two calls to SetState, when it runs it would have the two SetState timer threads blocked on its synchronized body. It will pass the first one, send the message and set "changed" to false since it was true. Now, it will pass the second thread, but here is the problem, "changed" is already set to false. As a result, it won't send the message even though it is supposed to.
    Would you please let me know if my understanding is correct? If so, what would you propose to resolve the problem? Should I call wait some other or should I notify in a different way?
    Thanks,
    B.D.
    Code:
    private static volatile boolean bChanged = false;
    private static Thread objMainProcess;
       protected static void Init(){
            objMainProcess = new Thread() {
                public void run() {
                    while( objMainProcess == Thread.currentThread() ) {
                       GetState();
            objMainProcess.setDaemon( true );
            objMainProcess.start();
        public static void initStatusTimer(){
            if(objTimer == null)
                 objTimer = new javax.swing.Timer( 1000, new java.awt.event.ActionListener(){
                    public void actionPerformed( java.awt.event.ActionEvent evt){
                              SetState();
        private static void SetState(){
            if( objMainProcess == null ) return;
            synchronized( objMainProcess ) {
                bChanged = true;
                try{
                    objMainProcess.notify();
                }catch( IllegalMonitorStateException e ) {}
        private static boolean GetState() {
            if( objMainProcess == null ) return false;
            synchronized( objMainProcess ) {
                if( bChanged) {
                    SendMessage();
                    bChanged = false;
                    return true;
                try {
                    objMainProcess.wait();
                }catch( InterruptedException e ) {}
                return false;
        }

    Thanks DrClap for your reply. Everything you said is right. It is not easy to make them alternate since SetState() could be called from different places where the state could be anything else but a status message. Like a GREETING message for example. It is a handshaking message but not a status message.
    Again as you said, There is a reason I can't call sendMessage() inside setState().
    The only way I was able to do it is by having a counter of the number of notifies that have been called. Every time notify() is called a counter is incremented. Now instead of just checking if "changed" flag is true, I also check if notify counter is greater than zero. If both true, I send the message. If "changed" flag is false, I check again if the notify counter is greater than zero, I send the message. This way it works, but it is kind of a patch than a good design fix. I am yet to find a good solution.
    Thanks,
    B.D.

  • Problem with threads running javaw

    Hi,
    Having a problem with multi thread programming using client server sockets. The program works find when starting the the application in a console using java muti.java , but when using javaw multi.java the program doesnt die and have to kill it in the task manager. The program doesnt display any of my gui error messages either when the server disconnect the client. all works find in a console. any advice on this as I havent been able to understand why this is happening? any comment would be appreciated.
    troy.

    troy,
    Try and post a minimum code sample of your app which
    does not work.
    When using javaw, make sure you redirect the standard
    error and standard output streams to file.
    Graeme.Hi Graeme,
    I dont understand what you mean by redirection to file? some of my code below.
    The code works fine under a console, code is supposed to exit when the client (the other server )disconnects. the problem is that but the clientworker side of the code still works. which under console it doesnt.
    public class Server{
    ServerSocket aServerSocket;
    Socket dianosticsSocket;
    Socket nPortExpress;
    ClientListener aClientListener;
    LinkedList queue = new LinkedList();
    int port = 0;
    int clientPort = 0;
    String clientName = null;
    boolean serverAlive = true;
    * Server constructor generates a server
    * Socket and then starts a client threads.
    * @param aPort      socket port of local machine.
    public Server(int aPort, String aClientName, int aClientPort){
    port = aPort;
    clientName = aClientName;
    clientPort = aClientPort;
    try{
    // create a new thread
    aServerSocket = new ServerSocket(port) ;
    // connect to the nPortExpress
    aClientListener = new ClientListener(InetAddress.getByName(clientName), clientPort, queue,this);
    // aClientListener.setDaemon(true);
    aClientListener.start();
    // start a dianostic port
    DiagnosticsServer aDiagnosticsServer = new DiagnosticsServer(port,queue,aClientListener);
    // System.out.println("Server is running on port " + port + "...");
    // System.out.println("Connect to nPort");
    catch(Exception e)
    // System.out.println("ERROR: Server port " + port + " not available");
    JOptionPane.showMessageDialog(null, (e.toString()),"ERROR: Server port " + port + " not available", JOptionPane.ERROR_MESSAGE);
    serverAlive = false;
    System.exit(1);
    while(serverAlive&&aClientListener.hostSocket.isConnected()){
    try{
    // connect the client
    Socket aClient = aServerSocket.accept();
    //System.out.println("open client connection");
    //System.out.println("client local: "+ aClient.getLocalAddress().toString());
    // System.out.println("client localport: "+ aClient.getLocalPort());
    // System.out.println("client : "+ aClient.getInetAddress().toString());
    // System.out.println("client port: "+ aClient.getLocalPort());
    // make a new client thread
    ClientWorker clientThread = new ClientWorker(aClient, queue, aClientListener, false);
    // start thread
    clientThread.start();
    catch(Exception e)
    //System.out.println("ERROR: Client connection failure");
    JOptionPane.showMessageDialog(null, (e.toString()),"ERROR: Client connection failure", JOptionPane.ERROR_MESSAGE);
    }// end while
    } // end constructor Server
    void serverExit(){
         JOptionPane.showMessageDialog(null, "Server ","ERROR: nPort Failure", JOptionPane.ERROR_MESSAGE);
         System.exit(1);
    }// end class Server
    *** connect to another server
    public class ClientListener extends Thread{
    InetAddress hostName;
    int hostPort;
    Socket hostSocket;
    BufferedReader in;
    PrintWriter out;
    boolean loggedIn;
    LinkedList queue;      // reference to Server queue
    Server serverRef; // reference to main server
    * ClientListener connects to the host server.
    * @param aHostName is the name of the host eg server name or IP address.
    * @param aHostPort is a port number of the host.
    * @param aLoginName is the users login name.
    public ClientListener(InetAddress aHostName, int aHostPort,LinkedList aQueue,Server aServer)      // reference to Server queue)
    hostName = aHostName;
    hostPort = aHostPort;
    queue = aQueue;
    serverRef = aServer;      
    // connect to the server
    try{
    hostSocket = new Socket(hostName, hostPort);
    catch(IOException e){
    //System.out.println("ERROR: Connection Host Failed");
    JOptionPane.showMessageDialog(null, (e.toString()),"ERROR: Connection to nPort Failed", JOptionPane.ERROR_MESSAGE);     
    System.exit(0);
    } // end constructor ClientListener
    ** multi client connection server
    ClientWorker(Socket aSocket,LinkedList aQueue, ClientListener aClientListener, boolean diagnostics){
    queue = aQueue;
    addToQueue(this);
    client = aSocket;
    clientRef = aClientListener;
    aDiagnostic = diagnostics;
    } // end constructor ClientWorker
    * run method is the main loop of the server program
    * in change of handle new client connection as well
    * as handle all messages and errors.
    public void run(){
    boolean alive = true;
    String aSubString = "";
    in = null;
    out = null;
    loginName = "";
    loggedIn = false;
    while (alive && client.isConnected()&& clientRef.hostSocket.isConnected()){
    try{
    in = new BufferedReader(new InputStreamReader(client.getInputStream()));
    out = new PrintWriter(new OutputStreamWriter(client.getOutputStream()));
    if(aDiagnostic){
    out.println("WELCOME to diagnostics");
    broadCastDia("Connect : diagnostics "+client.getInetAddress().toString());
    out.flush();
    else {       
    out.println("WELCOME to Troy's Server");
    broadCastDia("Connect : client "+client.getInetAddress().toString());
         out.flush();
    String line;
    while(((line = in.readLine())!= null)){
    StringTokenizer aStringToken = new StringTokenizer(line, " ");
    if(!aDiagnostic){
    broadCastDia(line);
    clientRef.sendMessage(line); // send mesage out to netExpress
    out.println(line);
    out.flush();
    else{
    if(line.equals("GETIPS"))
    getIPs();
    else{
    clientRef.sendMessage(line); // send mesage out to netExpress
    out.println(line);
    out.flush();
    } // end while
    catch(Exception e){
    // System.out.println("ERROR:Client Connection reset");
                             JOptionPane.showMessageDialog(null, (e.toString()),"ERROR:Client Connection reset", JOptionPane.ERROR_MESSAGE);     
    try{
    if(aDiagnostic){
    broadCastDia("Disconnect : diagnostics "+client.getInetAddress().toString());
    out.flush();
    else {       
    broadCastDia("Disconnect : client "+client.getInetAddress().toString());
         out.flush();
    // close the buffers and connection;
    in.close();
    out.close();
    client.close();
    // System.out.println("out");
    // remove from list
    removeThreadQueue(this);
    alive = false;
    catch(Exception e){
    // System.out.println("ERROR: Client Connection reset failure");
    JOptionPane.showMessageDialog(null, (e.toString()),"ERROR: Client Connection reset failure", JOptionPane.ERROR_MESSAGE);     
    }// end while
    } // end method run
    * method run - Generates io stream for communicating with the server and
    * starts the client gui. Run also parses the input commands from the server.
    public void run(){
    boolean alive = true;
    try{
    // begin to life the gui
    // aGuiClient = new ClientGui(hostName.getHostName(), hostPort, loginName, this);
    // aGuiClient.show();
    in = new BufferedReader(new InputStreamReader(hostSocket.getInputStream()));
    out = new PrintWriter(new OutputStreamWriter(hostSocket.getOutputStream()));
    while (alive && hostSocket.isConnected()){
    String line;
    while(((line = in.readLine())!= null)){
    System.out.println(line);
    broadCast(line);
    } // end while
    } // end while
    catch(Exception e){
    //     System.out.println("ERRORa Connection to host reset");
    JOptionPane.showMessageDialog(null, (e.toString()),"ERROR: Connection to nPort reset", JOptionPane.ERROR_MESSAGE);
    try{
    hostSocket.close();
         }catch(Exception a){
         JOptionPane.showMessageDialog(null, (a.toString()),"ERROR: Exception", JOptionPane.ERROR_MESSAGE);
    alive = false;
    System.exit(1);
    } // end method run

  • Problem with Threads and "plase wait..."-Window

    Hi everyone,
    I have a problem that I'm not able to solve in any way... I have a time-consuming task (a file decryption) which I execute in a separate thread; I've used the SwingWorker class, like suggested by sun-tutorial, and it works right. The problem is that I have to wait that the decryption have finished before continuing with program-execution. Therefore I would like to display a "please wait"-window while the task runs. I've tryed all the possible ways I know but the problem is always the same: the waitWindow is displayed empty, the bounds are painted but the contents no; it's only painted when the decrypt-task has finished. Please help me, I have no more resources....
    decrypt-file code:
    public class DecryptFile {
      private String cryptedFileNameAndPath;
      private ByteArrayInputStream resultStream = null;
      // need for progress
      private int lengthOfTask;
      private int current = -1;
      private String statMessage;
      public DecryptFile(String encZipFileNameAndPath) {
        cryptedFileNameAndPath = encZipFileNameAndPath;
        //Compute length of task...
        // 0 for indeterminate
        lengthOfTask = 0;
      public ByteArrayInputStream getDecryptedInputStream() {
        return this.resultStream;
       * Called from ProgressBarDemo to start the task.
      public void go() {
        current = -1;
        final SwingWorker worker = new SwingWorker() {
          public Object construct() {
            return new ActualTask();
        worker.start();
       * Called from ProgressBarDemo to find out how much work needs
       * to be done.
      public int getLengthOfTask() {
        return lengthOfTask;
       * Called from ProgressBarDemo to find out how much has been done.
      public int getCurrent() {
        return current;
      public void stop() {
        current = lengthOfTask;
       * Called from ProgressBarDemo to find out if the task has completed.
      public boolean done() {
        if (current >= lengthOfTask)
          return true;
        else
          return false;
      public String getMessage() {
        return statMessage;
       * The actual long running task.  This runs in a SwingWorker thread.
      class ActualTask {
        ActualTask () {
          current = -1;
          statMessage = "";
          resultStream = AIUtil.getInputStreamFromEncZip(cryptedFileNameAndPath); //here the decryption happens
          current = 0;
          statMessage = "";
      }The code that calls decryption and displays waitWindow
          final WaitSplash wS = new WaitSplash("Please wait...");
          final DecryptFile cryptedTemplate = new DecryptFile (this.templateFile);
          cryptedTemplate.go();
          while (! cryptedTemplate.done()) {
            try {
              wait();
            } catch (Exception e) { }
          this.templateInputStream = cryptedTemplate.getDecryptedInputStream();
          wS.close();Thanks, thanks, thanks in advance!
    Edoardo

    Maybe you can try setting the priority of the long-running thread to be lower? so that the UI will be more responsive...

Maybe you are looking for

  • Installed OSX update and apps won't open

    I just installed the latest OS-X update and now only Safari will open. I can't run Software update to reload the update. Can someone help me. Thank you!

  • Posting Document Split by Personnel Area

    PC00_M99_CIPE transaction has default posting variant SAP and this variant splits the posting document by based on company code. Is there anyone who can guide me how to create new posting variant which uses the Personnel Area? Is this possible? Thank

  • Free download of Oracle 10g & JDeveloper 10g(10.1.2.1)

    I am a new user of Oracle 10g.After downloading oracle10g from ur site,i was not able to access it on my desktop.The message i see on screen is 'to open this file windows needs to know what programme created it.' I run Microsoft Windows Xp 2002 versi

  • Yahoo Contacts more than 255 disappear

    So I synch my contacts with Yahoo.  I have 413 contacts.  But the other day I go into my contact list on my iPhone 5 and all contracts after "M" are gone.  It shows 255 on hte iPhone.  All are still in Yahoo.  So I turn off the synching with Yahoo. D

  • Audio Stream Recorder Prob

    Have Audigy 2 Platinum Pro & XP Pro. Wish to set up timed recording of streaming radio broadcast. Audio Stream Recorder status window shows recording status as "Audio device is already being used by another program." No other audio/video program is r