TomEE SSH connector commands


The previous article was about installing TomEE SSH connector. Let’s now see which commands are available by default in details.

Built-in commands

Cat

cat command is highly inspired from unix cat command. You add a file path and the command prints its content.

To avoid to be able to access the whole file system files you have to start the provided path by $base or $home which are the CATALINA_HOME or CATALINA_BASE variable of your TomEE.

Example: cat $home/conf/server.xml

Classloader

classloader command let you print what is in classloaders of an application. You have to provide the application id after the command name. Don’t panic if you don’t know it, simply write “classloader” and the command will print all the application ids.

Example: classloader MyWebapp

Deploy

deploy command simply let you deploy an application from a path.

Example: deploy /opt/apps/my-app.war

Note: if you have added the provisioning module you can use maven like path (deploy com.foo/foo-web/1.0.0/war)

Undeploy

undeploy command simply let you undeploy a deployed application from a path.

Example: undeploy /opt/apps/my-app.war

Note: same note than for deploy applied you can use maven path or http urls under the same constraints.

Apps

apps command is a simple command to print all deployed applications. It prints all ids.

Example: apps

Exit

exit is not surprising, it simply close the session.

Example: exit

Help

help command prints all available commands, their name, description and usage

Example: help

List

list command prints all deployed EJBs with their type, class and name.

Example: list

JMX

jmx commands let’s you interact with local MBeans.

It has several sub commands.

get

Query a value. Parameters are the attribute name and the objectname.

Example: jmx get MyAttributeName foo:type=bar

set

Update a value. Parameters are the attribute name, the objectname and the new value.

Example: jmx set MyAttributeName foo:type=bar NewValue

invoke

Invoke a method. Parameters are the method with its parameters and the object name.

Example: jmx invoke myMethod(arg1,arg2) foo:type=bar”)

list

list simply list all mbeans.

Example: jmx list

ls

Like the UNIX command ls list files/directories in a folder. The same contraint then for cat command is applied: you have to use $ase and $home variables.

Example: ls $home/conf

part

Part is a bit particular since it lets you print a segment of a file. You simply have to provide the segment <first line>-<last-line> and the path of the file (starting with $home or $base).

Example: part 3-10 $home/conf/catalina.properties

properties

properties command dumps the TomEE configuration in properties format.

Example: properties

script

script command lets you use the JSR 223 (scripting for the JVM) to do some stuff using ejbs (from their names) or CDI beans. For CDI beans you need to use the “bm” variable. bm object has the following methods:

  • beanFromClass(appname, classname)
  • beanFromName(appname, beanname)

You have to give the language to use as first parameter then the script itself.

Example: script groovy print ‘ok’

Note: by default with the JVM you can use javascript (js). To use groovy add groovy-all jar. For other languages (ruby, scala…) add the corresponding jar. Additinoal jar should be in tomcat common classloader (or lib directory).

script file

Close to script command, script file takes a file as parameter, determine the script language from the extension and execute it.

Example: script file my-script.js

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s