2013年7月31日 星期三

Resolved: Glassfish4: Configuration Error: Secure Admin must be enabled to access the DAS remotely.

After started the Glassfish4 server, the following error message was shown in the screen.

Configuration Error: Secure Admin must be enabled to access the DAS remotely.


Solution:
For remote access, Glassfish does not allow admin account with empty password.

It could be fixed by following steps:
1. Change the password via command
    ./asadmin change-admin-password

2. Restart the Glassfish server
    ./admin stop-domain
    ./admin start-domain

3. Enable Secure admin via command
    ./asadmin enable-secure-admin 



Resolved: Glassfish4 in AWS Ubuntu: Couldn't get lock for /srv/glassfish4/glassfish/domains/domain1/logs/server.log

Failed to start Glassfish4 server on AWS Ubuntu and returns error message of:

Couldn't get lock for /srv/glassfish4/glassfish/domains/domain1/logs/server.log

Solution:
It is usually caused by the permission problem on the execution account.  Try to switch user as the owner of the glassfish and start it up again!

Error message

/srv/glassfish4/bin$ ./asadmin start-domain
java.io.IOException: Couldn't get lock for /srv/glassfish4/glassfish/domains/domain1/logs/server.log
        at java.util.logging.FileHandler.openFiles(FileHandler.java:389)
        at java.util.logging.FileHandler.<init>(FileHandler.java:287)
        at com.sun.enterprise.admin.launcher.GFLauncherLogger.addLogFileHandler(GFLauncherLogger.java:98)
        at com.sun.enterprise.admin.launcher.GFLauncher.setup(GFLauncher.java:191)
        at com.sun.enterprise.admin.servermgmt.cli.StartDomainCommand.createLauncher(StartDomainCommand.java:220)
        at com.sun.enterprise.admin.servermgmt.cli.StartDomainCommand.executeCommand(StartDomainCommand.java:117)
        at com.sun.enterprise.admin.cli.CLICommand.execute(CLICommand.java:321)
        at com.sun.enterprise.admin.cli.AdminMain.executeCommand(AdminMain.java:360)
        at com.sun.enterprise.admin.cli.AdminMain.doMain(AdminMain.java:298)
        at org.glassfish.admin.cli.AsadminMain.main(AsadminMain.java:56)
Waiting for domain1 to start .Error starting domain domain1.
The server exited prematurely with exit code 1.
Before it died, it produced the following output:

Launching GlassFish on Felix platform
Exception in thread "main" java.lang.RuntimeException: the domain directory is not writable.
        at com.sun.enterprise.glassfish.bootstrap.MainHelper.verifyDomainRoot(MainHelper.java:244)
        at com.sun.enterprise.glassfish.bootstrap.MainHelper.findInstanceRoot(MainHelper.java:347)
        at com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:78)
        at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:54)

Command start-domain failed.

Cannot resolve: AWS Linux AMI + Glassfish4 Command start-domain failed.

Tried to setup a Glassfish4 server on AWS Linux AMI but not succeed.



After searched Google, seems there is a bug in openjdk and it was fixed on the release java-1.7.0-openjdk-devel-1.7.0.25-2.3.10.4.

Installed command: sudo yum install java-1.7.0-openjdk-devel
Installed version: 1.7.0.25-2.3.10.3.29.amzn1


Running Glassfish server and results the following error:

WARNING: Skipping entry  because it is not an absolute URI.
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:97)
        at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:54)
Caused by: A MultiException has 8 exceptions.  They are:
1. java.lang.ExceptionInInitializerError
2. java.lang.IllegalStateException: Unable to perform operation: post construct on org.glassfish.server.ServerEnvironmentImpl
3. java.lang.NoClassDefFoundError: Could not initialize class com.sun.enterprise.util.net.NetUtils
4. java.lang.IllegalStateException: Unable to perform operation: post construct on org.glassfish.server.ServerEnvironmentImpl
5. java.lang.IllegalArgumentException: While attempting to resolve the dependencies of com.sun.enterprise.v3.server.DomainXmlPersistence errors were found
6. java.lang.IllegalStateException: Unable to perform operation: resolve on com.sun.enterprise.v3.server.DomainXmlPersistence
7. java.lang.IllegalArgumentException: While attempting to resolve the dependencies of com.sun.enterprise.v3.server.GFDomainXml errors were found
8. java.lang.IllegalStateException: Unable to perform operation: resolve on com.sun.enterprise.v3.server.GFDomainXml
....
Exception in thread "main" java.lang.reflect.InvocationTargetException 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:490) 
at com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:97) 
at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:54)
Caused by: java.lang.ExceptionInInitializerError
at org.glassfish.common.util.admin.ManagedFile.<clinit>(ManagedFile.java:90)
at com.sun.enterprise.v3.server.DomainXmlPersistence.getPidFile(DomainXmlPersistence.java:102)
at com.sun.enterprise.v3.server.DomainXmlPersistence.accessRead(DomainXmlPersistence.java:114)
at org.glassfish.config.support.DomainXml.parseDomainXml(DomainXml.java:255)
at org.glassfish.config.support.DomainXml.run(DomainXml.java:117)
at org.jvnet.hk2.config.ConfigurationPopulator.populateConfig(ConfigurationPopulator.java:58)
at org.glassfish.hk2.bootstrap.HK2Populator.populateConfig(HK2Populator.java:158)
at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.populateConfig(AbstractModulesRegistryImpl.java:211)
at com.sun.enterprise.module.bootstrap.Main.createServiceLocator(Main.java:273)
at org.jvnet.hk2.osgiadapter.HK2Main.createServiceLocator(HK2Main.java:120)
at com.sun.enterprise.glassfish.bootstrap.osgi.EmbeddedOSGiGlassFishRuntime.newGlassFish(EmbeddedOSGiGlassFishRuntime.java:95)
at com.sun.enterprise.glassfish.bootstrap.GlassFishRuntimeDecorator.newGlassFish(GlassFishRuntimeDecorator.java:68)
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishRuntime.newGlassFish(OSGiGlassFishRuntime.java:88)
at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher.launch(GlassFishMain.java:113)
... 6 more
Caused by: java.util.MissingResourceException: Can't find com.sun.enterprise.util.LogMessages bundle
at java.util.logging.Logger.setupResourceInfo(Logger.java:1676)
at java.util.logging.Logger.<init>(Logger.java:285)
at java.util.logging.LogManager.demandLogger(LogManager.java:443)
at java.util.logging.Logger.demandLogger(Logger.java:347)
at java.util.logging.Logger.getLogger(Logger.java:438)
at com.sun.enterprise.util.CULoggerInfo.<clinit>(CULoggerInfo.java:61)
... 20 more

2013年7月20日 星期六

Install Java 7 in AWS Linux

This article teaches you how to change the Java version to Java 7 in AWS Linus.

1. sudo yum install java-1.7.0-openjdk
2. sudo alternatives --config java




How to setup a AWS linux server

This tutorial teaches you how to create a linux instance in AWS.

1. Create Instance --> Launch Instance



2. Choose Classic

3. Select Amazon Linus AMI

4. Continue

5. Continue
6. Continue
7. Continue

8. Enter the name for the key and then click "Create & Download your Key Pair".  This is the key for the server access (e.g. ssh).  Please keep it in a safe place as you cannot change it / download it again from aws.

9. Enter the Name and Description for the Security Group

10. Click Launch

11. Done!