Hot questions for Using GlassFish in linux

Question:

In the below output I am being asked if I trust a certificate, which I was not asked about in Glassfish 4.0. If I answe yes, then it still fails which can be seen.

I am starting it with asadmin start-domain and then change the admin password to x in this test. I change the passowrd with asadmin --user admin change-admin-password and asadmin enable-secure-admin.

This is the error:

Do you trust the above certificate [y|N] -->y
Authentication failed for user: admin (Usually, this means invalid user name and/or password)
Command change-admin-password failed.

Question

Does anyone know why Glassfish 4.1 asks about this certificate and how I can make it work, as I can't login even though it ends with it was a success.

Waiting for domain1 to start .......
Successfully started the domain : domain1
domain  Location: /opt/glassfish4/glassfish/domains/domain1
Log File: /opt/glassfish4/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.
=> Modifying password of admin to preset in Glassfish
spawn asadmin --user admin change-admin-password
Enter the admin password> 
Enter the new admin password> 
Enter the new admin password again> 
[
[
  Version: V3
  Subject: CN=localhost, OU=GlassFish, O=Oracle Corporation, L=Santa Clara, ST=California, C=US
  Signature Algorithm: SHA256withRSA, OID = 1.2.840.113549.1.1.11

  Key:  Sun RSA public key, 2048 bits
  modulus: 19016962123073818913980587828837922486576420141613590721707437891327039833432551153803083906839156766507774007880420863368627703049499522525030078369904284618227297420407350669314980277911425446307700835083768858763078579295691981047129695516569551334653620772195238596206551972125661803284768176221481772121528672632308667324875827891801774801031021244005840124791813739105291627626830463412652100947239506418948577875286315103270404232934705194347849152036735770668664880970935638976368368387912487716546355239785885758256691359924727187516306879956018711242524702651771632411566014598382402754461656354400636380993
  public exponent: 65537
  Validity: [From: Thu Aug 21 13:30:10 UTC 2014,
               To: Sun Aug 18 13:30:10 UTC 2024]
  Issuer: CN=localhost, OU=GlassFish, O=Oracle Corporation, L=Santa Clara, ST=California, C=US
  SerialNumber: [    31eb8d9f]

Certificate Extensions: 1
[1]: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: 13 55 DB 7D A9 31 71 A3   33 40 56 D3 49 A9 77 42  .U...1q.3@V.I.wB
0010: 90 A3 59 39                                        ..Y9
]
]

]
  Algorithm: [SHA256withRSA]
  Signature:
0000: 07 E5 F1 96 38 CE 55 33   1C 65 A5 5A 38 90 EB 98  ....8.U3.e.Z8...
0010: 59 A1 AE 19 5F BF 5F 53   BE CF 36 54 2F 03 5D 5E  Y..._._S..6T/.]^
0020: 9D 21 3C DC CC C9 A1 5E   E0 0B 71 31 36 CE 3A DB  .!<....^..q16.:.
0030: BB 78 40 ED 5B FB 0A F0   E6 01 5A C3 29 CD 0B E1  .x@.[.....Z.)...
0040: A1 0D A9 99 ED D8 28 78   DA 1B 2F 15 25 46 85 D8  ......(x../.%F..
0050: B3 8F E7 79 0F EF 37 6A   55 06 E0 2D 0C 67 F3 60  ...y..7jU..-.g.`
0060: 46 AB C2 F5 AC 70 5E 9F   3C EF E3 33 61 34 C4 F9  F....p^.<..3a4..
0070: CB 5A 83 10 82 E5 DA F3   15 1D 28 B2 F9 DE 53 F0  .Z........(...S.
0080: 10 72 79 48 BA B4 AC EC   49 16 92 D8 A6 48 B5 A7  .ryH....I....H..
0090: 3A 6F 37 15 02 F4 66 66   94 8C 82 2C 57 7A 45 04  :o7...ff...,WzE.
00A0: 33 31 F6 9B 7C 6A 04 B0   0A 01 8E 8E B9 31 9E 9A  31...j.......1..
00B0: AC 53 F7 CB 38 F6 E5 DB   86 FF F2 D8 39 77 34 47  .S..8.......9w4G
00C0: 5F 7F EC F3 37 79 08 EB   59 B5 90 3F D9 7E E8 70  _...7y..Y..?...p
00D0: C3 F4 DD 17 EC B4 19 D0   08 26 7E CB 64 46 17 B8  .........&..dF..
00E0: 08 D8 A7 99 1E CF F1 2B   79 86 F1 22 6F C4 05 94  .......+y.."o...
00F0: E1 4F E1 64 E4 F0 47 8D   95 95 08 4F FE F9 60 E4  .O.d..G....O..`.

]
Do you trust the above certificate [y|N] -->y
Authentication failed for user: admin (Usually, this means invalid user name and/or password)
Command change-admin-password failed.
=> Enabling secure admin login
spawn asadmin enable-secure-admin
Enter admin user name>  admin
Enter admin password for user "admin"> 
Authentication failed for user: admin
(Usually, this means invalid user name and/or password)
Command enable-secure-admin failed.
=> Done!
========================================================================
You can now connect to this Glassfish server using:

     admin:x

Please remember to change the above password as soon as possible!
========================================================================
=> Restarting Glassfish server
Waiting for the domain to stop .
Command stop-domain executed successfully.
=> Starting and running Glassfish server

Answer:

  Subject: CN=localhost, OU=GlassFish, O=Oracle Corporation, L=Santa Clara, ST=California, C=US
  ...
  Issuer: CN=localhost, OU=GlassFish, O=Oracle Corporation, L=Santa Clara, ST=California, C=US

Its a self signed certificate. You have to establish trust for it. Load it in a trust store.

When using Chrome, you can't just load it in a trust store. The certificate must be signed by a CA. Its OK to create your own CA to do it, but it must be signed by an authority.

  Version: V3
  Subject: CN=localhost, OU=GlassFish, O=Oracle Corporation, L=Santa Clara, ST=California, C=US
  Signature Algorithm: SHA256withRSA, OID = 1.2.840.113549.1.1.11
  ...

Don't put DNS names like localhost in the Common Name (CN). Its deprecated by both the IETF and CA/Browser Forums. Instead, put a friendly name like "Oracle Corporation" in the CN. You put a friendly name there because its displayed to the user.

Do put DNS names in the Subject Alternate Name (SAN). Both the IETF and CA/Browser Forums specify DNS names go in the SAN.

Chrome is the most strict when it comes to accepting certificates. I believe the latest Java is similar. If you are using Chrome and you put a DNS name in the CN, then you must put the same DNS name in the SAN. So there's no way to avoid putting a DNS name in the SAN.

Chrome does not allow self-signed certificates. It requires the server's certificate be signed by a CA (i.e., it cannot be self signed). Its OK to sign with a private CA not preloaded in the public CA Zoo. Just add the CA to your browser. Or get the server certificate signed by a CA Cartel member (Startcom offers free Class 1 certificates).

Question:

I have developed a JavaEE 7.0 Web Application using NetBeans (IDE) and GlassFish 4.1.0 (web server).

The application is working like a charm when I deploy it on the localhost. Now, I would like to deploy it on a Red Hat Linux Server using GlassFish. I am very little experienced regarding Linux Servers deployment. Therefore, I looked for some tutorials on the internet. I found a lot of them for Apache Tomcat deployment but none for GlassFish.

Do you have an idea of how to deploy a JavaEE 7.0 Web Application on a Red Hat Linux Server using GlassFish, please ?

Thank you so much for your help.


Answer:

GlassFish offers an admin console GUI, which by default is available at https://example.com:4848

The GUI allows to upload, deploy and manage web applications.

See: how to deploy war file to Glassfish?

Question:

We are needing to set a system variable that our application can read that is being ran within Glassfish 4. The application is currently accessing the system variable with System.getenv().

We set an a system environment property in Windows like this:

App_Home=/opt/app/config

I have tried adding it to glassfish/glassfish4/config/asenv.conf but that didn't seem to work. I have done a bunch of searching and everything I keep running back into is setting a java property (e.g. this How to set an env variable in Glassfish 2.1). I am wanting to access the system property not a java property.

I have also tried setting the "System Properties" in the glassfish administration console under "Server (Admin Server) --> Properties --> System Properties" clicked "Add Property" and added my environment variable. However, the application still doesn't find it using System.getenv().


Answer:

I was able to use Service Environment= option in my services file to resolve this.

Simply adding the following worked:

Environment="App_Home=..."
Environment="PYTHONPATH=..."

Question:

I am getting the below error. Any help will be appreciated.

$ sudo glassfish4/glassfish/bin/asadmin start-domain Waiting for domain1 to start ..................Error starting domain domain1. The server exited prematurely with exit code 0. Before it died, it produced the following output:

Launching GlassFish on Felix platform Registered com.sun.enterprise.glassfish.bootstrap.osgi.EmbeddedOSGiGlassFishRuntime@72d53ac7 in service registry. Found populator: com.sun.enterprise.v3.server.GFDomainXml



#!## LogManagerService.postConstruct : rootFolder=/srv/glassfish4/glassfish
#!## LogManagerService.postConstruct : templateDir=/srv/glassfish4/glassfish/lib/templates
#!## LogManagerService.postConstruct : src=/srv/glassfish4/glassfish/lib/templates/logging.properties
#!## LogManagerService.postConstruct : dest=/srv/glassfish4/glassfish/domains/domain1/config/logging.properties Completed shutdown of Log manager service Completed shutdown of GlassFish runtime Watcher for /srv/glassfish4/glassfish/domains/domain1/autodeploy/bundles exiting because of interruption.: java.lang.InterruptedException java.lang.InterruptedException  at java.lang.Object.wait(Native Method)     at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:226) Oct 27, 2014 8:57:08 PM com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner createBundleProvisioner INFO: Create bundle provisioner class = class com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner. Oct 27, 2014 8:57:08 PM com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner$DefaultCustomizer getLocations WARNING: Skipping entry  because it is not an absolute URI. Oct 27, 2014 8:57:08 PM com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner$DefaultCustomizer getLocations WARNING: Skipping entry  because it is not an absolute URI. [#|2014-10-27T20:57:15.978-0700|INFO|glassfish
4.1|javax.enterprise.logging|_ThreadID=15;_ThreadName=RunLevelControllerThread-1414468635292;_TimeMillis=1414468635978;_LevelValue=800;_MessageID=NCLS-LOGGING-00009;| Running GlassFish Version: GlassFish Server Open Source Edition  4.1  (build 13)|#]

[#|2014-10-27T20:57:15.989-0700|INFO|glassfish
4.1|javax.enterprise.logging|_ThreadID=15;_ThreadName=RunLevelControllerThread-1414468635292;_TimeMillis=1414468635989;_LevelValue=800;_MessageID=NCLS-LOGGING-00010;| Server log file is using Formatter class: com.sun.enterprise.server.logging.ODLLogFormatter|#]

[#|2014-10-27T20:57:17.173-0700|INFO|glassfish
4.1|org.hibernate.validator.internal.util.Version|_ThreadID=15;_ThreadName=RunLevelControllerThread-1414468635292;_TimeMillis=1414468637173;_LevelValue=800;| HV000001: Hibernate Validator 5.0.0.Final|#]

[#|2014-10-27T20:57:17.266-0700|INFO|glassfish
4.1|javax.enterprise.system.core.security|_ThreadID=14;_ThreadName=RunLevelControllerThread-1414468635273;_TimeMillis=1414468637266;_LevelValue=800;_MessageID=NCLS-SECURITY-01115;| Realm [admin-realm] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.|#]

[#|2014-10-27T20:57:17.320-0700|INFO|glassfish
4.1|javax.enterprise.system.core.security|_ThreadID=14;_ThreadName=RunLevelControllerThread-1414468635273;_TimeMillis=1414468637320;_LevelValue=800;_MessageID=NCLS-SECURITY-01115;| Realm [file] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.|#]

[#|2014-10-27T20:57:17.473-0700|INFO|glassfish
4.1|javax.enterprise.system.core.security|_ThreadID=14;_ThreadName=RunLevelControllerThread-1414468635273;_TimeMillis=1414468637473;_LevelValue=800;_MessageID=NCLS-SECURITY-01115;| Realm [certificate] of classtype [com.sun.enterprise.security.auth.realm.certificate.CertificateRealm] successfully created.|#]

[#|2014-10-27T20:57:17.954-0700|INFO|glassfish
4.1|org.glassfish.ha.store.spi.BackingStoreFactoryRegistry|_ThreadID=17;_ThreadName=RunLevelControllerThread-1414468635378;_TimeMillis=1414468637954;_LevelValue=800;| Registered org.glassfish.ha.store.adapter.cache.ShoalBackingStoreProxy for persistence-type = replicated in BackingStoreFactoryRegistry|#]

[#|2014-10-27T20:57:18.164-0700|INFO|glassfish
4.1|javax.enterprise.security.services|_ThreadID=14;_ThreadName=RunLevelControllerThread-1414468635273;_TimeMillis=1414468638164;_LevelValue=800;_MessageID=SEC-SVCS-00100;| Authorization Service has successfully initialized.|#]

[#|2014-10-27T20:57:18.406-0700|INFO|glassfish
4.1|javax.enterprise.system.core|_ThreadID=16;_ThreadName=RunLevelControllerThread-1414468635370;_TimeMillis=1414468638406;_LevelValue=800;_MessageID=NCLS-CORE-00087;|   Grizzly Framework 2.3.15 started in: 113ms - bound to [/0.0.0.0:8181]|#]

[#|2014-10-27T20:57:18.982-0700|INFO|glassfish
4.1|javax.enterprise.system.core|_ThreadID=16;_ThreadName=RunLevelControllerThread-1414468635370;_TimeMillis=1414468638982;_LevelValue=800;_MessageID=NCLS-CORE-00087;|   Grizzly Framework 2.3.15 started in: 129ms - bound to [/0.0.0.0:4848]|#]

[#|2014-10-27T20:57:19.308-0700|INFO|glassfish
4.1|javax.enterprise.system.core|_ThreadID=17;_ThreadName=RunLevelControllerThread-1414468635378;_TimeMillis=1414468639308;_LevelValue=800;_MessageID=NCLS-CORE-00087;|   Grizzly Framework 2.3.15 started in: 11ms - bound to [/0.0.0.0:3700]|#]

[#|2014-10-27T20:57:20.181-0700|INFO|glassfish
4.1|javax.enterprise.system.core|_ThreadID=1;_ThreadName=main;_TimeMillis=1414468640181;_LevelValue=800;_MessageID=NCLS-CORE-00017;|   GlassFish Server Open Source Edition  4.1  (13) startup time : Felix (9,542ms), startup services(4,931ms), total(14,473ms)|#]

[#|2014-10-27T20:57:20.183-0700|SEVERE|glassfish
4.1|javax.enterprise.system.core|_ThreadID=1;_ThreadName=main;_TimeMillis=1414468640183;_LevelValue=1000;_MessageID=NCLS-CORE-00019;| Shutting down server due to startup exception java.net.BindException: Address already in use  at sun.nio.ch.Net.bind0(Native Method)  at sun.nio.ch.Net.bind(Net.java:444)    at sun.nio.ch.Net.bind(Net.java:436)    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)     at org.glassfish.grizzly.nio.transport.TCPNIOBindingHandler.bindToChannelAndAddress(TCPNIOBindingHandler.java:132)  at org.glassfish.grizzly.nio.transport.TCPNIOBindingHandler.bind(TCPNIOBindingHandler.java:88)  at org.glassfish.grizzly.nio.transport.TCPNIOTransport.bind(TCPNIOTransport.java:236)   at org.glassfish.grizzly.nio.transport.TCPNIOTransport.bind(TCPNIOTransport.java:225)   at org.glassfish.grizzly.nio.transport.TCPNIOTransport.bind(TCPNIOTransport.java:85)    at org.glassfish.grizzly.config.GenericGrizzlyListener.start(GenericGrizzlyListener.java:180)   at com.sun.enterprise.v3.services.impl.GlassfishNetworkListener.start(GlassfishNetworkListener.java:109)    at com.sun.enterprise.v3.services.impl.GrizzlyProxy.start0(GrizzlyProxy.java:267)   at com.sun.enterprise.v3.services.impl.GrizzlyProxy.start(GrizzlyProxy.java:241)    at com.sun.enterprise.v3.services.impl.GrizzlyService.createNetworkProxy(GrizzlyService.java:567)   at com.sun.enterprise.v3.services.impl.GrizzlyService.postConstruct(GrizzlyService.java:490)    at org.jvnet.hk2.internal.ClazzCreator.postConstructMe(ClazzCreator.java:329)   at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:377)    at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:461)    at org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext.findOrCreate(AsyncRunLevelContext.java:227)     at org.glassfish.hk2.runlevel.RunLevelContext.findOrCreate(RunLevelContext.java:84)     at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2258)  at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:105)  at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:87)   at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.oneJob(CurrentTaskFuture.java:1162)    at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.run(CurrentTaskFuture.java:1147)   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  at java.lang.Thread.run(Thread.java:745) |#]

[#|2014-10-27T20:57:20.481-0700|INFO|glassfish
4.1|javax.enterprise.system.core|_ThreadID=55;_ThreadName=Thread-11;_TimeMillis=1414468640481;_LevelValue=800;_MessageID=NCLS-CORE-00092;|   Server shutdown initiated|#]

[#|2014-10-27T20:57:20.498-0700|INFO|glassfish
4.1|javax.enterprise.bootstrap|_ThreadID=1;_ThreadName=main;_TimeMillis=1414468640498;_LevelValue=800;_MessageID=NCLS-BOOTSTRAP-00027;| Registered com.sun.enterprise.glassfish.bootstrap.osgi.EmbeddedOSGiGlassFishImpl@2c3b2e73 as OSGi service registration: org.apache.felix.framework.ServiceRegistrationImpl@290bdbae.|#]

[#|2014-10-27T20:57:21.488-0700|INFO|glassfish
4.1|javax.enterprise.bootstrap|_ThreadID=55;_ThreadName=Thread-11;_TimeMillis=1414468641488;_LevelValue=800;_MessageID=NCLS-BOOTSTRAP-00028;| Unregistered com.sun.enterprise.glassfish.bootstrap.osgi.EmbeddedOSGiGlassFishImpl@2c3b2e73 from service registry.|#]

[#|2014-10-27T20:57:21.503-0700|INFO|glassfish
4.1||_ThreadID=55;_ThreadName=Thread-8;_TimeMillis=1414468641503;_LevelValue=800;| FileMonitoring shutdown|#]

[#|2014-10-27T20:57:21.904-0700|INFO|glassfish
4.1|javax.enterprise.system.core|_ThreadID=55;_ThreadName=Thread-11;_TimeMillis=1414468641904;_LevelValue=800;_MessageID=NCLS-CORE-00013;|   Shutdown procedure finished|#]


Command start-domain failed

Answer:

The important line in the error log is this:

java.net.BindException: Address already in use at sun.nio.ch.Net.bind0

This is most likely due to there already being another service (Apache, an old Tomcat installation, etc) using GlassFish's default port of 8080. The port that GlassFish uses can be changed by following the instructions here.

Furthermore, to find out what is already using GlassFish's port so you can stop the service if necessary, use this for Windows and this for Linux.

Question:

I am new at both linux and glassfish, I am trying to deploy this .war project I made in Eclipse Kepler. But I get the following error while deploying:

Error occurred during deployment: Exception while loading the app : java.lang.ArrayIndexOutOfBoundsException: 3. Please see server.log for more details.

Then I go to server log and I find the following:-

[#|2015-06-01T14:04:02.926+0200|SEVERE|glassfish3.1.2|javax.enterprise.system.ssl.security.com.sun.enterprise.security.ssl.impl|_ThreadID=22;_ThreadName=Thread-2;|SEC5054: Certificate has expired: [
[
  Version: V3
  Subject: CN=GTE CyberTrust Root 5, OU="GTE CyberTrust Solutions, Inc.", O=GTE Corporation, C=US
  Signature Algorithm: SHA1withRSA, OID = 1.2.840.113549.1.1.5

  Key:  Sun RSA public key, 2048 bits
  modulus: 23741889829347261660812437366387754385443431973861114865490414153884050331745811968523116847625570146592736935209718565296053386842135985534863157983128812774162998053673746470782252407673402238146869994438729551246768368782318393878374421033907597162218758024581735139682087126982809511479059100617027892880227587855877479432885604404402435662802390484099065871430585284534529627347717530352189612077130606642676951640071336717026459037542552927905851171460589361570392199748753414855675665635003335769915908187224347232807336022456537328962095005323382940080676931822787496212635993279098588863972868266229522169377
  public exponent: 65537
  Validity: [From: Fri Aug 14 16:50:00 CEST 1998,
               To: Thu Aug 15 01:59:00 CEST 2013]
  Issuer: CN=GTE CyberTrust Root 5, OU="GTE CyberTrust Solutions, Inc.", O=GTE Corporation, C=US
  SerialNumber: [    01b6]

Certificate Extensions: 4
[1]: ObjectId: 2.5.29.19 Criticality=true
BasicConstraints:[
  CA:true
  PathLen:5
]

[2]: ObjectId: 2.5.29.32 Criticality=false
CertificatePolicies [
  [CertificatePolicyId: [1.2.840.113763.1.2.1.3]
[]  ]
]

[3]: ObjectId: 2.5.29.15 Criticality=true
KeyUsage [
  Key_CertSign
  Crl_Sign
]

[4]: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: 76 0A 49 21 38 4C 9F DE   F8 C4 49 C7 71 71 91 9D  v.I!8L....I.qq..
]
]

]
  Algorithm: [SHA1withRSA]
  Signature:
0000: 41 3A D4 18 5B DA B8 DE   21 1C E1 8E 09 E5 F1 68  A:..[...!......h
0010: 34 FF DE 96 F4 07 F5 A7   3C F3 AC 4A B1 9B FA 92  4.......<..J....
0020: FA 9B ED E6 32 21 AA 4A   76 C5 DC 4F 38 E5 DF D5  ....2!.Jv..O8...
0030: 86 E4 D5 C8 76 7D 98 D7   B1 CD 8F 4D B5 91 23 6C  ....v......M..#l
0040: 8B 8A EB EA 7C EF 14 94   C4 C6 F0 1F 4A 2D 32 71  ............J-2q
0050: 63 2B 63 91 26 02 09 B6   80 1D ED E2 CC B8 7F DB  c+c.&...........
0060: 87 63 C8 E1 D0 6C 26 B1   35 1D 40 66 10 1B CD 95  .c...l&.5.@f....
0070: 54 18 33 61 EC 13 4F DA   13 F7 99 AF 3E D0 CF 8E  T.3a..O.....>...
0080: A6 72 A2 B3 C3 05 9A C9   27 7D 92 CC 7E 52 8D B3  .r......'....R..
0090: AB 70 6D 9E 89 9F 4D EB   1A 75 C2 98 AA D5 02 16  .pm...M..u......
00A0: D7 0C 8A BF 25 E4 EB 2D   BC 98 E9 58 38 19 7C B9  ....%..-...X8...
00B0: 37 FE DB E2 99 08 73 06   C7 97 83 6A 7D 10 01 2F  7.....s....j.../
00C0: 32 B9 17 05 4A 65 E6 2F   CE BE 5E 53 A6 82 E9 9A  2...Je./..^S....
00D0: 53 0A 84 74 2D 83 CA C8   94 16 76 5F 94 61 28 F0  S..t-.....v_.a(.
00E0: 85 A7 39 BB D7 8B D9 A8   B2 13 1D 54 09 34 24 7D  ..9........T.4$.
00F0: 20 81 7D 66 7E A2 90 74   5C 10 C6 BD EC AB 1B C2   ..f...t\.......

]|#]

[#|2015-06-01T14:04:02.934+0200|INFO|glassfish3.1.2|org.glassfish.admingui|_ThreadID=22;_ThreadName=Thread-2;|Redirecting to /common/applications/uploadFrame.jsf?form:title2:bottomButtons:uploadButton=Processing...&bare=false|#]

[#|2015-06-01T14:04:02.994+0200|INFO|glassfish3.1.2|org.glassfish.admingui|_ThreadID=24;_ThreadName=Thread-2;|Admin Console: Initializing Session Attributes...|#]

[#|2015-06-01T14:04:23.003+0200|WARNING|glassfish3.1.2|org.apache.catalina.connector.Request|_ThreadID=23;_ThreadName=Thread-2;|PWC4011: Unable to set request character encoding to UTF-8 from context , because request parameters have already been read, or ServletRequest.getReader() has already been called|#]

[#|2015-06-01T14:04:23.056+0200|INFO|glassfish3.1.2|org.glassfish.admingui|_ThreadID=23;_ThreadName=Thread-2;|GUI deployment: uploadToTempfile|#]

[#|2015-06-01T14:04:23.057+0200|INFO|glassfish3.1.2|org.glassfish.admingui|_ThreadID=23;_ThreadName=Thread-2;|uploadFileName=CompactSpring.war|#]

[#|2015-06-01T14:04:34.120+0200|SEVERE|glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=22;_ThreadName=Thread-2;|Exception while loading the app|#]

[#|2015-06-01T14:04:34.363+0200|SEVERE|glassfish3.1.2|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=22;_ThreadName=Thread-2;|Exception while loading the app : java.lang.ArrayIndexOutOfBoundsException: 3
com.google.common.collect.ComputationException: java.lang.ArrayIndexOutOfBoundsException: 3
    at com.google.common.collect.ComputingConcurrentHashMap.compute(ComputingConcurrentHashMap.java:218)
    at com.google.common.collect.ComputingConcurrentHashMap.apply(ComputingConcurrentHashMap.java:100)
    at com.google.common.collect.MapMaker$ComputingMapAdapter.get(MapMaker.java:515)
    at org.jboss.weld.resources.ClassTransformer.loadClass(ClassTransformer.java:149)
    at org.jboss.weld.introspector.jlr.WeldClassImpl.<init>(WeldClassImpl.java:139)
    at org.jboss.weld.introspector.jlr.WeldClassImpl.of(WeldClassImpl.java:118)
    at org.jboss.weld.resources.ClassTransformer$TransformTypeToWeldClass.apply(ClassTransformer.java:49)
    at org.jboss.weld.resources.ClassTransformer$TransformTypeToWeldClass.apply(ClassTransformer.java:40)
    at com.google.common.collect.ComputingConcurrentHashMap.compute(ComputingConcurrentHashMap.java:206)
    at com.google.common.collect.ComputingConcurrentHashMap.apply(ComputingConcurrentHashMap.java:100)
    at com.google.common.collect.MapMaker$ComputingMapAdapter.get(MapMaker.java:515)
    at org.jboss.weld.resources.ClassTransformer.loadClass(ClassTransformer.java:149)
    at org.jboss.weld.introspector.jlr.WeldClassImpl.<init>(WeldClassImpl.java:139)
    at org.jboss.weld.introspector.jlr.WeldClassImpl.of(WeldClassImpl.java:118)
    at org.jboss.weld.resources.ClassTransformer$TransformTypeToWeldClass.apply(ClassTransformer.java:49)
    at org.jboss.weld.resources.ClassTransformer$TransformTypeToWeldClass.apply(ClassTransformer.java:40)
    at com.google.common.collect.ComputingConcurrentHashMap.compute(ComputingConcurrentHashMap.java:206)
    at com.google.common.collect.ComputingConcurrentHashMap.apply(ComputingConcurrentHashMap.java:100)
    at com.google.common.collect.MapMaker$ComputingMapAdapter.get(MapMaker.java:515)
    at org.jboss.weld.resources.ClassTransformer.loadClass(ClassTransformer.java:149)
    at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:86)
    at org.jboss.weld.bootstrap.BeanDeployer.addClasses(BeanDeployer.java:115)
    at org.jboss.weld.bootstrap.BeanDeployment.createBeans(BeanDeployment.java:171)
    at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:336)
    at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:179)
    at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:128)
    at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:277)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:460)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
    at org.glassfish.admin.rest.ResourceUtil.runCommand(ResourceUtil.java:214)
    at org.glassfish.admin.rest.ResourceUtil.runCommand(ResourceUtil.java:207)
    at org.glassfish.admin.rest.resources.TemplateListOfResource.createResource(TemplateListOfResource.java:148)
    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:622)
    at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
    at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
    at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
    at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
    at com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:134)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
    at com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:134)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
    at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
    at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
    at com.sun.jersey.server.impl.container.grizzly.GrizzlyContainer._service(GrizzlyContainer.java:182)
    at com.sun.jersey.server.impl.container.grizzly.GrizzlyContainer.service(GrizzlyContainer.java:147)
    at org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:148)
    at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
    at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:701)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 3
    at org.jboss.weld.introspector.jlr.WeldConstructorImpl.<init>(WeldConstructorImpl.java:103)
    at org.jboss.weld.introspector.jlr.WeldConstructorImpl.of(WeldConstructorImpl.java:66)
    at org.jboss.weld.introspector.jlr.WeldClassImpl.<init>(WeldClassImpl.java:205)
    at org.jboss.weld.introspector.jlr.WeldClassImpl.of(WeldClassImpl.java:118)
    at org.jboss.weld.resources.ClassTransformer$TransformTypeToWeldClass.apply(ClassTransformer.java:49)
    at org.jboss.weld.resources.ClassTransformer$TransformTypeToWeldClass.apply(ClassTransformer.java:40)
    at com.google.common.collect.ComputingConcurrentHashMap.compute(ComputingConcurrentHashMap.java:206)
    ... 78 more
|#]

[#|2015-06-01T14:04:34.401+0200|INFO|glassfish3.1.2|org.glassfish.admingui|_ThreadID=23;_ThreadName=Thread-2;|Exception Occurred :Error occurred during deployment: Exception while loading the app : java.lang.ArrayIndexOutOfBoundsException: 3. Please see server.log for more details.|#]

I dont understand why the 'ArrayIndexOutOfBoundsException: 3' is appearing because this error doesn't exist when I debug the project in eclipse.

EDIT1: As requested here is the pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>rs.fispace</groupId>
    <artifactId>trace</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>core</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <postgresql-version>9.2-1003-jdbc4</postgresql-version>
        <spring-release-version>4.1.6.RELEASE</spring-release-version>
        <log4j-release-version>2.1</log4j-release-version>
        <junit-release-version>4.12</junit-release-version>
        <springsecurity.version>3.2.5.RELEASE</springsecurity.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit-release-version}</version>
            <scope>test</scope>
        </dependency>

        <!-- postgresql database driver -->
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>${postgresql-version}</version>
        </dependency>

        <!-- Spring framework -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring-release-version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${spring-release-version}</version>
        </dependency>

        <!-- Spring security -->
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>${springsecurity.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>${springsecurity.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-taglibs</artifactId>
            <version>${springsecurity.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>${log4j-release-version}</version>
        </dependency>

        <!-- hibernate-validator -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>5.1.3.Final</version>
        </dependency>

        <!-- MySQL Connector -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.6</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <!-- or whatever version you use -->
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.18.1</version>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

And here is the other pom.xml (I wanst sure which one to post here):

    <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>eu.fispace.apps</groupId>
    <artifactId>CompactSpring</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <build>
        <plugins>
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <configuration>
                    <scanIntervalSeconds>10</scanIntervalSeconds>
                    <webApp>
                        <descriptor>src/main/webapp/WEB-INF/web.xml</descriptor>
                        <contextPath>/fispace-app-compact</contextPath>
                        <extraClasspath>target/classes</extraClasspath>

                    </webApp>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <properties>
        <spring.version>4.1.6.RELEASE</spring.version>
        <jstl.version>1.2</jstl.version>
        <log4j.version>1.2.17</log4j.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <jdk.version>1.8</jdk.version>
        <apache-tiles.version>3.0.5</apache-tiles.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.4</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>eu.fispace</groupId>
            <artifactId>api</artifactId>
            <version>0.15.0-S1513</version>
        </dependency>
        <dependency>
            <groupId>eu.limetri.ygg</groupId>
            <artifactId>ygg-client</artifactId>
            <version>0.17</version>
        </dependency>

        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-servlet-oauth-client</artifactId>
            <version>1.1.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-adapter-core</artifactId>
            <version>1.1.0.Final</version>
        </dependency>

        <dependency>
            <groupId>eu.limetri.ygg</groupId>
            <artifactId>ygg-auth-keycloak</artifactId>
            <version>0.17</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
            <version>1.17.1</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-core</artifactId>
            <version>1.17.1</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-servlet</artifactId>
            <version>1.17.1</version>
        </dependency>
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>4.1.6.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>4.1.6.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>4.1.6.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>4.1.6.RELEASE</version>
        </dependency>

        <!-- hibernate-validator -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>5.1.3.Final</version>
        </dependency>

        <!-- MySQL Connector -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.6</version>
        </dependency>

        <dependency>
            <groupId>rs.fispace</groupId>
            <artifactId>trace</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
    </dependencies>
</project>

Answer:

The Exceptions concerning "Certificate has expired" on startup in Glassfish 3.x should not affect your code. Except if you are going to use this invalid SSL certificates.

The reason for this exceptions is, that the certificate keystore of Glassfish contains expired SSL certificates. In my case I just got rid of them an now the errors are gone.

To remove them, you just have to navigate - using commandline - to the Glassfish directory where the file cacerts.jks is located (for example glassfish/domains/domain1/config/. There you execute the following statement:

/opt/jre/bin/keytool -delete -alias gtecybertrust5ca -keystore cacerts.jks -storepass changeit

Note that '/opt/jre/bin/keytool' could be an alternative path, it depends on where your Java installation is located.

After that, you need to restart Glassfish and the certificate errors should be gone.

Question:

I am trying to install Glassfish 4.0 on a Linux Red Hat Entreprise Linux release 5.11 (Tikanga) Server.

Therefore, I successfully installed Java jdk1.7.0_79 and NetBeans 4.0 on this server following this website instructions: https://blog.idrsolutions.com/2014/02/tutorial-setting-up-glassfish-on-a-linux-server/

When I run the server using the linux command ./asadmin start-domain, the console tells me that everything is ok:

If I run the sudo netstat -lntp command, I obtain the following output for port 4848:

which seems to be all right.

Finally, if I open the domain.xml file in glassfish/domains/domain1/config repertory, I will have:

and

and

which is quite strange because port 4848 is not appearing and everything is set to localhost.

I really do not know what is going on. In the tutorial everything looked so straightforward. Could you help me please ?


Answer:

I finally found out the problem.

The firewall of my Linux Red Hat Entreprise Linux release 5.11 was blocking the 4848 port. Therefore, using the following commands I successfully made everything working properly:

  1. Go to the following folder:

/etc/sysconfig

  1. Open the file containing the firewall table:

vi iptables

  1. Add the following line to the table:

-A RH-Firewall-1-INPUT -m state –-state NEW -m tcp -p tcp -–dport 4848 -j ACCEPT

  1. Save and exit
  2. Restart the network service by typing :

service iptables restart

Question:

Operating system: Ubuntu 12.04, GlassFish version: 4.0.1 (build 10)

In a GlassFish servlet I print the Java version in processRequest with this code:

    out.println("<p>" + System.getProperty("java.version") + "</p>");
    out.println("<p>" + System.getProperty("java.home") + "</p>");
    out.println("<p>" + System.getProperty("java.vendor") + "</p>");

When I enter the servlet address in a web browser the output is

1.7.0_65
/usr/lib/jvm/java-7-openjdk-amd64/jre
Oracle Corporation

However if I enter java -version on the console, the output is

java version "1.7.0_75"
OpenJDK Runtime Environment (IcedTea 2.5.4) (7u75-2.5.4-1~precise1)
OpenJDK 64-Bit Server VM (build 24.75-b04, mixed mode)

I checked for installed Java versions and the system has only one Java version installed

~# update-alternatives --config java
There is only one alternative in link group java: /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
Nothing to configure.

As expected, /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java -version also displays java version "1.7.0_75"

So the installed Java version is 1.7.0_75 while GlassFish displays 1.7.0_65. Why?


Answer:

Have you tried restarting GlassFish? Could be that the server hasn't been restarted after upgrading the JRE (and therefore the old version could still be running in memory).

Question:

First i am a total novice at linux so dont hate. I have done the same thing on windows may times and always gotten it to work. Trying on a linux box for the first time.

1)I have installed Glassfish 4 which needs JDK7 or higher.

2)I installed JDK 8

3)I set JAVA_HOME to the JDK

4)I unziped Glassfish.

When i run the following

glassfish4/bin/asadmin

I get the following error

Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

What to do.

I have seen this before and solution has been to set the JDK path. But i cant find anywhere where i am to set the path. asenv.conf ?


Answer:

Looks like your default system java is in old version. You can check it by running:

$ java -version

To set specific Java for Glassfish open glassfish/config/asenv.conf file and add at the end folowing:

AS_JAVA=pathToYourJavaHomeFolder

Question:

I try to get the list of instances of my cluster, for that i use ProcessBuilder to execute a command :

asadmin list-instances --long=true

when i execute this command from java in windows it work fine, but when i deploy my application in a real server in Linux i get an exception:

Exception = java.io.IOException: Cannot run program "/bin/sh -c 'asadmin list-instances --long=true'": error=2, Aucun fichier ou dossier de ce type

And when i execute this command directly in the server it work fine? i really can't understand what is the problem

Here is my Java code:

public String executerCommande() {
    String line, line2 = "";
    try {
        //Windows command
        //ProcessBuilder builder = new ProcessBuilder("cmd.exe", "/c", command);
        //I use this with quots and without quotes
        //ProcessBuilder builder = new ProcessBuilder("/bin/sh -c asadmin list-instances --long=true");
        ProcessBuilder builder = new ProcessBuilder("/bin/sh -c 'asadmin list-instances --long=true'");
        builder.redirectErrorStream(true);
        Process p = builder.start();
        BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
        while (true) {
            line = r.readLine();
            if (line == null) {
                break;
            }
            line2 += r.readLine() + "\n";
        }
    } catch (Exception e) {
        System.out.println("Exception = " + e);
    }
    return line2;
}

Thank you.


Answer:

Using Runtime might help

    try {
         String command = "asadmin list-instances --long=true";
         Process p = Runtime.getRuntime().exec(command);
         BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
         for (String s = br.readLine(); s != null; s = br.readLine()) {
                System.out.println("line: " + s);
         }
         br.close();
         p.waitFor();
         System.out.println("command executed exited: " + p.exitValue());
         p.destroy();
    } catch (Exception e) {
        System.out.println("Exception" + e);
    }

Question:


Answer: