Hot questions for Using GlassFish in asadmin
I'm using Java EE with Glassfish.
I can't run asadmin command as well. I did the following, but output from terminal is:
No command 'asadmin' found, did you mean: Command 'amadmin' from package 'amanda-server' (universe) Command 'acsadmin' from package'ion' (universe) asadmin: command not found
I have Ubuntu 14.04 Trusty Tahr. I should be in bin directory of glassfish, so I'm in /opt/glassfish4/bin. But always nothing happend, just error message above.
In Ubuntu and Linux in generál, you run commands from current directory like this:
./asadmin, ie. you must prepend
./ to make it explicit that you run a command I current directory. This is traditionally for some security reasons.
I'm trying to use a javax.sql.DataSource injected into a servlet (glassfish)
@Resource (name="jdbc/MysqlDS" ) javax.sql.DataSource mysqlDS;
The following statements fail, throwing "java.sql.SQLException: Access denied for user 'userapp'@'localhost' (using password: YES)":
con=mysqlDS.getConnection(); PreparedStatement pstmt=con.prepareStatement("select now()");
con=mysqlDS.getConnection("userapp","userpassword"); PreparedStatement pstmt=con.prepareStatement("select now()");
But the following were successful:
Class.forName("com.mysql.jdbc.Driver"); con = java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/user_lindenb", "appuser", "userpassword"); w.println("OK"); con.close(); con=null;
$ mysql -u appuser --password=userpassword -D user_lindenb -e 'select now()' +---------------------+ | now() | +---------------------+ | 2015-08-05 10:19:07 | +---------------------+
The grant was declared as follow:
grant insert,select,update,delete on user_lindenb.* TO 'appuser'@'localhost' identified by 'userpassword';
and the resources were declared as follow
asadmin --port 8138 create-jdbc-connection-pool \ --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlDataSource \ --restype javax.sql.DataSource \ --property "password=userpassword:user=userapp:serverName=localhost:databaseName=user_lindenb" \ MysqlDS asadmin --port 8138 create-jdbc-resource \ --connectionpoolid MysqlDS \ "jdbc/MysqlDS"
what's wrong with this user 'userapp' ?
after I added
grant USAGE on *.* TO 'appuser'@'localhost' identified by 'adminadmin';
everything worked fine... I don't understand why.
I'm trying to start my local domain from a command line, for some reason my domain was created in a different location so I tried the following command to start the domain:
C:\Program Files (x86)\glassfish4\glassfish\bin>asadmin start-domain C:\Users\Abraham\personal_domain
but it doesn't work, I got the following error:
There is no such domain directory:
C:\Program Files (x86)\glassfish4\glassfish\domains\C:\Users\Abraham\personal_domain Command start-domain failed.
Do I have to add another attribute in the command?, What am I missing?
From NetBeans, it runs fine and I can access to my application but I want to be able to start it from command line
Firstly, to find more information about any
asadmin subcommand, you can use
help to find the man page for that command in one of two ways:
asadmin help start-domain
asadmin start-domain --help
Secondly, to start a domain from a different location, you need to first specify the domains directory - a folder where the actual domain folder sits, and then the domain name. This will look a lot like you've just typed out the full path to the domain directory, but do be aware that there is a space in between the end of the path and the name of the domain.
e.g. if I wanted to start a domain called "
myDomain" in a folder
C:\Users\me\domains, I could do this:
asadmin start-domain --domaindir C:\Users\me\domains myDomain
Note the space in between
So, in your case, you would need to use:
asadmin start-domain --domaindir C:\Users\Abraham personal_domain
So I am trying to restart glassfish server but it fails to start. What could be the error?
java.io.FileNotFoundException: /home/ubuntu/glassfish-3.1.1/glassfish/domains/domain1/logs/server.log (Permission denied)
at java.io.FileOutputStream.open(Native Method)
Waiting for domain1 to start ..............................................................................................................................................................................................................................
Anyone kindly advice?
It obviously fails to create or open the log file:
You should ensure that the folder structure exists and is accessible by the process (and it's user).
I would like to create a jdbc connection pool from the command line --- doing it through the browser all the time is driving me crazy as it is such a tedious process. I've used the command
asadmin create-jdbc-connection-pool --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlDataSource --restype javax.sql.DataSource --property user=root:password=test:DatabaseName=test:ServerName=localhost:port=3306 the-pool
with success. However, it creates a connection pool with only the properties that are specified in the command. When I use the administration console at localhost:4848 to create a connection pool, the default number of "additional parameters" seem to be in the region of 171 properties. I'm assuming that the console is enacting a default property flag. Does anyone know how I might modify the command to get a more comprehensive list of properties? I've consulted the Oracle docs for pool administration but have had no joy and my shoddy installation of glassfish rendered
asadmin's help pages defunct.
I've been using the command posted in the question successfully for the past few months. There appears to be no need to set any of the additional properties. However, I use
com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource instead of MysqlDataSource for the sake of performance (see this answer).
Upon creation of the pool, the jdbc resource is created by
asadmin create-jdbc-resource --connectionpoolid the-pool jdbc/the-pool
Pretty much says it all, but when I try to log in to the Glassfish console I am get a "Error Authentication Failed Re-enter your username and password"
However when i use asadmin I am able to login, deploy, etc. it all works.
If there is a particular place I can alter the log level or a place I can look.
FYI part of the reason I think this happened is that I have changed the master password.
Not Exactly sure why it works, but I think it may be due to some cached values. I already had secure admin enabled when I stared the process of adding SSL certificates, and based on information in this post: Right way to configure Glassfish SSL certificate nickname? I was able to find a solution. With the server running Disable Secure Admin. Restart Server Enable Secure Admin Restart Server.