Nested methods

I'm missing this programming techinque very much. I find 3 reasons to use nested methods: hierarchic code is easier to understand, no need to pass local variables as paraters and resulting speedup.
Here is an example from one of the replays on the topic:
class Foo {
     int num;
     void foo() {
          num = 3;
          class MethodClass {
               void printHI() { System.out.println("HI"); }
          MethodClass.printHI();
          MethodClass.printHI();
}The author of this example stated that it's very un-OO, meantime Java doesn't support nested methods.
Is it really bad OO practise? I suppose that having nested methods makes reflection more complex, in place of class methods we would have hierarchy of methods. In fact Java classes should already have hirearcy of nested variables (classes). Why not to make the same thing for methods? I'm not sure wheter it's correct Dephi's RTTI and reflection but methods nesting doesn't harm to RTTI.
I see that creating an instance of class just for calling one of its methods is not very effective and slows down the execution even more than passing local variables as parameters in the case of non-nested functions.

Does this code looks like algorithm?
method1() {
     do(1);
     do(2);
     do(3);
     do(1);
     do(2);
     do(3);
}When do you define new procedure? IMO a procedure is a snippet of reusable code. Thus I would define procedure do123() {
     do(1);
     do(2);
     do(3);
}and would write
method1() {
     do123();
     do123();
}Imagine that this sequence (do 1, do2, do3, do1, do2, do3) is not used only by method1. In this case procedure do123 is (re)used only by method1 scope. I can't find any reason to define this procedure in the object scope, even specifying it as private. do123 should be defined in the scope of method1. Even worse, when you want to use method1 local variables from do123.
proposed.
advantages:
     1) the procedure do123() is defined and
        used only at metod1 scope
     2) no need to pass parameter a into the procedure
        do123
void method1() {
     int a = x;
     void do123() {
          use(a);
     do123();
/*Java implementation 1.
disadvantages:
     1) the procedure do123() is used only from method1 scope
        while it is defined at object scope
     2) we need to pass parameter a into the procedure do123 that
        is verbose too and sows down run time
private void do123(int a) {
     use(a);
void method1() {
     int a = x;
     do123(a);
/*Java implementation 2.
disadvantages:
     1) the procedure do123() is used only from the scope of
        method1 but is defined at the object scope
     2) we need to define variable a at the object scope while it
        is used only in method1
private int a = x;
private void do123() {
     use(a);
void method1() {
     do123();
}They told that private methods are inlined, but it is not possible for recursive calls and it is not true for normal privates, because there is a special bytecode to invoke private methods. Because methods are not inlined all parameters must be copied into new stack frame.
Objects can incapsulate data and methods, methods incapsulate only local variables. If incapsulation is a key OOP notion then why we can't incapsulate methods onto methods?
I'm trying to tell that nested methods is an extremly powerful feature in describing algoritms. Using local methods would lead to less verbose, easier to maintain and faster code.

Similar Messages

  • Need opinions about using methods in-line

    Hello fellow SDNers,
    I have this piece of code where i use functional method as operand, string formatting options in-line et al. A friend of mine says it's not too descriptive.
      cl_demo_output=>display_text( |Laufzeit: { lcl_calc_laufzeit=>main(
                                                     im_date_from = p_begda
                                                     im_date_to   = p_endda )-count ALIGN = LEFT } Monat(e)| ).
    Is Too-little is just too confusing?
    I like in-line data declarations, functional methods because i feel they are more intuitive.
    What are your ideas/opinions about it?
    BR,
    Suhas

    Hi Suhas,
    when i was starting with C-programming, i was impressed by what you could achieve with just so little of actual coding.
    I thougt it was quite cool, when I managed to squeeze whole programs into just a few lines, using heavily nested ternary operators and for-loops.
    Well, they did what they where meant to do, but when after a while i had to alter one only gradually, it took me some time to rethink, what i myself had created not so long ago.
    Imagining how someone else would try to follow my line of thought, i came to the conclusion, that it was not so desireable, to squeeze the last bit of efficiency out of the characters that built the source-code, but that it could be far better, to enfold it, make it bigger, even less elegant, but allthemore easier to understand.
    Why do i tell you this?
    I seem to recognize a bit of the fascination, i felt myself, in your code sample. Letting you beeing carried away by possibility alone, does not necessarily lead to the best results on the long run.
    Back to your question - i'm afraid, your friend was right.
    You can do better, without loosing to much.
    Truth be told, i haven't done too much in the line of string templates and nested method calls yet.
    I have to admit, i'm challenged even to follow, what your sample exactly does. Nevertheless, i will dig in and discover whatever it may provide for me .
    Best regards - Jörg

  • Problem in a class :(

    Could someone help me to find why the intRead method doesn't work ???
    import java.io.*;
    public class EntreeFormatee {
         public static void main(String[] args) {
              // M�thode permettant de lire une valeur int...
              public int intRead() // the error is here...it's written : "Syntax error on token "(", ";" expected"
                   try
                        for(int i = 0; i < 5; i++)
                             if(tokenizer.nextToken()==tokenizer.TT_NUMBER)
                             return (int)tokenizer.nval; // La valeur est num�rique donc renvoyer comme int
                             else
                                  System.out.println("Entree incorrecte: " + tokenizer.sval + " Saisissez un entier une nouvelle fois");
                                  continue; // R�ssayer l'op�ration de lecture
                        System.out.println("Cinq erreurs de lecture pour la valeur int" + " - programme termin�");
                        System.exit(1); // Terminer le programme
                        return 0;
                   catch(IOException e) // Erreur de la lecture du nextToken()
                        System.out.println(e); // Afficher l'erreur
                        System.exit(1);
                        return 0;
              // plus d'autres m�thodes pour lire d'autres types de donn�es...
              // Objet pour d�couper en cha�nes distinctes l'entr�e du flot d'entr�e standard
              private StreamTokenizer tokenizer = new StreamTokenizer(new InputStreamReader(System.in));

    public static void main(String[] args) {
    public int intRead() // the error is here...it's written : "Syntax error on token "(", ";" expected"
    { [/code]
    Java doesn't allow nested methods; define your intRead method somewhere else at
    the clas level (static) or at the object level.
    kind regards,
    Jos                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Using static variables in JSP

    Hi All,
    I have written the following code, but its not compiling saying that "Class or interface declaration expected. static "
    I dotn know whats wrong in this scriplet though.. any help is greatly appretiated.
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>JSP Scriplet</title>
    </head>
    <body>
    <%
    static int counter = 15;
    for(int i = 0; i < 15; i++){
    int p = returnCounter();
    if(p == 0)
    System.out.println("I am the 15th user");
    public static int returnCounter(){
    counter = counter - 1;
    System.out.println("counter : " + counter);
    return counter;
    %>
    </body>
    </html>

    Simply put, you're Java code is wrong.
    The detail is that essentially all of the code in your JSP file is in one big method.
    So, here's what your code looks like to the compiler:
    public void _internalJspDoPageCode() {
        static int counter = 15;
        public static int returnCounter() {
    }You can't simply nest methods like this in Java.
    If you want to, you can try this:
    <%
        public class mycounter {
            static int counter = 15;
            public static int returnCounter() {
                counter = counter - 1;
                return counter;
        for (int i = 0; i < 15; i++) {
            int p = mycounter.returnCounter();
            if(p == 0)
                System.out.println("I am the 15th user");
    %>That will create an inner class with a static member, which is basically what you're trying to do.
    But note that this inner class is only accessible from this JSP page, and no where else.

  • Has anyone got any advice on this problem?

    I'm just getting to grips with Java and I'm having trouble getting some code to work. I want to find out why I'm getting error messages with the following code:
    public class CraftItem {
    private String itemCode;
    private double price;
    public CraftItem(String iCode, double iPrice) {
    itemCode = iCode;
    price = iPrice;
    public void prCraftItem(){
    System.out.println("Item " + itemCode);
    I'm getting:
    "CraftItem.java": Error #: 206 : malformed expression at line 10, column 5 with the first bold text
    "CraftItem.java": Error #: 204 : illegal start of expression at line 12, column 3 with the second bold text
    I'm using a Test.java to test the program:
    public class Test {
    public Test() {
    public static void main(String[] args) {
    CraftItem nails = new CraftItem("123456",1.5);
    nails.prCraftItem();
    It's probably something childishly simple to Java experts but any advice for me as to where I'm going wrong with this would be much appreciated!
    Thanks - Nic

    public CraftItem(String iCode, double iPrice)
         public void prCraftItem(){}
    }Nested method?

  • Transactional error when using JMS from stateless session bean

    I get a transaction exception when committing a bean method responsible for sending to a JMS topic. This happens only occasionally when two separate threads invoke this method "at the same time".
    The scenario:
    Two separate threads running two different instances of a stateless session bean (slsb A). This ejb (slsb A) has an injected slsb B which is communicating with the the topic.
    Both instances of slsb A are utilising the same instance of slsb B.
    The CMT transactions for the two threads start in slsb A from methods with transaction attribute "RequiresNew". All nested methods are to other slsbs and have the transaction attribute "Required". The method in slsb B which sends the message is closing both the session and the connection to the topic.
    I'm running Glassfish version 9.1_02 (build b04-fcs) and JMS implementation OpenMQ version 4.1.
    Stacktrace (glassfish log):
    [#|2008-09-09T13:00:40.515+0200|SEVERE|sun-appserver9.1|javax.resourceadapter.mqjmsra.outbound.connection|_ThreadID=18;_ThreadName=httpSSLWorkerThread-8080-1;_RequestID=108e8418-71a6-4d8b-a94d-9e1edc885891;|commitTransaction (XA) on JMSService:jmsdirect failed for connectionId:5754505514139844608 and onePhase:false due to unkown JMSService server error.|#]
    [#|2008-09-09T13:00:40.515+0200|SEVERE|sun-appserver9.1|javax.enterprise.system.core.transaction|_ThreadID=18;_ThreadName=httpSSLWorkerThread-8080-1;org.omg.CORBA.INTERNAL:   vmcid: 0x0  minor code: 0 completed: Maybe;commit;_RequestID=108e8418-71a6-4d8b-a94d-9e1edc885891;|JTS5031: Exception [org.omg.CORBA.INTERNAL:   vmcid: 0x0  minor code: 0 completed: Maybe] on Resource [commit] operation.|#]
    [#|2008-09-09T13:00:40.531+0200|INFO|sun-appserver9.1|javax.enterprise.system.container.ejb|_ThreadID=18;_ThreadName=httpSSLWorkerThread-8080-1;SubscriptionBean;|EJB5018: An exception was thrown during an ejb invocation on [SubscriptionBean]|#]
    [#|2008-09-09T13:00:40.531+0200|INFO|sun-appserver9.1|javax.enterprise.system.container.ejb|_ThreadID=18;_ThreadName=httpSSLWorkerThread-8080-1;|
    javax.ejb.EJBException: Unable to complete container-managed transaction.; nested exception is: javax.transaction.SystemException: org.omg.CORBA.INTERNAL: JTS5031: Exception [org.omg.CORBA.INTERNAL:   vmcid: 0x0  minor code: 0 completed: Maybe] on Resource [commit] operation. vmcid: 0x0 minor code: 0 completed: No
    javax.transaction.SystemException: org.omg.CORBA.INTERNAL: JTS5031: Exception [org.omg.CORBA.INTERNAL:   vmcid: 0x0  minor code: 0 completed: Maybe] on Resource [commit] operation. vmcid: 0x0 minor code: 0 completed: No
         at com.sun.jts.jta.TransactionManagerImpl.commit(TransactionManagerImpl.java:321)
         at com.sun.enterprise.distributedtx.J2EETransactionManagerImpl.commit(J2EETransactionManagerImpl.java:1030)
         at com.sun.enterprise.distributedtx.J2EETransactionManagerOpt.commit(J2EETransactionManagerOpt.java:397)
         at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:3792)
         at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:3585)
         at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1354)
         at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1316)
         at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:205)
         at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:127)
         at $Proxy130.requestNewSubscription(Unknown Source)
         at com.abeldrm.kms.core.services.subscription.SubscriptionWSBean.requestNewSubscription(SubscriptionWSBean.java:94)
         at sun.reflect.GeneratedMethodAccessor127.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1067)
         at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:176)
         at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2895)
         at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3986)
         at com.sun.ejb.containers.WebServiceInvocationHandler.invoke(WebServiceInvocationHandler.java:189)
         at $Proxy129.requestNewSubscription(Unknown Source)
         at sun.reflect.GeneratedMethodAccessor126.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.sun.enterprise.webservice.InvokerImpl.invoke(InvokerImpl.java:81)
         at com.sun.enterprise.webservice.EjbInvokerImpl.invoke(EjbInvokerImpl.java:82)
         at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:146)
         at com.sun.xml.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethodHandler.java:257)
         at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:93)
         at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:595)
         at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:554)
         at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539)
         at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436)
         at com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl.process(AbstractTubeImpl.java:106)
         at com.sun.enterprise.webservice.MonitoringPipe.process(MonitoringPipe.java:147)
         at com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:115)
         at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:595)
         at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:554)
         at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539)
         at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436)
         at com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl.process(AbstractTubeImpl.java:106)
         at com.sun.xml.ws.tx.service.TxServerPipe.process(TxServerPipe.java:329)
         at com.sun.enterprise.webservice.CommonServerSecurityPipe.processRequest(CommonServerSecurityPipe.java:218)
         at com.sun.enterprise.webservice.CommonServerSecurityPipe.process(CommonServerSecurityPipe.java:129)
         at com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:115)
         at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:595)
         at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:554)
         at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539)
         at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436)
         at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:243)
         at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:444)
         at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:244)
         at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:135)
         at com.sun.enterprise.webservice.Ejb3MessageDispatcher.handlePost(Ejb3MessageDispatcher.java:113)
         at com.sun.enterprise.webservice.Ejb3MessageDispatcher.invoke(Ejb3MessageDispatcher.java:87)
         at com.sun.enterprise.webservice.EjbWebServiceServlet.dispatchToEjbEndpoint(EjbWebServiceServlet.java:226)
         at com.sun.enterprise.webservice.EjbWebServiceServlet.service(EjbWebServiceServlet.java:155)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
         at com.sun.enterprise.web.AdHocContextValve.invoke(AdHocContextValve.java:114)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
         at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:87)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
         at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
         at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
         at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
         at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
         at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
         at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
         at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
         at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
         at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
    IMQ broker log:
    [09/Sep/2008:13:00:40 CEST] ERROR CommitTransaction: commit failed. Connection ID: 5754505514139844608, Transaction ID: 0:
    com.sun.messaging.jmq.jmsserver.util.BrokerException: Unknown Transaction 0
         at com.sun.messaging.jmq.jmsserver.data.protocol.ProtocolImpl.commitTransaction(ProtocolImpl.java:630)
         at com.sun.messaging.jmq.jmsserver.service.imq.IMQDirectService.commitTransaction(IMQDirectService.java:1735)
         at com.sun.messaging.jms.ra.DirectXAResource.commit(DirectXAResource.java:201)
         at com.sun.jts.jtsxa.OTSResourceImpl.commit(OTSResourceImpl.java:114)
         at com.sun.jts.CosTransactions.RegisteredResources.distributeCommit(RegisteredResources.java:795)
         at com.sun.jts.CosTransactions.TopCoordinator.commit(TopCoordinator.java:2111)
         at com.sun.jts.CosTransactions.CoordinatorTerm.commit(CoordinatorTerm.java:403)
         at com.sun.jts.CosTransactions.TerminatorImpl.commit(TerminatorImpl.java:249)
         at com.sun.jts.CosTransactions.CurrentImpl.commit(CurrentImpl.java:623)
         at com.sun.jts.jta.TransactionManagerImpl.commit(TransactionManagerImpl.java:309)
         at com.sun.enterprise.distributedtx.J2EETransactionManagerImpl.commit(J2EETransactionManagerImpl.java:1030)
         at com.sun.enterprise.distributedtx.J2EETransactionManagerOpt.commit(J2EETransactionManagerOpt.java:397)
         at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:3792)
         at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:3585)
         at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1354)
         at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1316)
         at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:205)
         at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:127)
         at $Proxy130.requestNewSubscription(Unknown Source)
         at com.abeldrm.kms.core.services.subscription.SubscriptionWSBean.requestNewSubscription(SubscriptionWSBean.java:94)
         at sun.reflect.GeneratedMethodAccessor127.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1067)
         at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:176)
         at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2895)
         at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3986)
         at com.sun.ejb.containers.WebServiceInvocationHandler.invoke(WebServiceInvocationHandler.java:189)
         at $Proxy129.requestNewSubscription(Unknown Source)
         at sun.reflect.GeneratedMethodAccessor126.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.sun.enterprise.webservice.InvokerImpl.invoke(InvokerImpl.java:81)
         at com.sun.enterprise.webservice.EjbInvokerImpl.invoke(EjbInvokerImpl.java:82)
         at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:146)
         at com.sun.xml.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethodHandler.java:257)
         at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:93)
         at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:595)
         at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:554)
         at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539)
         at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436)
         at com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl.process(AbstractTubeImpl.java:106)
         at com.sun.enterprise.webservice.MonitoringPipe.process(MonitoringPipe.java:147)
         at com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:115)
         at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:595)
         at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:554)
         at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539)
         at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436)
         at com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl.process(AbstractTubeImpl.java:106)
         at com.sun.xml.ws.tx.service.TxServerPipe.process(TxServerPipe.java:329)
         at com.sun.enterprise.webservice.CommonServerSecurityPipe.processRequest(CommonServerSecurityPipe.java:218)
         at com.sun.enterprise.webservice.CommonServerSecurityPipe.process(CommonServerSecurityPipe.java:129)
         at com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:115)
         at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:595)
         at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:554)
         at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539)
         at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436)
         at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:243)
         at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:444)
         at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:244)
         at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:135)
         at com.sun.enterprise.webservice.Ejb3MessageDispatcher.handlePost(Ejb3MessageDispatcher.java:113)
         at com.sun.enterprise.webservice.Ejb3MessageDispatcher.invoke(Ejb3MessageDispatcher.java:87)
         at com.sun.enterprise.webservice.EjbWebServiceServlet.dispatchToEjbEndpoint(EjbWebServiceServlet.java:226)
         at com.sun.enterprise.webservice.EjbWebServiceServlet.service(EjbWebServiceServlet.java:155)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
         at com.sun.enterprise.web.AdHocContextValve.invoke(AdHocContextValve.java:114)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
         at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:87)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
         at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
         at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
         at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
         at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
         at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
         at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
         at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
         at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
         at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
    Have anyone any idea why this should fail?
    Regards,
    Jon

    I would suggest opening a case with [email protected] FWIW, I recall seeing
              something like this in WLS 6.0. I believe it is fixed in WLS 6.1
              -- Rob
              Chris Dupuy wrote:
              > Btw, this occurs when I create an stateful session bean that ends up
              > throwing an exception and setRollbackOnly() is called. From that point
              > forward, my logs fill with this message.
              >
              > Chris
              >
              > "Chris Dupuy" <[email protected]> wrote in message
              > news:[email protected]..
              > > anyone know what this means, and what you can do about it?
              > >
              > >
              > > <Error> <ConnectionManager> <atossd03> <cbeyondServer> <ExecuteThread:
              > '14'
              > > for queue: 'd
              > > efault'> <> <> <000000> <Closing:
              > 'weblogic.rjvm.t3.T3JVMConnection@488831'
              > > because of: 'Server received a message over an uniniti
              > > alized connection: 'JVMMessage from: 'null' to:
              > >
              > '5825313123619479267S:10.6.6.40:[8000,8000,8001,8001,8000,8001,-1]:cbeyond:c
              > > beyond
              > > Server' cmd: 'CMD_REQUEST', QOS: '101', responseId: '2', invokableId: '1',
              > > flags: 'JVMIDs Not Sent, TX Context Not Sent', abbrev o
              > > ffset: '204'''>
              > >
              > >
              > >
              

  • XLSX Upload - a unified approach - error in LOAD_XML_DATA "=" expected after "2"

    Hello Experts
    I implemented the How-to XLSX Upload - a unified approach ( written by Benu Mariantony) in our Web dynpro application to load data into our SAP BW Application.
    According document and page 20:
    I created the method load_xml_data in the webdynpro view.
    I assume and it works. I created attribute  mo_parts and mo_package attributes on the view ( only one view -> main)
    Now I get an error, where I am lost. Please read that:
    Error: In line 10: "=" expected after "2".
    Please can you help me.
    Best regards
    Christian

    Hi Christian,
    I think, your system does not support nested method call in a single statement. So, go for individual method call.
    Please try the below code:
    DATA lv_uri TYPE string.
    DATA lo_part TYPE REF TO cl_openxml_part.
    DATA lo_parts LIKE wd_this->mo_parts.
    DATA lo_part2 LIKE lo_part.
    DATA lo_uri TYPE REF TO cl_openxml_parturi.
    lo_part = wd_this->mo_parts->get_part( 2 ).
    lo_parts = lo_part->get_parts( ).
    lo_part2 = lo_parts->get_part( iv_xml_index ).
    lo_uri = lo_part2->get_uri( ).
    lv_uri = lo_uri->get_uri( ).
    Hope this helps you.
    Regards,
    Rama

  • Action listener just wont work..

    wats the prob wid this code???help plz!!1
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.sql.*;
    public class searchmember extends JApplet implements ActionListener /*searchmember should be declared abstract;
    it does not define actionPerformed(java.awt.event.ActionEvent) in searchmember*/
    JPanel p1;
    Statement s;
    JTextField t;
    CheckboxGroup radioGroup;
    Checkbox b1,b2;
    JLabel l;
    JButton b;
    public void init()
    p1=new JPanel();
    radioGroup = new CheckboxGroup();
    setSize(500,500);
    l=new JLabel("search book:");
    l.setBounds(50,50,80,20);
    t=new JTextField();
    t.setBounds(130,50,170,20);
    b1=new Checkbox("by name",radioGroup,false);
    b1.setBounds(150,70,100,20);
    b2=new Checkbox("by author",radioGroup,false);
    b2.setBounds(250,70,100,20);
    b=new JButton("search");
    getContentPane().add(p1,BorderLayout.CENTER);
    p1.setLayout(null);
    p1.add(l);
    p1.add(t);
    p1.add(b1);
    p1.add(b2);
    b.addActionListener(this);
    public void actionPerformed (ActionEvent ae) {  //gives illegal start of expression
              Object obj = ae.getSource();
              if (obj == b) {          //If Find Button Pressed.
                   Toolkit.getDefaultToolkit().beep();
              }     //says ; expected
    }

    First, please stop using SMS speak.
    Second, please enclose your code in [code][/code] tags. They make the program much easier to read.
    Finally, your problem is that you have tried to put the actionPerformed method inside the init method. You can't nest methods inside one another.

  • Stackoverflow

    HI,
    I have an applet that displays images thrown a diaporama. Sometimes images are reloaded because its content has changed. All works fine, excepts I got an error 12 or 14 hours after like : Stackoverflow error, then diaporama stop.
    I don't know what happen, for me all is ok, but I think perhaps I have to look about Threads that run the diaporama, but how ? Any Idea ?

    Stack overflow generally has one cause: you are either intentionally or unintentionally implementing recursion which is causing an infinite regression, which exhausts the stack, which is what is used to keep track of nested method calls.
    What does that mean? It means you have something like this:public void blowTheStack(int n)
        int m = n;
        if (m > 0)
            blowTheStack(m);
    }when the VM enters method blowTheStack(), it checks the passed variable n and effectively passes that value to itself. On entry, it checks the passed variable n and effectively passes that value to itself. On entry, it checks the passed variable n and effectively passes that value to itself... even though there is a check for 0 (which would bottom out the recursion), it never changes that value, with the result that if the initial value is anything but 0, it keeps calling iteself and calling itself in deeper and deeper nested levels until the call stack overflows. It's kinda like an infinite loop, except for the fact that instead of looping, it is regressing within itself. That's why it's called an "Infinite Regression". Kinda like the Morton salt container that has a picture of a girl holding a Morton salt container, that has a picture of a girl holding a Mortin salt container...
    Infinite regression can also be more devious.public void blowTheStackWithHelp(int n)
        int m = n;
        if (m > 0)
            helpBlowTheStack(m);
    public void helpBlowTheStack(int n)
        int m = n;
        if (m > 0)
            blowTheStackWithHelp(m);
    }here, neither method is calling itself, but each method calls the other. Once again, because nothing changes from method entry to the method call, it just repeats (or more exactly, propagates) the method calls until the stack is exhausted.
    Recursion can be a very useful strategy. It frequently makes very complicated problems simple. But you have to be careful to ensure that the recursion "bottoms out" eventually so it can climb back up the stack by successively returning from all thise nested method calls.

  • Getting stuck on isClosed()

    I can't figure out for the life of me why this would be occurring. I call the open statement, and it runs the query without any issues what so ever. It gets to the this.resultSet.last() and tries to operate, but it gets stuck. I stepped inside of the this.resultSet.last() method, and found out that it's getting stuck specifically on the this.jdbc.getConnection().isClosed(). It runs just fine when this.jdbc.getConnection().isClosed() gets called in teh open, but comes to a dead stop right when it hits the same line in last(). After a certain amount of time passes, it eventually throws an Outofmemory exception. Any one happen to have an idea of what would or could be causing this? Any and all information would be useful. Thanks.
    public synchronized boolean open() {         try         {             if (this.jdbc instanceof MRxJDBC)             {                 if (this.jdbc.getConnection() instanceof java.sql.Connection)                 {                     if (!this.jdbc.getConnection().isClosed())                     {                         this.sql = "SELECT * FROM fills";                         this.preparedStatement = this.jdbc.getConnection().prepareStatement(this.sql,                                 ResultSet.TYPE_SCROLL_INSENSITIVE,                                 ResultSet.CONCUR_READ_ONLY);                         this.resultSet = this.preparedStatement.executeQuery();                         this.resultSet.last();                         this.count = this.resultSet.getRow();                         this.resultSet.beforeFirst();                         return true;                     }                     this.debug("open()", "", "The connection is not open", "");                     return false;                 }                 this.debug("open())", "", "No sql connection", "");                 return false;             }             this.debug("open()", "", "The MRXJDBC as not been instantiated.", "");         } catch (Exception ex)         {             ex.printStackTrace();             this.debug("open()", "", ex.getMessage(), "");             return false;         }         return true;     } public synchronized boolean last() {         try {             if (this.jdbc instanceof MRxJDBC) {                 if (this.jdbc.getConnection() instanceof java.sql.Connection) {                     if (!this.jdbc.getConnection().isClosed()) { //stuck right here. Pulls connection back NP, calls isClosed(), gets stuck                         if (this.resultSet instanceof ResultSet) {                             if (this.resultSet.last()) {                                 this.assign();                                 this.debug("last()", "Record "+this.resultSet.getRow()+" of "+this.count+" returned.", "", "");                                                return true;                             }                             this.debug("last()", "", "No records returned.", "");                                            return false;                         }                         this.debug("last()", "", "No results returned.", "");                                        return false;                     }                     this.debug("last()", "", "The connection is not open", "");                                    return false;                 }                 this.debug("last()", "", "No sql connection", "");                                return false;             }             this.debug("last()", "", "The MRXJDBC as not been instantiated.", "");                            return false;         } catch (Exception ex) {             this.debug("last()", "", ex.toString(), "");                            return false;         }     }
    Edited by: SabinsAura on Oct 8, 2009 7:28 AM

    At least tidy up that horrible nested method. Try this:
    public synchronized boolean last() {
       try {
          if (!(jdbc instanceof MRxJDBC)) {
             debug("last()", "", "The MRXJDBC as not been instantiated.", "");               
             return false;
          if (!(jdbc.getConnection() instanceof java.sql.Connection)) {
             debug("last()", "", "No sql connection", "");               
             return false;
          if (jdbc.getConnection().isClosed()) {
             debug("last()", "", "The connection is not open", "");               
             return false;
          if (!(resultSet instanceof ResultSet)) {
             debug("last()", "", "No results returned.", "");               
             return false;
          if (!resultSet.last()) {
             debug("last()", "", "No records returned.", "");               
             return false;
          assign();
          debug("last()", "Record "+resultSet.getRow()+" of "+count+" returned.", "", "");               
          return true;
       } catch (Exception ex) {
          debug("last()", "", ex.toString(), "");               
          return false;
    }What is "MRXJDBC" and are you sure it doesn't do pooling? Are you absolutely certain that the jdbc connection you pass in is the same as the jdbc field that you access in the above code?

  • Read from file to string

    I know how to read from the file and put the data into an array list, but how do i put it into a string?
    here is the code i've written for the arraylist.
    class AddressBook extends JFrame
        DefaultTableModel contactsTable;
        ArrayList addresses = new ArrayList();
    public ArrayList readAddresses()
            try
                Scanner addressBookFile = new Scanner(new File("AddressBook.buab"));
                while (addressBookFile.hasNext())
                    addresses.add(addressBookFile.nextLine());
            catch(FileNotFoundException ex)
                ex.printStackTrace();
            return addresses;
        }Is it possible to change the arraylist to a string or should i read it in as a string in the first place?

    So, you wrote this line yourself?
                    addresses.add(addressBookFile.nextLine());Then you must know what it does, right?
    What is addresses?
    What does the add() method do?
    What is the argument to the add method here?
    What does it mean when you have a "nested" method call like add(addressBookFile.nextLine())?

  • Loss of sync converting from NTSC to PAL

    Hello,
    I'm trying to convert NTSC DV footage to PAL using Graeme's Nattress filter, but the footage goes out of sync.
    Anyone knows how to fix the problem?
    Thank you,
    nicola

    Most likely problem is that the timeline you're doing the conversion on is not PAL. You should open the sequence settings for the timeline, and check that it's 720x576 and 25fps. If you're following the nesting method from the instructions, make sure "nesting" is on. Also, if you've not already done so, watch the videos here:
    http://www.nattress.com/standardsConversionMovie.htm
    And get back to me via email if you have any problems,
    Thanks,
    Graeme

  • Code to Limit Characters in Input

    Hey guys,
    Im trying to write an if statement limiting the amount of characters someone is able to put in to 10 but i dont know the code for it.
    Its going to look like:
    if (userPhone == ???)
    Its a phone number so all I need is to limit the characters and I can get it from there, thanks!

    Bascotie wrote:
    Doesnt seem to be working.
    First I tried if(userPhone.length > 10) and I got an error about userPhone.lengthThat's because it's .length(). It's a method. You have to use parentheses.
    If you read the API documentation, you could have figured this out in less time than it took you to post another question to the forum (and then create a whole new thread pointlessly).
    >
    Then I tried delcaring
    public static void checkChars() under the main statement and that didnt work so I tried typing it right after the userPhone statement I have and that didnt work either?You can't write code by just throwing words around randomly.
    In particular, you don't nest methods in Java. Write a method that starts, does some stuff and then ends with a closing brace. Then you can create another method.

  • Re:Bapis

    What is instance method? can any one explain how oops are useful for lerning the bapis.Can any one send me the basic concept of oops.
    Thanks&regards
    Bhushan-karra

    Hi,
    Instance methos : a method with out ststic modifier.
    For Both class methos and Instance method , memeory allocted only once, that is loading the class.
    But difference is, we can access the static method, directly with class name , with out using object of that class.
    Where as Instance method can be access through only Objects or other non ststic method of same class (This concept is called nested method).
    Of course, we have some restrictions with static methods:
    1. static method can use only static variables.
    2. static method can not access through the non ststic method and  vice versa.

  • Wcap/csapi - search on event/todo

    Hi,
    I'm using wcap now and I want to search on certain things like dtstart and dtend (more specifically, I want to search on calid + dtstart + dtend), is there any way to do it?
    or if wcap can't , how about csapi or any other suggestions?
    Thanks,

    You're trying to define the actionPerformed method inside the body of your MyMenuSystem constructor. Java doesn't know about nested method definitions. Tip: always indent your code that's within curly braces; you'd see your error immediately then.
    kind regards,
    Jos

Maybe you are looking for