Using a string or char as a class when calling a method

Is there a way to take the string.charAt(int) method and use it as a stand in for a class that is one character long? (Examples below, as I'm sure that question makes no sense out of context.)
Something like (note the last line):
import java.util.Scanner;
public class DRV
     public static void main(String[] args)
          Scanner inpt = new Scanner(System.in);
          String stringy;
          A a = new A();
          System.out.println("Enter 'a': ");
          stringy = inpt.next();
          [stringy.charAt(0)].lineOne();
}Or will I just have to use a lot of if statements:
import java.util.Scanner;
public class DRV
     public static void main(String[] args)
          Scanner inpt = new Scanner(System.in);
          String stringy;
          A a = new A();
          System.out.println("Enter 'a': ");
          stringy = inpt.next();
          if (stringy.charAt(0) == 'a')
               a.lineOne();
               System.out.println();
}I doubt this is possible, but it would be totally awesome if there was something like [stringy.charAt(0)].classmethod();. This would allow me to just use a couple for loops instead of a cluster of if's.
Thanks for any help.
Edited by: 797223 on Sep 28, 2010 11:21 PM

What Kayaman said.
Another suggestion, slightly more elaborate, is to use class.forName() and reflection to create an instance of the correct class:
stringy = inpt.next();
Class clazz = Class.forName(makeClassCase(stringy));
Object o = clazz.newInstance();
SomeInterface i = (SomeInterface)o;
i.lineOne();This assumes that you write a method private String makeClassCase(String s) that returns the correctly cased class name (e.g. transforms 'a' to 'A') and adds the appropriate package name if applicable, and that you define method lineOne() in an interface SomeInterface and in all classes that implement it (assuming I have correctly understood that all your classes do expose the same lineOne() method).
You'll have to make special provisions for error cases (e.g. the user types a class name that doesn't exist, or that doesn't implement the common interface).

Similar Messages

  • Errors in a Java class when calling other methods

    I am giving the code i have given the full class name . and now it is giving the following error :
    Cannot reference a non-static method connectDB() in a static context.
    I am also giving the code. Please do help me on this. i am a beginner in java.
    import java.sql.*;
    import java.util.*;
    import DButil.*;
    public class StudentManager {
    /** Creates a new instance of StudentManager */
    public StudentManager() {
    Connection conn = null;
    Statement cs = null;
    public Vector getStudent(){
    try{
    dbutil.connectDB();
    String Query = "Select St_Record, St_L_Name, St_F_Name, St_Major, St_Email_Address, St_SSN, Date, St_Company, St_Designation";
    cs = conn.createStatement();
    java.sql.ResultSet rs = cs.executeQuery(Query);
    Vector Studentvector = new Vector();
    while(rs.next()){
    Studentinfo Student = new Studentinfo();
    Student.setSt_Record(rs.getInt("St_Record"));
    Student.setSt_L_Name(rs.getString("St_L_Name"));
    Student.setSt_F_Name(rs.getString("St_F_Name"));
    Student.setSt_Major(rs.getString("St_Major"));
    Student.setSt_Email_Address(rs.getString("St_Email_Address"));
    Student.setSt_Company(rs.getString("St_Company"));
    Student.setSt_Designation(rs.getString("St_Designation"));
    Student.setDate(rs.getInt("Date"));
    Studentvector.add(Student);
    if( cs != null)
    cs.close();
    if( conn != null && !conn.isClosed())
    conn.close();
    return Studentvector;
    }catch(Exception ignore){
    return null;
    }finally {
    dbutil.closeDB();
    import java.sql.*;
    import java.util.*;
    public class dbutil {
    /** Creates a new instance of dbutil */
    public dbutil() {
    Connection conn;
    public void connectDB(){
    conn = ConnectionManager.getConnection();
    public void closeDB(){
    try{
    if(conn != null && !conn.isClosed())
    conn.close();
    }catch(Exception excep){
    The main error is occuring at the following lines connectDB() and closeDB() in the class student manager. The class dbutil is in an another package.with an another file called connectionManager which establishes the connection with DB. The dbutil has the openconnection and close connection methods. I have not yet written the insert statements in StudentManager. PLease do Help me

    You're doing quite a few things that will cause errors, I'm afraid. I'll see if I can help you.
    The error you're asking about is caused by the following line:
    dbutil.connectDB();
    Now first of all please always ensure that your class names begin with capital letters and your instances of classes with lowercase letters. That's what everybody does, so it makes your code much easier to follow.
    So re-write the couple of lines at the beginning of your dbutil class like this:
    public class Dbutil {
    /** Creates a new instance of Dbutil */
    public Dbutil() {
    Now you need to create an instance of dbutil before you can call connectDB() like this:
    Dbutil dbutil = new Dbutil();
    now you can call the method connectDB():
    dbutil.connectDB();
    The problem was that if you don't create an instance first then java assumes that you are calling a static method, because you don't need an instance of a class to call a static method. If it was static, the method code would have been:
    public static void connectDB(){
    You have a fine example of a static method call in your code:
    ConnectionManager.getConnection();
    If it wasn't a static method your code would have to look like this:
    ConnectionManager connectionManager = new ConnectionManager();
    connectionManager.getConnection();
    See the difference? I also know that ConnectionManager.getConnection() is a call to a static method because it begins with a capital letter.
    Anyway - now on to other things:
    You have got two different Connection objects called conn. One is in StudentManager and the other is in Dbutils, and for the moment they have nothing to do with each other.
    You call dbUtil.connectDb() and so if your connectDb method is working properly you have a live connection called conn in your dbUtil object. But the connection called conn in StudentManager is still null.
    If your connection in the dbUtil object is working then you could just add a line after the call to connectDb() in StudentManager so that the StudentManager.conn object references the dbUtil.conn object like this:
    dbutil.connectDB();
    conn = dbUtil.conn;

  • Can't add list element when calling a method from another class

    I am trying to call a method in another class, which contains code listmodel.addElement("text"); to add an element into a list component made in that class.
    I've put in System.out.println("passed"); in the method just to make sure if the method was being called properly and it displays normally.
    I can change variables in the other class by calling the method with no problem. The only thing I can't do is get listmodel.addElement("text"); to add a new element in the list component by doing it this way.
    I've called that method within it's class and it added the element with no problem. Does Java have limitations about what kind of code it can run from other classes? And if that's the case I'd really like to know just why.

    There were no errors, just the element doesnt get added to the list by doing it this way
    class showpanel extends JPanel implements ActionListener, MouseMotionListener {
           framepanel fp = new framepanel();
           --omitted--
         public void actionPerformed(ActionEvent e){
                  if(e.getSource() == button1){
                       fp.addLayer();
    /*is in a different class file*/
    class framepanel extends JPanel implements ActionListener{
            --omitted--
         public void addLayer(){
              listmodel.addElement("Layer"+numLayer);
              numLayer++;
    }

  • How to specify realm name when calling weak( ) method on ServletAuthentication class?

    I've created a bunch of custom realms and for a specific user logon (form based "uname" and "pword"), the system knows exactly which custom realm to look up against. However, in using ServletAuthentication class, one can only specify realm name in strong(req, res, realmName), not the weak() method. Any clue?
    -john

    Hi John,
    Did you find the answer to this question? I'm having a similar problem when calling the ServletAuthentication.assertIdentity() method.
    Cheers,
    Vidar

  • To print which class is calling a method??

    Hello people
    Is there any way it could be known which class is calling a particular method from the method itself?
    Thanks

    Try this:
    * @author Malcolm McMahon
    * @version $Revision: $
    public class TestTrace {
        static {
            printCall();
        private static void c() {
            printCall();
        private static void printCall() {
            String name = Thread.currentThread().getStackTrace()[3].getMethodName();
            System.out.println("Call: " + name);
        public static void main(String[] args) {
            printCall();
            c();
    }Only think is, I'm not confident that the index 3 will remain unchanged in different releases (there are two levels within getStackTrace() and there's no guarantee that will remain true).

  • Getting Bad Type Error when calling a method in the proxy class

    Hi,
    I have generated the proxy classes from wsdl.
    When I am calling the methods in the proxy class from one of external class, I am getting following error.
    Can anyone please help me in resolving this issue.
    javax.xml.ws.soap.SOAPFaultException: org.xml.sax.SAXException: Bad types (interface javax.xml.soap.SOAPElement -> class com.intraware.snetmgr.webservice.data.SubscribeNetObjectReference) Message being parsed:
         at com.sun.xml.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:197)
         at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:122)
         at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:125)
         at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:95)
         at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:136)
         at $Proxy176.find(Unknown Source)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at weblogic.wsee.jaxws.spi.ClientInstanceInvocationHandler.invoke(ClientInstanceInvocationHandler.java:84)
         at $Proxy173.find(Unknown Source)
         at com.xxx.fs.FNServices.findAccountWs(FNServices.java:132)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstanceResolver.java:92)
         at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstanceResolver.java:74)
         at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:151)
         at com.sun.xml.ws.server.sei.EndpointMethodHandlerImpl.invoke(EndpointMethodHandlerImpl.java:268)
         at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:100)
         at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:866)
         at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:815)
         at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:778)
         at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:680)
         at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:403)
         at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:532)
         at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:253)
         at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:140)
         at weblogic.wsee.jaxws.WLSServletAdapter.handle(WLSServletAdapter.java:171)
         at weblogic.wsee.jaxws.HttpServletAdapter$AuthorizedInvoke.run(HttpServletAdapter.java:708)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
         at weblogic.wsee.util.ServerSecurityHelper.authenticatedInvoke(ServerSecurityHelper.java:103)
         at weblogic.wsee.jaxws.HttpServletAdapter$3.run(HttpServletAdapter.java:311)
         at weblogic.wsee.jaxws.HttpServletAdapter.post(HttpServletAdapter.java:336)
         at weblogic.wsee.jaxws.JAXWSServlet.doRequest(JAXWSServlet.java:95)
         at weblogic.servlet.http.AbstractAsyncServlet.service(AbstractAsyncServlet.java:99)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
         at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
         at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
         at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:136)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
    Thanks
    Anoop

    Hi Vlad,
    The service has not been changed since i have generated the proxy.
    I tried calling the service from soapUI and I am getting the following error now.
    Request:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:uri="uri:webservice.subscribenet.intraware.com" xmlns:uri1="uri:subscribenet.intraware.com">
    <soapenv:Header>
    <uri:SessionHeader>
    <uri:SessionID>hjkashd9sd90809dskjkds090dsj</uri:SessionID>
    </uri:SessionHeader>
    </soapenv:Header>
    <soapenv:Body>
    <uri:Find>
    <uri:SubscribeNetObjectReference>
    <uri1:ID></uri1:ID>
    <uri1:IntrawareID></uri1:IntrawareID>
    <uri1:SharePartnerID></uri1:SharePartnerID>
    </uri:SubscribeNetObjectReference>
    </uri:Find>
    </soapenv:Body>
    </soapenv:Envelope>
    Response:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Header/>
    <soapenv:Body>
    <soapenv:Fault>
    <faultcode>soapenv:Server.generalException</faultcode>
    <faultstring>org.xml.sax.SAXException: WSWS3279E: Error: Unable to create JavaBean of type com.intraware.snetmgr.webservice.data.SubscribeNetObjectReference. Missing default constructor? Error was: java.lang.InstantiationException: com.intraware.snetmgr.webservice.data.SubscribeNetObjectReference. Message being parsed:</faultstring>
    </soapenv:Fault>
    </soapenv:Body>
    </soapenv:Envelope>
    Thanks
    Anoop

  • Browser Dependency when calling a method in backing bean using a javasript.

    Hi all,
    I have a problem which may look simple but bugging me for quite some time.
    The problem is : When I call a method in the backing bean using a Javascript, (the method can alternatively be invoked by clicking on a command link) I am facing an exception (stack printed below).
    The strange part is that...I am getting this exception only when I use Internet Explorer. It works absolutely fine when I use Mozilla or Netscape browsers. Also, even in ie, it is working fine when I click on the link directly. The probem comes only when I invoke the action using a javascript.
    WARN [lifecycle] executePhase(RENDER_RESPONSE 6,com.sun.faces.cont
    ext.FacesContextImpl@16ce9df) threw exception
    javax.faces.FacesException
         at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java
    :135)
         at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
         at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
    FilterChain.java:290)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
    ain.java:206)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
    FilterChain.java:235)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
    ain.java:206)
         at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.ja
    va:96)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
    FilterChain.java:235)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
    ain.java:206)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
    va:230)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
    va:175)
         at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssoci
    ationValve.java:179)
         at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:
    84)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104
         at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnecti
    onValve.java:156)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
    :109)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http
    11Protocol.java:580)
         at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
         at java.lang.Thread.run(Unknown Source)
    Caused by: ClientAbortException: java.net.SocketException: Connection reset by
    peer: socket write error
         at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:
    358)
         at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:434)
         at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:309)
         at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:288)
         at org.apache.catalina.connector.Response.flushBuffer(Response.java:542)
         at org.apache.catalina.connector.ResponseFacade.flushBuffer(ResponseFacade.java
    :279)
         at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:20
    2)
         at org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java
    :101)
         at org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:
    222)
         at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java
    :106)
         ... 24 more
    Caused by: java.net.SocketException: Connection reset by peer: socket write erro
    r
         at java.net.SocketOutputStream.socketWrite0(Native Method)
         at java.net.SocketOutputStream.socketWrite(Unknown Source)
         at java.net.SocketOutputStream.write(Unknown Source)
         at org.apache.coyote.http11.InternalOutputBuffer$OutputStreamOutputBuffer.doWri
    te(InternalOutputBuffer.java:764)
         at org.apache.coyote.http11.filters.ChunkedOutputFilter.doWrite(ChunkedOutputFi
    lter.java:124)
         at org.apache.coyote.http11.InternalOutputBuffer.doWrite(InternalOutputBuffer.j
    ava:570)
         at org.apache.coyote.Response.doWrite(Response.java:560)
         at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:
    353)
         ... 33 more
    13:54:42,805 ERROR [STDERR] ClientAbortException: java.net.SocketException: Con
    nection reset by peer: socket write error
    13:54:42,805 ERROR [STDERR]      at org.apache.catalina.connector.OutputBuffer.realW
    riteBytes(OutputBuffer.java:358)
    13:54:42,805 ERROR [STDERR]      at org.apache.tomcat.util.buf.ByteChunk.flushBuffer
    (ByteChunk.java:434)
    13:54:42,805 ERROR [STDERR]      at org.apache.catalina.connector.OutputBuffer.doFlu
    sh(OutputBuffer.java:309)
    13:54:42,805 ERROR [STDERR]      at org.apache.catalina.connector.OutputBuffer.flush
    (OutputBuffer.java:288)
    13:54:42,820 ERROR [STDERR]      at org.apache.catalina.connector.Response.flushBuff
    er(Response.java:542)
    13:54:42,820 ERROR [STDERR]      at org.apache.catalina.connector.ResponseFacade.flu
    shBuffer(ResponseFacade.java:279)
    13:54:42,820 ERROR [STDERR]      at com.sun.faces.application.ViewHandlerImpl.render
    View(ViewHandlerImpl.java:202)
    13:54:42,820 ERROR [STDERR]      at org.ajax4jsf.framework.ViewHandlerWrapper.render
    View(ViewHandlerWrapper.java:101)
    13:54:42,820 ERROR [STDERR]      at org.ajax4jsf.framework.ajax.AjaxViewHandler.rend
    erView(AjaxViewHandler.java:222)
    13:54:42,820 ERROR [STDERR]      at com.sun.faces.lifecycle.RenderResponsePhase.exec
    ute(RenderResponsePhase.java:106)
    13:54:42,820 ERROR [STDERR]      at com.sun.faces.lifecycle.LifecycleImpl.phase(Life
    cycleImpl.java:251)
    13:54:42,820 ERROR [STDERR]      at com.sun.faces.lifecycle.LifecycleImpl.render(Lif
    ecycleImpl.java:144)
    13:54:42,820 ERROR [STDERR]      at javax.faces.webapp.FacesServlet.service(FacesSer
    vlet.java:245)
    13:54:42,820 ERROR [STDERR]      at org.apache.catalina.core.ApplicationFilterChain.
    internalDoFilter(ApplicationFilterChain.java:290)
    13:54:42,820 ERROR [STDERR]      at org.apache.catalina.core.ApplicationFilterChain.
    doFilter(ApplicationFilterChain.java:206)
    13:54:42,820 ERROR [STDERR]      at com.hds.vc.common.infrastructure.AIMFilter.doFil
    ter(AIMFilter.java:27)
    13:54:42,820 ERROR [STDERR]      at org.apache.catalina.core.ApplicationFilterChain.
    internalDoFilter(ApplicationFilterChain.java:235)
    13:54:42,820 ERROR [STDERR]      at org.apache.catalina.core.ApplicationFilterChain.
    doFilter(ApplicationFilterChain.java:206)
    13:54:42,820 ERROR [STDERR]      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.d
    oFilter(ReplyHeaderFilter.java:96)
    13:54:42,820 ERROR [STDERR]      at org.apache.catalina.core.ApplicationFilterChain.
    internalDoFilter(ApplicationFilterChain.java:235)
    13:54:42,820 ERROR [STDERR]      at org.apache.catalina.core.ApplicationFilterChain.
    doFilter(ApplicationFilterChain.java:206)
    13:54:42,820 ERROR [STDERR]      at org.apache.catalina.core.StandardWrapperValve.in
    voke(StandardWrapperValve.java:230)
    13:54:42,820 ERROR [STDERR]      at org.apache.catalina.core.StandardContextValve.in
    voke(StandardContextValve.java:175)
    13:54:42,820 ERROR [STDERR]      at org.jboss.web.tomcat.security.SecurityAssociatio
    nValve.invoke(SecurityAssociationValve.java:179)
    13:54:42,820 ERROR [STDERR]      at org.jboss.web.tomcat.security.JaccContextValve.i
    nvoke(JaccContextValve.java:84)
    13:54:42,820 ERROR [STDERR]      at org.apache.catalina.core.StandardHostValve.invok
    e(StandardHostValve.java:128)
    13:54:42,820 ERROR [STDERR]      at org.apache.catalina.valves.ErrorReportValve.invo
    ke(ErrorReportValve.java:104)
    13:54:42,820 ERROR [STDERR]      at org.jboss.web.tomcat.service.jca.CachedConnectio
    nValve.invoke(CachedConnectionValve.java:156)
    13:54:42,820 ERROR [STDERR]      at org.apache.catalina.core.StandardEngineValve.inv
    oke(StandardEngineValve.java:109)
    13:54:42,820 ERROR [STDERR]      at org.apache.catalina.connector.CoyoteAdapter.serv
    ice(CoyoteAdapter.java:241)
    13:54:42,820 ERROR [STDERR]      at org.apache.coyote.http11.Http11Processor.process
    (Http11Processor.java:844)
    13:54:42,820 ERROR [STDERR]      at org.apache.coyote.http11.Http11Protocol$Http11Co
    nnectionHandler.process(Http11Protocol.java:580)
    13:54:42,820 ERROR [STDERR]      at org.apache.tomcat.util.net.JIoEndpoint$Worker.ru
    n(JIoEndpoint.java:447)
    13:54:42,820 ERROR [STDERR]      at java.lang.Thread.run(Unknown Source)
    13:54:42,820 ERROR [STDERR] Caused by: java.net.SocketException: Connection rese
    t by peer: socket write error
    13:54:42,820 ERROR [STDERR]      at java.net.SocketOutputStream.socketWrite0(Native
    Method)
    13:54:42,820 ERROR [STDERR]      at java.net.SocketOutputStream.socketWrite(Unknown
    Source)
    13:54:42,820 ERROR [STDERR]      at java.net.SocketOutputStream.write(Unknown Source
    13:54:42,820 ERROR [STDERR]      at org.apache.coyote.http11.InternalOutputBuffer$Ou
    tputStreamOutputBuffer.doWrite(InternalOutputBuffer.java:764)
    13:54:42,820 ERROR [STDERR]      at org.apache.coyote.http11.filters.ChunkedOutputFi
    lter.doWrite(ChunkedOutputFilter.java:124)
    13:54:42,820 ERROR [STDERR]      at org.apache.coyote.http11.InternalOutputBuffer.do
    Write(InternalOutputBuffer.java:570)
    13:54:42,820 ERROR [STDERR]      at org.apache.coyote.Response.doWrite(Response.java
    :560)
    13:54:42,820 ERROR [STDERR]      at org.apache.catalina.connector.OutputBuffer.realW
    riteBytes(OutputBuffer.java:353)
    13:54:42,820 ERROR [STDERR]      ... 33 more
    Please throw some light on this issue.

    This is the Java script I am using
    function submitForm(e){
         var characterCode
         if(e && e.which){
         e = e
         characterCode = e.which
         }else{
         e = event                    characterCode = e.keyCode
         if (characterCode== 13){
         document.getElementById('mainform:submitForm:search').onclick();
    Regards,
    Jagadeesh
    Edited by: Jagadeesh.Pala on Oct 1, 2007 3:59 AM

  • Permission Denied when calling a method from VB using WebLogic 8.1.2 JCOM

    Hi,
    We are calling an java/ejb methods from VB using WebLogic JCOM 8.1 SP2. But
    using JCOM, we are getting a error Permission denied when called from VB. We think
    that we should update pathch jintegra 2.0 or 2.1 in WebLogic 8.1.2 the to solve
    this issue, because we faced the same problen "permission denied" when we used
    JINTEGRA(third party software). Once we installed the JINTEGRA 2.1 it solved the
    issue.
    So, can anyone help on regard to this issue of "Permission denied" in WebLogic
    JCOM 8.1 SP2.
    Thanks & Regards
    Raghu

    I too am experiencing the jCOM error: "Run-time error '70': Permission Denied". The problem appears to be related to a Microsoft Security Patch KB835732 (MS04-011 which, as you indicated, has been fixed in J-Integra v2.1 (FYI, jCOM 8.1 is based on J-Integra 1.5.4, see J-Integra/jCOM versions.
    Did you ever get a resolution concerning 8.1 SP2? 8.1 SP3 is available now but I don't see any mention of jCOM updates in the WebLogic 8.1 What's New documention. I can't immediately upgrade (trying to stay on same version as a few other developers I work with) but I am hoping it is resolved in SP3.

  • We are using extends thread and implements runnable which class first calli

    hi

    Yes, the language allows it, but your JSL quote is the 3rd edition, and Java 1.4 is based on the 2nd edition (the 2nd edition of the JSL does not go into such a deep explanation of the example shown, so thanks for that pointer). In any case, since the JSL does not address my specific issue, it is only superficially relevant (IMHO). The language allows it, but the behavior is unpredictable. I think that's what is sticking in my craw. I'm not sure what the behavior should be, but if I had to, I would propose that the behavior should not change when I change the inheritance qualifiers (again, in this particular case), but there may be other considerations.
    HibernateUtil is a snippet that can be found in the Hibernate tutorial/reference at [http://www.hibernate.org/hib_docs/v3/reference/en/html/tutorial.html|http://www.hibernate.org/hib_docs/v3/reference/en/html/tutorial.html]
    The basic idea is a cached session factory, because session factories are expensive to build. We use multiple databases, so our incarnation of HibernateUtil compares the requested database to the one in a static factory variable. If they match, that factory is used. If they don't match, the thread switches to the requested factory and creates sessions from it.
    The odd thing is that with the aforementioned inheritance "typo", it either detects that the requested database is the same as the one in the static factory (which is not true), or it returns the wrong factory (which is wrong). I want to emphasize that no other code changes were made (zero, zip, none, really, I mean it), and lots of other classes extend C1 (from the example) and they have never had this problem.

  • Run time error when calling Start() method from an Output counter user control in my class.

    I am new to DAQmx and .NET.
    In my application I need to activate a clock out on counter 2 (HW pci 16 E 4).
    I went through all the steps like the sampling examples but instead of Analog input
    I used counter output , and setup the pulse ratios.
    When I click the switch in the user interface ( a user control databinded to the clock output)
    the output works. Since I need to activate it programmatically I tried to call the daQmxUserControl11.Start()
    method but this causes the following error :
    An unhandled exception of type 'NationalInstruments.DAQmx.DaqException' occurred in nationalinstruments.daqmx.dll
    Additional information: Specified operation cannot be performed while the task is running.
    Task Name: DAQmxTask1
    Status Code: -200479
    Any ideas on what am I doing wrong?
    Thanks David

    Thanks a lot,
    I also discovered that dragging the user control onto my user interface doesn't allow alternate activation.
    ( I actually tried stopping and then starting but the result was the same )
    Calling the routines as indicated in the header comments also gave some hiccups ( I had to remark some code to get the system working progrtammatically.
    public void Start()
    #region Update UI
    this.switch1.Caption = "On";
    this.switch1.Value = true;
    #endregion
    daqmxTask.Start();
    public void Stop()
    #region Update UI
    this.switch1.Caption = "Off";
    this.switch1.Value = false;
    #endregion
    daqmxTask.Stop();
    #region Methods

  • Converting a string to Class object and calling its method

    I have recently moved to Java and I need help on this specific issue given below.
    I have to do this :
    ValModule1 val1 = new ValModule1();
    ValModule2 val2 = new ValModule2();
    if(val1.checkModule(xmlDocument)){
    $i++;
    There are many ValModule* classes and they all have the method called checkModule in them. I need to instantiate each class and run the checkMethod which returns true or false. My problem is that I am trying to get the name of the module (if it is ValModule1 or 2 or 3) from the user. What I get from the user is the name of the class for which I should call checkModule method on.
    how can I convert this string validationname given by the user and instantiate that class and call the method?
    I have tried this:
    String str="c:/xpathtest/src/Plugin_Config.xml";
    File xmlDocument = new File(str);
    String cls = "ValModule1"; // assuming this is what the user gave me
    Class t = Class.forName("ValModule1");
    Object o = t.newInstance();
    After that if I try
    if(o.checkModule(xmlDocument)){
    $i++;
    It gives me an error saying that it is not an existing method
    cannot resolve symbol
    [javac] symbol : method checkModule (java.io.File)
    [javac] location: class java.lang.Object
    [javac] if(o.checkModule(xmlDocument)){
    [javac] ^
    [javac] 1 error
    Can you please let me know where I am screwing up :-) ? If you need me to put both the programs I can do that too. Thanks in Anticipation

    I have recently moved to Java and I need help on this
    specific issue given below.
    I have to do this :
    ValModule1 val1 = new ValModule1();
    ValModule2 val2 = new ValModule2();
    if(val1.checkModule(xmlDocument)){
    $i++;
    There are many ValModule* classes and they all have
    the method called checkModule in them. I need to
    instantiate each class and run the checkMethod which
    returns true or false. My problem is that I am trying
    to get the name of the module (if it is ValModule1 or
    2 or 3) from the user. What I get from the user is
    the name of the class for which I should call
    checkModule method on.
    how can I convert this string validationname given by
    the user and instantiate that class and call the
    method?
    Define an interface containing the method all your classes have in common, cast the Object reference returned by newInstance to that interface, then you can call that method.
    Good Luck
    Lee

  • How to load a class dynamically and then a call a method?

    Hi
    I want to call a method from a class,which class is loaded dynamically.
    Consider a classA and ClassB..
    ClassB contains a method showvalue() which returns a String value.
    I want to load a ClassB dynamically in ClassA,and call the method showvalue() and print the returned value of that method (showvalue).
    How to do this?
    Thanks

    Since you found your way to Reflections and Reference Objects, I can only assume you know that reflection is the answer. Since the reflection tutorial on this site, and indeed, the many others on the web, can explain this a whole lot better and more consisely than can be done in a forum, I'll point you in that direction instead. As a starting point, and to show I'm not just fobbing you off, you're interested in the classes java.lang.Class, java.lang.reflect.Method, and the method Class.getMethod(String, Class[])

  • Using Java Reflection to call a method with int parameter

    Hi,
    Could someone please tell me how can i use the invoke() of the Method class to call an method wiht int parameter? The invoke() takes an array of Object, but I need to pass in an array of int.
    For example I have a setI(int i) in my class.
    Class[] INT_PARAMETER_TYPES = new Class[] {Integer.TYPE };
    Method method = targetClass.getMethod(methodName, INT_PARAMETER_TYPES);
    Object[] args = new Object[] {4}; // won't work, type mismatch
    int[] args = new int[] {4}; // won't work, type mismatch
    method.invoke(target, args);
    thanks for any help.

    Object[] args = new Object[] {4}; // won't work, type
    mismatchShould be:
        Object[] args = new Object[] { new Integer(4) };The relevant part of the JavaDoc for Method.invoke(): "If the corresponding formal parameter has a primitive type, an unwrapping conversion is attempted to convert the object value to a value of a primitive type. If this attempt fails, the invocation throws an IllegalArgumentException. "
    I suppose you could pass in any Number (eg, Double instead of Integer), but that's just speculation.

  • How to determine the Class of a static methods class?

    hi,
    is there a way to get the code below to output
    foo() called on One.class
    foo() called on Two.classthanks,
    asjf
    public class Two extends One {
       public static void main(String [] arg) {
          One.foo(); // should say "foo() called on One.class"
          Two.foo(); // should say "foo() called on Two.class"
    class One {
       public static final void foo() {
          System.out.println("foo() called on "/*+something.getClass()*/);
    }

    - One.class won't resolve to Two.class when the static
    method is called via the class TwoThat's because static methods are not polymorphic. They cannot be overridden. For example try this:
    public class Two extends One {
       public static void main(String [] arg) {
          One.foo(); // should say "foo() called on One.class"
          Two.foo(); // should say "foo() called on Two.class"
          One one = new Two();
          one.foo();
          ((Two) one).foo();
       public static void foo() {
          System.out.println("foo() called on Two");
    class One {
       public static void foo() {
          System.out.println("foo() called on One");
    }

  • Telling which class called your method

    Does anybody know a way you can tell which class is calling your method? I mean:
    class A {
    public static void main(String args[]) {
    new A.doIt();
    void doIt() {
    B b = new B();
    b.callMe();
    class B {
    public void callMe() {
    String whoDidIt;
    whoDidIt=[stuff i'm asking for];
    System.out.println("I was called from an instance of class " + whoDidIt);
    How can I get that code to print "I was called from an instance of class A"???
    Lots of thanks in advance

    Pass the calling object to callMe as a parameter, egB b = new B();
    b.callMe(this);callMe becomes:
    public void callMe(Object caller)
       System.out.println("I was called from an instance of class " + caller.getClass());
    }Of course, there is nothing to stop anyone who calls the method passing a different object and confusing callMe.

Maybe you are looking for

  • Office 2007 Document Attaching in Solution Manager

    Dear Gurus, When document attaching in Solution Manager 7.01, the system does not support Microsoft Office 2007 formats. (docx, xlsx) Are there any customizing for this topic? Thank you,

  • Firefox always opens with a search box rather than my homepage.

    I have dragged the icon over to the homepage icon, and responded "yes" that I want to set it as my homepage. It always opens with a search box instead. http://www.searchqu.com/406 is the URL. How can I get it to use my homepage?

  • Palm T/X Sync with Windows Vista - 64 processor

    I have a Palm T/X handheld and recently purchased a new computer that has Windows Vista operating system and a 64-bit processor. I tried to download the software that would allow me to HotSync my T/X with Windows Vista, but apparently this does not w

  • How to view source of native method Thread.start()

    I have already downloaded and unzipped the source code for JDK. I want to view the implementation of Thread.start() method. However, I can only see one line: public synchronized native void start();Could anyone tell me how can view the implementation

  • White mark on the retina screen

    My new iPhone 4S had a white mark on the right bottom of the retina screen. Is this a hardware problem ? and can I have a new replacement ? Thanks.