Access Specifiers for a class

Why we can't declare private or protected for a class as access specifier.
Can you give me an example on it.

This is the third time someone asked something like this today:
http://forum.java.sun.com/thread.jspa?threadID=664848 (where someone references your post on JavaRanch).
http://forum.java.sun.com/thread.jspa?threadID=664790

Similar Messages

  • Access specifiers for interface methods

    When we implement the interface ,we have to specify the implementing method access specifier to be "PUBLIC" ,but not "PROTECTED" or "PRIVATE".
    Compiler is giving an error -- attempting to assign weaker access privileges ,when we specify protected.
    what is the internal reason for this?Why we shouldnt make the access weaker in the implementing class.
    Can any one help me on this.Your help is highly appreciated.

    When we implement the interface ,we have to specify
    the implementing method access specifier to be
    "PUBLIC" ,but not "PROTECTED" or "PRIVATE".
    Compiler is giving an error -- attempting to assign
    weaker access privileges ,when we specify protected.
    what is the internal reason for this?There is absolutely no point in having a private interface method. The interface represents a visible abstraction and private methods are never visible so it is a contradiction in terms.
    An interface is intended to represent an abstraction that a user (software) uses. Protected via child/parent represents a usage that is restricted to a child from a parent. The child can already see the parent so there is no point in having an abstraction for the child. And it would probably be unwise to limit a child by such an abstraction.
    Protected via the package and interfaces is more contentious as to why it is not allowed. There are those that argue that this should be allowed so that a package can use interfaces but restrict them to the package. To me this seems like a minor point given that most interfaces will probably represent an abstraction to other packages and not within a single package. This applies specifically to default access as well.

  • Default access specifiers for void main()

    I m having one problem that if i make void main(String a[])
    syntax like private static void main(String args[]) and run using jdk1.4 it will run. So my question is that why this is possible still i making main() private. If i run it in jdk1.5.0 then it give error main is not public so what was the problem with the jdk1.4?

    Congratulations on your first post after almost 2
    years. ?The most impressive thing is that he remembered his
    password ...I posted by first message in 2004, I only used this account to read the bugdatabase and vote on bugs prior to that. So I don't see anything strange in having an account, and not using the forums.
    Kaj
    Ps. But I'm also impressed by the fact that he remembered the password, I had an account which I created in -97, but I forgot the password to that account :(

  • My java program runs fine even if i don't specify access specifier of class

    Hi,
    My java program runs fine even if i don't specify access specifier of class as public .
    Then why do they say that atleast one class should be specified as public.
    please help.

    public access specifier is the default access
    specifier
    so if you dont give the access specifier before the
    class name it is not wrong.I think that you are wrong. The default specifier is package or "package-private".
    See here:
    http://java.sun.com/docs/books/tutorial/java/javaOO/accesscontrol.html
    Message was edited by:
    petes1234

  • About access specifiers (inheritance)

    abstract Class A
    abstract public add();
    Class B extends A
    protected add() //this wont work
    //some code here
    The access specifier for add method in A is public ,and in B is protected.This is not allowed by compiler.
    Why cant we make the access weaker in the sub class?What is the drawback in allowing to make the access weaker.

    Because any class that uses class A has the right to expect to use the add() method, since it is public in A. Since B is an A, it must allow some one to use an instance of B as if it were an A.

  • Java inner class access specifiers

    public class MyClass1 {
    public static void main(String argv[]){ }
    /*Modifier at XX */ class MyInner {}
    What modifiers would be legal at XX in the above code?
    1) public
    2) private
    3) static
    4) friend

    Iam a newbie to javaI don't care. I still assume you have a brain and expect you to use it.
    and iam struck with this
    question, iam getting a compile time error for any
    access specifiers mentioned as options, but the
    answers given by my superior are 1,2,3, are
    correct..Then you made a typo or whatever. Make sure you eliminate the problems that are not "illegal access modifier" errors.
    What good is knowing the reply to this if you can't even write an example?

  • Java class specified for a rule not present in the archive path

    While checking an implementation of configurator, I found a CX rule that has a java class associated with it oracle.apps.cz.cx.xxx.AVCX
    But, when I clicked the 'Choose class' button to check where this class is located, I am unable to find the same in the list of available classes.
    I have also checked the jar file containing the custom java classes with no avail.
    But, the functionality works fine as expected. i.e., while clicking the UI button that invokes this CX rule, it works as it should.
    What could be the reason for this? Could the java class be hidden somewhere else other than the archive path specified for this model?
    Thanks in advance for any advise.

    Hi Biju,
    In this case, this class may be located on the server file system. To know the location of any class on server system, you can do following:
    Open http://host:url/OA_HTML/CZInfo.jsp
    Enter your classname with path in apprpriate input box and then find it. It would display the location of the class in filesystem from where its loaded.
    Thanks,
    Pankaj

  • Unable to locate specified base class 'resources.style1.HelpButtonIcon' for component class

    Hi,
    I have a Flex (4.1.0) project, which has many skinnable custom components. The application allows a user to choose another style which changes these skins via loading a new compiled CSS. These non-default skins are in a separate Flex project.  I've not had a problem with this method until now.
    The custom component I am skinning contains several icons which are defined in the component like this:
    [SkinPart(required="true", type="mx.core.IVisualElement")]
    public var componentIconHelp:IFactory;
    then I use the iconRendererFunction to return the appropriate component part:
    private function iconRendererFunction(item:Object):IFactory
         //truncated method    
         return componentIconHelp;
    Within the skin for "style1", I then have
    <s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009"
         xmlns:s="library://ns.adobe.com/flex/spark"
         xmlns:mx="library://ns.adobe.com/flex/mx"
         xmlns:style1="resources.style1.*">
    <!-- host component -->
    <fx:Metadata>
         [HostComponent("myApp.components.ButtonComponent")]
    </fx:Metadata>
    <fx:Declarations>
         <fx:Component id="componentIconHelp">
              <style1:HelpButtonIcon />
         </fx:Component>
    </Declarations>
    When I try to compile this, I get the "Unable to locate specified base class 'resources.style1.HelpButtonIcon' for component class 'resources.style1.ButtonComponentSkinInnerClass0'" error.
    If I remove the HelpButtonIcon from the <fx:Component> declaration, and just put it in the main body of the skin, it compiles and renders, but I need it to be a component (there's multiple components I have to choose from to display, similar to the ButtonBar skin).
    Any ideas why it's not compiling and what I need to do to achive this?
    Thanks

    Thanks, one step closer (or further away :-)
    I tried adding the airspark.swc to the library path for the project and it made no difference so I added:
    -external-library-path /Applications/Adobe Flash Builder 4/sdks/4.0.0/frameworks/libs/air/airspark.swc
    to the external tools configuration and now get the error:
    command line: Error: unable to open 'Flash'
    The project itself runs fine, it's only the ASDocs that's causing problems.

  • No servlet class has been specified for servlet null

    Hi,
    I�m trying to bend tomcat in my own application. Therefore I�m using the Embedded Tomcat version 5.5.23.
    I have started only a server, engine, host and context, so I have a server without the sockets etc. this because it has to become a test-application for the web-app of the company.
    The server starts gracefully, but when I call context.invoke(request,response) I get this error:
    SEVERE: Allocate exception for servlet null
    With this stacktrace:
    javax.servlet.ServletException: No servlet class has been specified for servlet null
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1016)
    at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:791)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:127)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:870)
    at nl.realworks.embedTomcat.EmbedTomcat.invoke(EmbedTomcat.java:74)
    at nl.realworks.embedTomcat.StartEmbedTomcat.main(StartEmbedTomcat.java:29)
    Exception in thread "main" java.lang.NullPointerException
    at org.apache.catalina.connector.Request.setAttribute(Request.java:1383)
    at org.apache.catalina.core.StandardWrapperValve.exception(StandardWrapperValve.java:331)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:145)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:870)
    at nl.realworks.embedTomcat.EmbedTomcat.invoke(EmbedTomcat.java:74)
    at nl.realworks.embedTomcat.StartEmbedTomcat.main(StartEmbedTomcat.java:29)
    does anyone has a idea what the cause of this problem is? The request I send is �GET /index.jsp� using a MockHttpServletRequest of the spring framework. I convert the mockhttpservletrequest to a org.apache.cataline.connecor.Request. and that works.
    The code in tomcat where the error is caused by:
    // Complain if no servlet class has been specified
    if (actualClass == null) {
    unavailable(null);
    throw new ServletException
    (sm.getString("standardWrapper.notClass", getName()));
    Thanks in advance.
    Auke Noppe

    Tobias
    Yes , you are correct. We dont need to replicate DDIC tables for direct BW replication. This was the first time we were working with BW on Hana and never installed DMIS component on that system. The error was gone after we put the addon.
    Mahesh Shetty

  • Specifying access rights for page tabs

    Hello
    I have trouble with specifying access rights for tabs that are inside another tab.
    I have a group named "Customers" and a group for each of our customer companies. The company-groups are all members of the Customers group.
    Then i created a tab called "Customers" which i specified access rights to the Customers group.
    Under the customers tab, i created one tab for each customer and i've specified access rights to each tab.
    I want to accomplish that customers who log into the portal only are able to see theyr own tab, but this doesn't seem to work properly.
    Have anyone had this problem before?
    Regards
    Per-Jarle Sfther

    Per-Jarle,
    Are you sure that the users are not part of a group that is included in the group you gave access to on the tab?
    Rich

  • Storage class specified for parameter error

    I used gcc version 4.2.1
    on Target: sparc-sun-solaris2.8
    Configured with: /net/Src/Gnu/GCC/gcc-4.2.1/configure prefix=/usr/local/Gnu/Sol8 enable-languages=c,c++,fortran with-ld=/usr/local/Gnu/bin/ld with-gnu-ld with-as=/usr/local/Gnu/bin/as with-gnu-as with-ar=/usr/local/Gnu/bin/ar with-gnu-ar
    Thread model: posix
    to make a program which include some of standard system header file
    Making the code gave this error message:
    gcc -o resource_vector_test.o -c resource_vector_test.c
    In file included from /usr/include/sys/select.h:51,
    from /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/sys/types.h:574,
    from /usr/include/fcntl.h:39,
    from resource_vector_test.c:2:
    /usr/include/sys/time.h:345: error: redefinition of parameter '_RESTRICT_KYWD'
    /usr/include/sys/time.h:344: error: previous definition of '_RESTRICT_KYWD' was here
    /usr/include/sys/time.h:395: error: conflicting types for '_RESTRICT_KYWD'
    /usr/include/sys/time.h:395: error: previous definition of '_RESTRICT_KYWD' was here
    In file included from /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/time.h:29,
    from /usr/include/sys/time.h:416,
    from /usr/include/sys/select.h:51,
    from /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/sys/types.h:574,
    from /usr/include/fcntl.h:39,
    from resource_vector_test.c:2:
    /usr/include/iso/time_iso.h:110: error: conflicting types for '_RESTRICT_KYWD'
    /usr/include/iso/time_iso.h:110: error: previous definition of '_RESTRICT_KYWD' was here
    /usr/include/iso/time_iso.h:111: error: conflicting types for '_RESTRICT_KYWD'
    /usr/include/iso/time_iso.h:110: error: previous definition of '_RESTRICT_KYWD' was here
    In file included from /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/sys/types.h:574,
    from /usr/include/fcntl.h:39,
    from resource_vector_test.c:2:
    /usr/include/sys/select.h:168: error: redefinition of parameter '_RESTRICT_KYWD'
    /usr/include/sys/select.h:168: error: previous definition of '_RESTRICT_KYWD' was here
    /usr/include/sys/select.h:169: error: redefinition of parameter '_RESTRICT_KYWD'
    /usr/include/sys/select.h:168: error: previous definition of '_RESTRICT_KYWD' was here
    /usr/include/sys/select.h:169: error: conflicting types for '_RESTRICT_KYWD'
    /usr/include/sys/select.h:169: error: previous definition of '_RESTRICT_KYWD' was here
    /usr/include/sys/select.h:172: error: redefinition of parameter '_RESTRICT_KYWD'
    /usr/include/sys/select.h:172: error: previous definition of '_RESTRICT_KYWD' was here
    /usr/include/sys/select.h:173: error: redefinition of parameter '_RESTRICT_KYWD'
    /usr/include/sys/select.h:172: error: previous definition of '_RESTRICT_KYWD' was here
    /usr/include/sys/select.h:173: error: conflicting types for '_RESTRICT_KYWD'
    /usr/include/sys/select.h:173: error: previous definition of '_RESTRICT_KYWD' was here
    /usr/include/sys/select.h:174: error: conflicting types for '_RESTRICT_KYWD'
    /usr/include/sys/select.h:173: error: previous definition of '_RESTRICT_KYWD' was here
    In file included from resource_vector_test.c:3:
    /usr/include/unistd.h: In function '_exit':
    /usr/include/unistd.h:292: error: expected declaration specifiers before '__NORETURN'
    /usr/include/unistd.h:299: error: storage class specified for parameter 'fattach'
    /usr/include/unistd.h:302: error: storage class specified for parameter 'fchdir'
    /usr/include/unistd.h:303: error: storage class specified for parameter 'fchown'
    /usr/include/unistd.h:306: error: storage class specified for parameter 'fchownat'
    /usr/include/unistd.h:310: error: storage class specified for parameter 'fchroot'
    /usr/include/unistd.h:314: error: storage class specified for parameter 'fdatasync'
    /usr/include/unistd.h:322: error: storage class specified for parameter 'fdetach'
    /usr/include/unistd.h:324: error: storage class specified for parameter 'fork'
    /usr/include/unistd.h:326: error: storage class specified for parameter 'fork1'
    /usr/include/unistd.h:327: error: storage class specified for parameter 'forkall'
    /usr/include/unistd.h:329: error: storage class specified for parameter 'fpathconf'
    /usr/include/unistd.h:332: error: storage class specified for parameter 'fsync'
    /usr/include/unistd.h:337: error: storage class specified for parameter 'ftruncate'
    /usr/include/unistd.h:339: error: storage class specified for parameter 'getcwd'
    /usr/include/unistd.h:342: error: storage class specified for parameter 'getdtablesize'
    /usr/include/unistd.h:344: error: storage class specified for parameter 'getegid'
    /usr/include/unistd.h:345: error: storage class specified for parameter 'geteuid'
    /usr/include/unistd.h:346: error: storage class specified for parameter 'getgid'
    /usr/include/unistd.h:347: error: storage class specified for parameter 'getgroups'
    /usr/include/unistd.h:349: error: storage class specified for parameter 'gethostid'
    /usr/include/unistd.h:354: error: storage class specified for parameter 'gethostname'
    /usr/include/unistd.h:356: error: storage class specified for parameter 'getlogin'
    /usr/include/unistd.h:369: error: storage class specified for parameter 'getpagesize'
    /usr/include/unistd.h:371: error: storage class specified for parameter 'getpgid'
    /usr/include/unistd.h:373: error: storage class specified for parameter 'getpid'
    /usr/include/unistd.h:374: error: storage class specified for parameter 'getppid'
    /usr/include/unistd.h:375: error: storage class specified for parameter 'getpgrp'
    /usr/include/unistd.h:381: error: storage class specified for parameter 'getsid'
    /usr/include/unistd.h:383: error: storage class specified for parameter 'getuid'
    /usr/include/unistd.h:385: error: storage class specified for parameter 'getusershell'
    /usr/include/unistd.h:388: error: storage class specified for parameter 'getwd'
    /usr/include/unistd.h:396: error: storage class specified for parameter 'ioctl'
    /usr/include/unistd.h:397: error: storage class specified for parameter 'isaexec'
    /usr/include/unistd.h:398: error: storage class specified for parameter 'issetugid'
    /usr/include/unistd.h:400: error: storage class specified for parameter 'isatty'
    /usr/include/unistd.h:402: error: storage class specified for parameter 'lchown'
    /usr/include/unistd.h:404: error: storage class specified for parameter 'link'
    /usr/include/unistd.h:406: error: storage class specified for parameter 'llseek'
    /usr/include/unistd.h:411: error: storage class specified for parameter 'lockf'
    /usr/include/unistd.h:413: error: storage class specified for parameter 'lseek'
    /usr/include/unistd.h:416: error: storage class specified for parameter 'nice'
    /usr/include/unistd.h:419: error: storage class specified for parameter 'mincore'
    /usr/include/unistd.h:421: error: storage class specified for parameter 'pathconf'
    /usr/include/unistd.h:422: error: storage class specified for parameter 'pause'
    /usr/include/unistd.h:423: error: storage class specified for parameter 'pipe'
    /usr/include/unistd.h:427: error: storage class specified for parameter 'pread'
    /usr/include/unistd.h:430: error: storage class specified for parameter 'profil'
    /usr/include/unistd.h:442: error: storage class specified for parameter 'pthread_atfork'
    /usr/include/unistd.h:446: error: storage class specified for parameter 'ptrace'
    /usr/include/unistd.h:451: error: storage class specified for parameter 'pwrite'
    /usr/include/unistd.h:456: error: storage class specified for parameter 'rcmd_af'
    /usr/include/unistd.h:458: error: storage class specified for parameter 'read'
    /usr/include/unistd.h:461: error: conflicting types for '_RESTRICT_KYWD'
    /usr/include/unistd.h:461: error: previous definition of '_RESTRICT_KYWD' was here
    /usr/include/unistd.h:462: error: storage class specified for parameter 'readlink'
    /usr/include/unistd.h:466: error: storage class specified for parameter 'rename'
    /usr/include/unistd.h:470: error: storage class specified for parameter 'renameat'
    /usr/include/unistd.h:473: error: storage class specified for parameter 'resolvepath'
    /usr/include/unistd.h:476: error: storage class specified for parameter 'rexec_af'
    /usr/include/unistd.h:478: error: storage class specified for parameter 'rmdir'
    /usr/include/unistd.h:481: error: storage class specified for parameter 'rresvport_af'
    /usr/include/unistd.h:486: error: storage class specified for parameter 'sbrk'
    /usr/include/unistd.h:489: error: storage class specified for parameter 'setegid'
    /usr/include/unistd.h:490: error: storage class specified for parameter 'seteuid'
    /usr/include/unistd.h:492: error: storage class specified for parameter 'setgid'
    /usr/include/unistd.h:494: error: storage class specified for parameter 'setgroups'
    /usr/include/unistd.h:495: error: storage class specified for parameter 'sethostname'
    /usr/include/unistd.h:497: error: storage class specified for parameter 'setpgid'
    /usr/include/unistd.h:499: error: storage class specified for parameter 'setpgrp'
    /usr/include/unistd.h:500: error: storage class specified for parameter 'setregid'
    /usr/include/unistd.h:501: error: storage class specified for parameter 'setreuid'
    /usr/include/unistd.h:503: error: storage class specified for parameter 'setsid'
    /usr/include/unistd.h:504: error: storage class specified for parameter 'setuid'
    /usr/include/unistd.h:506: error: storage class specified for parameter 'setusershell'
    /usr/include/unistd.h:508: error: storage class specified for parameter 'sleep'
    /usr/include/unistd.h:510: error: storage class specified for parameter 'stime'
    /usr/include/unistd.h:517: error: storage class specified for parameter 'symlink'
    /usr/include/unistd.h:518: error: storage class specified for parameter 'sync'
    /usr/include/unistd.h:527: error: storage class specified for parameter 'sysconf'
    /usr/include/unistd.h:528: error: storage class specified for parameter 'tcgetpgrp'
    /usr/include/unistd.h:529: error: storage class specified for parameter 'tcsetpgrp'
    /usr/include/unistd.h:533: error: storage class specified for parameter 'tell'
    /usr/include/unistd.h:538: error: storage class specified for parameter 'truncate'
    /usr/include/unistd.h:540: error: storage class specified for parameter 'ttyname'
    /usr/include/unistd.h:542: error: storage class specified for parameter 'ualarm'
    /usr/include/unistd.h:544: error: storage class specified for parameter 'unlink'
    /usr/include/unistd.h:547: error: storage class specified for parameter 'unlinkat'
    /usr/include/unistd.h:550: error: storage class specified for parameter 'usleep'
    /usr/include/unistd.h:553: error: storage class specified for parameter 'vfork'
    /usr/include/unistd.h:556: error: storage class specified for parameter 'vhangup'
    /usr/include/unistd.h:558: error: storage class specified for parameter 'write'
    /usr/include/unistd.h:560: error: storage class specified for parameter 'yield'
    /usr/include/unistd.h:566: error: storage class specified for parameter 'ftruncate64'
    /usr/include/unistd.h:567: error: storage class specified for parameter 'lseek64'
    /usr/include/unistd.h:568: error: storage class specified for parameter 'pread64'
    /usr/include/unistd.h:569: error: storage class specified for parameter 'pwrite64'
    /usr/include/unistd.h:570: error: storage class specified for parameter 'tell64'
    /usr/include/unistd.h:571: error: storage class specified for parameter 'truncate64'
    /usr/include/unistd.h:572: error: storage class specified for parameter 'lockf64'
    /usr/include/unistd.h:962: error: storage class specified for parameter 'getlogin_r'
    /usr/include/unistd.h:963: error: storage class specified for parameter 'ttyname_r'
    In file included from /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/string.h:27,
    from resource_vector_test.c:4:
    /usr/include/iso/string_iso.h:77: error: storage class specified for parameter 'memcmp'
    /usr/include/iso/string_iso.h:78: error: conflicting types for '_RESTRICT_KYWD'
    /usr/include/iso/string_iso.h:78: error: previous definition of '_RESTRICT_KYWD' was here
    /usr/include/iso/string_iso.h:78: error: storage class specified for parameter 'memcpy'
    /usr/include/iso/string_iso.h:79: error: storage class specified for parameter 'memmove'
    /usr/include/iso/string_iso.h:80: error: storage class specified for parameter 'memset'
    /usr/include/iso/string_iso.h:81: error: conflicting types for '_RESTRICT_KYWD'
    /usr/include/iso/string_iso.h:81: error: previous definition of '_RESTRICT_KYWD' was here
    /usr/include/iso/string_iso.h:81: error: storage class specified for parameter 'strcat'
    /usr/include/iso/string_iso.h:82: error: storage class specified for parameter 'strcmp'
    /usr/include/iso/string_iso.h:83: error: conflicting types for '_RESTRICT_KYWD'
    /usr/include/iso/string_iso.h:83: error: previous definition of '_RESTRICT_KYWD' was here
    /usr/include/iso/string_iso.h:83: error: storage class specified for parameter 'strcpy'
    /usr/include/iso/string_iso.h:84: error: storage class specified for parameter 'strcoll'
    /usr/include/iso/string_iso.h:85: error: storage class specified for parameter 'strcspn'
    /usr/include/iso/string_iso.h:86: error: storage class specified for parameter 'strerror'
    /usr/include/iso/string_iso.h:87: error: storage class specified for parameter 'strlen'
    /usr/include/iso/string_iso.h:88: error: conflicting types for '_RESTRICT_KYWD'
    /usr/include/iso/string_iso.h:88: error: previous definition of '_RESTRICT_KYWD' was here
    /usr/include/iso/string_iso.h:88: error: storage class specified for parameter 'strncat'
    /usr/include/iso/string_iso.h:89: error: storage class specified for parameter 'strncmp'
    /usr/include/iso/string_iso.h:90: error: conflicting types for '_RESTRICT_KYWD'
    /usr/include/iso/string_iso.h:90: error: previous definition of '_RESTRICT_KYWD' was here
    /usr/include/iso/string_iso.h:90: error: storage class specified for parameter 'strncpy'
    /usr/include/iso/string_iso.h:91: error: storage class specified for parameter 'strspn'
    /usr/include/iso/string_iso.h:92: error: conflicting types for '_RESTRICT_KYWD'
    /usr/include/iso/string_iso.h:92: error: previous definition of '_RESTRICT_KYWD' was here
    /usr/include/iso/string_iso.h:92: error: storage class specified for parameter 'strtok'
    /usr/include/iso/string_iso.h:93: error: conflicting types for '_RESTRICT_KYWD'
    /usr/include/iso/string_iso.h:93: error: previous definition of '_RESTRICT_KYWD' was here
    /usr/include/iso/string_iso.h:93: error: storage class specified for parameter 'strxfrm'
    /usr/include/iso/string_iso.h:147: error: storage class specified for parameter 'memchr'
    /usr/include/iso/string_iso.h:148: error: storage class specified for parameter 'strchr'
    /usr/include/iso/string_iso.h:149: error: storage class specified for parameter 'strpbrk'
    /usr/include/iso/string_iso.h:150: error: storage class specified for parameter 'strrchr'
    /usr/include/iso/string_iso.h:151: error: storage class specified for parameter 'strstr'
    In file included from resource_vector_test.c:4:
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/string.h:72: error: storage class specified for parameter 'memccpy'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/string.h:77: error: storage class specified for parameter 'strsignal'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/string.h:78: error: storage class specified for parameter 'ffs'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/string.h:79: error: storage class specified for parameter 'strcasecmp'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/string.h:80: error: storage class specified for parameter 'strncasecmp'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/string.h:81: error: storage class specified for parameter 'strlcpy'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/string.h:82: error: storage class specified for parameter 'strlcat'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/string.h:88: error: storage class specified for parameter 'strdup'
    In file included from /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:27,
    from resource_vector_test.c:5:
    /usr/include/iso/stdlib_iso.h:55: error: storage class specified for parameter '__ctype'
    /usr/include/iso/stdlib_iso.h:69: error: storage class specified for parameter 'div_t'
    /usr/include/iso/stdlib_iso.h:74: error: storage class specified for parameter 'ldiv_t'
    /usr/include/iso/stdlib_iso.h:116: error: storage class specified for parameter 'wchar_t'
    /usr/include/iso/stdlib_iso.h:123: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__NORETURN'
    /usr/include/iso/stdlib_iso.h:124: error: storage class specified for parameter 'abs'
    /usr/include/iso/stdlib_iso.h:125: error: storage class specified for parameter 'atexit'
    /usr/include/iso/stdlib_iso.h:126: error: storage class specified for parameter 'atof'
    /usr/include/iso/stdlib_iso.h:127: error: storage class specified for parameter 'atoi'
    /usr/include/iso/stdlib_iso.h:128: error: storage class specified for parameter 'atol'
    /usr/include/iso/stdlib_iso.h:130: error: storage class specified for parameter 'bsearch'
    /usr/include/iso/stdlib_iso.h:137: error: storage class specified for parameter 'calloc'
    /usr/include/iso/stdlib_iso.h:138: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'div'
    /usr/include/iso/stdlib_iso.h:140: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__NORETURN'
    /usr/include/iso/stdlib_iso.h:141: error: storage class specified for parameter 'free'
    /usr/include/iso/stdlib_iso.h:142: error: storage class specified for parameter 'getenv'
    /usr/include/iso/stdlib_iso.h:143: error: storage class specified for parameter 'labs'
    /usr/include/iso/stdlib_iso.h:144: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'ldiv'
    /usr/include/iso/stdlib_iso.h:145: error: storage class specified for parameter 'malloc'
    /usr/include/iso/stdlib_iso.h:146: error: storage class specified for parameter 'mblen'
    /usr/include/iso/stdlib_iso.h:147: error: expected ')' before '*' token
    /usr/include/iso/stdlib_iso.h:149: error: expected ')' before '*' token
    /usr/include/iso/stdlib_iso.h:150: error: storage class specified for parameter 'qsort'
    /usr/include/iso/stdlib_iso.h:156: error: storage class specified for parameter 'rand'
    /usr/include/iso/stdlib_iso.h:157: error: storage class specified for parameter 'realloc'
    /usr/include/iso/stdlib_iso.h:158: error: storage class specified for parameter 'srand'
    /usr/include/iso/stdlib_iso.h:159: error: conflicting types for '_RESTRICT_KYWD'
    /usr/include/iso/stdlib_iso.h:159: error: previous definition of '_RESTRICT_KYWD' was here
    /usr/include/iso/stdlib_iso.h:159: error: storage class specified for parameter 'strtod'
    /usr/include/iso/stdlib_iso.h:160: error: conflicting types for '_RESTRICT_KYWD'
    /usr/include/iso/stdlib_iso.h:160: error: previous definition of '_RESTRICT_KYWD' was here
    /usr/include/iso/stdlib_iso.h:160: error: storage class specified for parameter 'strtol'
    /usr/include/iso/stdlib_iso.h:162: error: conflicting types for '_RESTRICT_KYWD'
    /usr/include/iso/stdlib_iso.h:161: error: previous definition of '_RESTRICT_KYWD' was here
    /usr/include/iso/stdlib_iso.h:162: error: storage class specified for parameter 'strtoul'
    /usr/include/iso/stdlib_iso.h:163: error: storage class specified for parameter 'system'
    /usr/include/iso/stdlib_iso.h:164: error: expected declaration specifiers or '...' before 'wchar_t'
    /usr/include/iso/stdlib_iso.h:164: error: storage class specified for parameter 'wctomb'
    /usr/include/iso/stdlib_iso.h:165: error: expected ';', ',' or ')' before '*' token
    In file included from resource_vector_test.c:5:
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:80: error: storage class specified for parameter 'lldiv_t'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:121: error: storage class specified for parameter '_exithandle'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:126: error: storage class specified for parameter 'drand48'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:127: error: storage class specified for parameter 'erand48'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:128: error: storage class specified for parameter 'jrand48'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:129: error: storage class specified for parameter 'lcong48'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:130: error: storage class specified for parameter 'lrand48'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:131: error: storage class specified for parameter 'mrand48'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:132: error: storage class specified for parameter 'nrand48'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:133: error: storage class specified for parameter 'seed48'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:134: error: storage class specified for parameter 'srand48'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:135: error: storage class specified for parameter 'putenv'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:136: error: storage class specified for parameter 'setkey'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:153: error: storage class specified for parameter 'swab'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:159: error: storage class specified for parameter 'mkstemp'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:164: error: storage class specified for parameter 'mkstemp64'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:170: error: storage class specified for parameter 'a64l'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:171: error: storage class specified for parameter 'ecvt'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:172: error: storage class specified for parameter 'fcvt'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:173: error: storage class specified for parameter 'gcvt'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:174: error: storage class specified for parameter 'getsubopt'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:175: error: storage class specified for parameter 'grantpt'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:176: error: storage class specified for parameter 'initstate'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:177: error: storage class specified for parameter 'l64a'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:178: error: storage class specified for parameter 'mktemp'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:179: error: storage class specified for parameter 'ptsname'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:180: error: storage class specified for parameter 'random'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:181: error: storage class specified for parameter 'realpath'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:182: error: storage class specified for parameter 'setstate'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:183: error: storage class specified for parameter 'srandom'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:184: error: storage class specified for parameter 'ttyslot'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:185: error: storage class specified for parameter 'unlockpt'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:186: error: storage class specified for parameter 'valloc'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:191: error: storage class specified for parameter 'dup2'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:192: error: storage class specified for parameter 'qecvt'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:193: error: storage class specified for parameter 'qfcvt'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:194: error: storage class specified for parameter 'qgcvt'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:195: error: storage class specified for parameter 'getcwd'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:195: error: redefinition of parameter 'getcwd'
    /usr/include/unistd.h:339: error: previous definition of 'getcwd' was here
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:196: error: storage class specified for parameter 'getexecname'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:197: error: storage class specified for parameter 'getlogin'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:197: error: redefinition of parameter 'getlogin'
    /usr/include/unistd.h:356: error: previous definition of 'getlogin' was here
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:198: error: storage class specified for parameter 'getopt'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:199: error: storage class specified for parameter 'optarg'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:200: error: storage class specified for parameter 'optind'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:200: error: storage class specified for parameter 'opterr'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:200: error: storage class specified for parameter 'optopt'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:201: error: storage class specified for parameter 'getpass'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:202: error: storage class specified for parameter 'getpassphrase'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:203: error: storage class specified for parameter 'getpw'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:204: error: storage class specified for parameter 'isatty'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:204: error: redefinition of parameter 'isatty'
    /usr/include/unistd.h:400: error: previous definition of 'isatty' was here
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:205: error: storage class specified for parameter 'memalign'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:206: error: storage class specified for parameter 'ttyname'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:206: error: redefinition of parameter 'ttyname'
    /usr/include/unistd.h:540: error: previous definition of 'ttyname' was here
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:209: error: storage class specified for parameter 'atoll'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:210: error: storage class specified for parameter 'llabs'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:211: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'lldiv'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:212: error: storage class specified for parameter 'lltostr'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:213: error: storage class specified for parameter 'strtoll'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:214: error: storage class specified for parameter 'strtoull'
    /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/stdlib.h:215: error: storage class specified for parameter 'ulltostr'
    In file included from resource_vector_test.c:7:
    /usr/include/sys/mman.h:162: error: storage class specified for parameter 'mmap'
    /usr/include/sys/mman.h:163: error: storage class specified for parameter 'munmap'
    /usr/include/sys/mman.h:164: error: storage class specified for parameter 'mprotect'
    /usr/include/sys/mman.h:165: error: storage class specified for parameter 'msync'
    /usr/include/sys/mman.h:166: error: storage class specified for parameter 'mlock'
    /usr/include/sys/mman.h:167: error: storage class specified for parameter 'munlock'
    /usr/include/sys/mman.h:168: error: storage class specified for parameter 'mincore'
    /usr/include/sys/mman.h:168: error: redefinition of parameter 'mincore'
    /usr/include/unistd.h:419: error: previous definition of 'mincore' was here
    /usr/include/sys/mman.h:169: error: storage class specified for parameter 'memcntl'
    /usr/include/sys/mman.h:170: error: storage class specified for parameter 'madvise'
    /usr/include/sys/mman.h:172: error: storage class specified for parameter 'getpagesizes'
    /usr/include/sys/mman.h:181: error: storage class specified for parameter 'mmap64'
    /usr/include/sys/mman.h:186: error: storage class specified for parameter 'mlockall'
    /usr/include/sys/mman.h:187: error: storage class specified for parameter 'munlockall'
    /usr/include/sys/mman.h:188: error: storage class specified for parameter 'shm_open'
    /usr/include/sys/mman.h:189: error: storage class specified for parameter 'shm_unlink'
    In file included from /usr/local/Gnu/Sol8/lib/gcc/sparc-sun-solaris2.8/4.2.1/include/sys/signal.h:28,
    from /usr/include/sys/procset.h:42,
    from /usr/include/sys/processor.h:39,
    from resource_vector_test.c:9:
    /usr/include/sys/iso/signal_iso.h:101: error: storage class specified for parameter '_sysconf'
    In file included from /usr/local/Gnu/Sol8/lib/gcc/sparc

    Hi again,
    I think I've solved the problem :)
    The problem was the version of gcc
    I've tried using the gcc shipped with solaris 10 in /usr/sfw
    and the problem get solved.

  • [Fwd: Client accessing MBeanHome for more than one domain receives SecurityException]

    Fwd'ing to security newsgroup
    -------- Original Message --------
    Subject: Client accessing MBeanHome for more than one domain receives
    SecurityException
    Date: 4 Mar 2004 07:27:33 -0800
    From: Dinesh Bhat <[email protected]>
    Reply-To: Dinesh Bhat <[email protected]>
    Organization: BEA NEWS SITE
    Newsgroups: weblogic.developer.interest.management
    Hi,
    When a client accesses MBeans of more than one domains (Weblogic 8.1)
    that have
    different passwords, it receives a SecurityException. This occurs when
    the MBeanHome
    for each domain is looked up at initialization and reused for each
    request ( to
    access MBeans ). The security exception does not occur if the MBeanHome
    for each
    domain is looked up for each request. On initial review, this behavoir
    seems inconsistent.
    Looking up the MBeanHome for each request may introduce a significant
    overhead.
    I am not sure if concurrent lookups would also cause the same problem.
    I have read on another post that we can work around this problem by
    establishing
    a trust relationship between the servers, but this may not be feasible
    when one
    is monitoring a lot of servers and the overhead of configuration may be
    an issue.
    I have attached code that can reproduce the problem.
    Please advise on the correct approach.
    Thanks
    Dinesh Bhat
    Panacya Inc.
    import java.util.ArrayList;
    import java.util.Set;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.Hashtable;
    import javax.management.MBeanServer;
    import javax.naming.Context;
    import weblogic.jndi.Environment;
    import weblogic.management.MBeanHome;
    * This class reproduces the Security Exception that is caused when a client tries to access
    * MBeans of more than one domain with different weblogic passwords. Here is the stacktrace of the
    * exception
    * java.lang.SecurityException: [Security:090398]Invalid Subject: principals=[weblogic, Administrators]
         at weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:108)
         at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:138)
         at weblogic.management.internal.AdminMBeanHomeImpl_811_WLStub.getDomainName(Unknown Source)
         at WLSecurityTest.getWeblogicInfo(WLSecurityTest.java:140)
         at WLSecurityTest.runTest(WLSecurityTest.java:75)
         at WLSecurityTest.<init>(WLSecurityTest.java:66)
         at WLSecurityTest.main(WLSecurityTest.java:51)
         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:324)
         at com.intellij.rt.execution.application.AppMain.main(Unknown Source)
    Caused by: java.lang.SecurityException: [Security:090398]Invalid Subject: principals=[weblogic, Administrators]
         at weblogic.security.service.SecurityServiceManager.seal(SecurityServiceManager.java:682)
         at weblogic.rjvm.MsgAbbrevInputStream.getSubject(MsgAbbrevInputStream.java:181)
         at weblogic.rmi.internal.BasicServerRef.acceptRequest(BasicServerRef.java:814)
         at weblogic.rmi.internal.BasicServerRef.dispatch(BasicServerRef.java:299)
         at weblogic.rjvm.RJVMImpl.dispatchRequest(RJVMImpl.java:920)
         at weblogic.rjvm.RJVMImpl.dispatch(RJVMImpl.java:841)
         at weblogic.rjvm.ConnectionManagerServer.handleRJVM(ConnectionManagerServer.java:222)
         at weblogic.rjvm.ConnectionManager.dispatch(ConnectionManager.java:794)
         at weblogic.rjvm.t3.T3JVMConnection.dispatch(T3JVMConnection.java:570)
         at weblogic.socket.NTSocketMuxer.processSockets(NTSocketMuxer.java:105)
         at weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:32)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
    * Note: the exception is caused only when the MBeanHome for each domain is cached and used for subsequent
    * transactions. The exception does not occur if the MBeanHome for each domain is looked up for each transaction. This
    * would significant overhead in practice. Also the transactions across the various domains occurs serially, hence
    * the effect of concurrent lookups has to be tested.
    * Usage:
    * This class has been tested with weblogic 8.1
    * The class needs weblogic.jar in its classpath
    * One can specify the weblogic details as System properties. The properties need to be specified in
    * the following format:
    * wls.host.n, wls.userId.n, wls.password.n where n is the weblogix instance number. Also specify
    * the boolean system property reconnect.each.iteration to toggle between reconnecting or not reconnecting
    * for each iteration. When not reconnecting for each iteration, the MBeanHome is reused and the Security Exception
    * occurs.
    * Following is the example of system properties
    * -Dwls.host.0=localhost:7001 -Dwls.userId.0=weblogic -Dwls.password.0=weblogic
    * -Dwls.host.1=localhost:7011 -Dwls.userId.1=weblogic -Dwls.password.1=weblogic1
    * -Dwls.host.2=localhost:7021 -Dwls.userId.2=weblogic -Dwls.password.2=weblogic2
    * -Dreconnect.each.iteration=false
    public class WLSecurityTest
    ArrayList wlsDetailsList = new ArrayList();
    HashMap connectionMap = new HashMap();
    public static void main(String[] args)
    try
    WLSecurityTest wlSecurityTest = new WLSecurityTest();
    catch (Exception e)
    e.printStackTrace();
    * Constructor
    * @throws Exception
    public WLSecurityTest() throws Exception
    int noOfTries = 10;
    getWLSDetails();
    for( int i=0; i <= noOfTries; i++)
    runTest();
    * Runs the test
    private void runTest()
    for (int i = 0; i < wlsDetailsList.size(); i++)
    WLSDetails wlsDetails = (WLSDetails) wlsDetailsList.get(i);
    getWeblogicInfo(wlsDetails);
    * Get Weblogic details from System properties
    * @throws Exception
    private void getWLSDetails() throws Exception
    wlsDetailsList = new ArrayList();
    String hostKeyTmpl = "wls.host";
    String userIdKeyTmpl = "wls.userId";
    String passwordKeyTmpl = "wls.password";
    boolean done = false;
    for (int i = 0; !done; i++)
    WLSDetails wlsDetails = new WLSDetails();
    String hostKey = hostKeyTmpl + "." + Integer.toString(i);
    String userIdKey = userIdKeyTmpl + "." + Integer.toString(i);
    String passwordKey = passwordKeyTmpl + "." + Integer.toString(i);
    wlsDetails.hostName = System.getProperty(hostKey);
    done = (wlsDetails.hostName == null) || (wlsDetails.hostName.length() == 0);
    if (!done)
    wlsDetails.userId = System.getProperty(userIdKey);
    wlsDetails.password = System.getProperty(passwordKey);
    connect(wlsDetails);
    wlsDetailsList.add(wlsDetails);
    * Lookup the MBeanHome for the specified weblogic server
    * @param wlsDetails
    * @throws Exception
    public synchronized void connect(WLSecurityTest.WLSDetails wlsDetails) throws Exception
    Context ctx = null;
    MBeanHome mbHomeLocal = null;
    try
    Environment env = new Environment();
    env.setProviderUrl("t3://" + wlsDetails.hostName);
    env.setSecurityPrincipal(wlsDetails.userId);
    env.setSecurityCredentials(wlsDetails.password);
    Hashtable hashtable = env.getProperties();
    System.out.println(hashtable.toString());
    ctx = env.getInitialContext();
    wlsDetails._mBeanHome = (MBeanHome) ctx.lookup(MBeanHome.ADMIN_JNDI_NAME);
    catch (Exception e)
    e.printStackTrace();
    * Gets weblogic information using MBeans
    * @param wlsDetails
    public synchronized void getWeblogicInfo(WLSDetails wlsDetails)
    try
    boolean reconnectEachIteration =
    Boolean.getBoolean("reconnect.each.iteration");
    if( (reconnectEachIteration) || ((wlsDetails._mBeanHome == null) && (!reconnectEachIteration) ))
    connect(wlsDetails);
    MBeanHome mbHomeLocal = wlsDetails._mBeanHome;
    String domainName = mbHomeLocal.getDomainName();
    Set allMBeans = mbHomeLocal.getAllMBeans();
    System.out.println("Size: " + allMBeans.size());
    Set clusterMBeans = mbHomeLocal.getMBeansByType("Cluster", domainName);
    System.out.println(clusterMBeans);
    MBeanServer mBeanServer = mbHomeLocal.getMBeanServer();
    catch (Exception ex)
    ex.printStackTrace();
    * Class that holds weblogic server details
    class WLSDetails
    String hostName = "";
    String userId = "";
    String password = "";
    MBeanHome _mBeanHome = null;

    If Server version is 61.
    Make user "system" password of all weblogic servers same.
    If Server version above 61(70,81)
    In the Security Advanced Settings un check generated credential and specify a common credentail for all the weblogic servers(domains).

  • Problem with access specifier and static???

    I've a question. I saw a code written for Sun's Java Tutorial. The program had three class methods and all of them start like this:
    static public void methodName1{
    static public void methodName2{
    and
    static public void main(String[] args){
    My question is why the keyword static was used first? Why not access specifier? I mean what's the reason behind it? Is there any difference between them?
    Thanks in advance.
    --DM

    The order doesn't matter. The programmer thought it was a good idea for some reason. I might be tempted to do it if I had static and instance methods with the same name or something like that.
    public static void myMethod() {
    public void myMethod() {
    or
    static public void myMethod() {
    public void myMethod() {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Need new access specifier

    I think there must be another access specifier that is like protected but not friendly, I mean only the supclasses can access that, not the classes in that package.
    Suppose a class that has private or friendly fields and I had to define another field of the same type for its subclass.
    Or I have a class with a protected field that I know I will use it if I want to define a subclass of it. But I don't want to let the other classes in thatpackage modify this field unintentionally.
    The problem is not only for fields. There are situations that I want to permit subclasses to call a method but I don't want other classes in the same package call it.

    there isn't.
    perhaps you need to think more about which classes sit in which packages ?
    maybe a better package structure would give you this control.

  • Regarding Protected access specifier

    Hi ,
    I thought that indeed you could access protected data member from another package IF you are using Inheritance. It makes the data memeber in question "friendly" to the derived class. At least that is my understanding.
    You can not access protected data element directly in different packages. package test1;
    public class Test123 {
    protected int x=42;
    package test2;
    import test1.Test123;
    public class Test234 extends test1.Test123{
         public static void main(String args[]){
              Test123 ob=new Test123();
              System.out.println("x="+ob.x);
    but My question is that ..if u run this program its not compile..Compile time exception is throws saying that the field Test123.x is not visible..but according to protected access specifier this will work...and one thing that if i make field ' x ' of Test123 as public it is working... How it is possible ...can anybody pls help it out.. Thanx in advance...

    This access is provided even to subclasses that reside in a different package from
    the class that owns the protected feature.As you have found this (and similar) can be confusing.
    Have a look at the Java Language Specification (http://java.sun.com/docs/books/jls/third_edition/html/names.html#6.6.7) "6.6.7 Example: protected Fields, Methods, and Constructors". Can you see the difference between the delta() and delta3d() methods?
    "A protected member or constructor of an object may be accessed from outside the package in which it is declared only by code that is responsible for the implementation of that object." As another example of this, the following compiles OKpackage test2;
    import test1.Test123;
    public class Test234 extends test1.Test123 {
        public static void main(String args[]) {
            Test234 ob = new Test234();
            System.out.println("x=" + ob.x);
    }When run it prints "42" - showing that the same d@mn field is being accessed! Like you, I'd appreciate hearing a simple rationale for this (if there is one).

Maybe you are looking for