I already blogged about the way to connect to TomEE through SSH.
The idea of this post is to do the same but more easily using the tomee-maven-plugin.
The steps are the following ones:
* add the tomee-maven-plugin
* add openejb-ssh librairies in TomEE lib/ folder
* configure your LoginModule
* add the JAAS system property to specify your LoginModule (java.security.auth.login.config)
So in your pom you should get something like:
<plugin> <groupId>org.apache.openejb.maven</groupId> <artifactId>tomee-maven-plugin</artifactId> <version>1.0.1-SNAPSHOT</version> <configuration> <systemVariables> <!-- where is our JAAS configuration --> <java.security.auth.login.config>${project.build.directory}/apache-tomee/conf/login.config</java.security.auth.login.config> </systemVariables> <libs> <!-- we need the ssh library --> <lib>unzip:org.apache.openejb:openejb-ssh:${openejb.version}:zip</lib> </libs> <zip>false</zip> <!-- set true if you want to create a zip and attach it to your build --> </configuration> </plugin>
Now you just need the configuration files. We’ll use the place used by default by tomee-maven-plugin: src/main/tomee/conf.
For the demo we’ll simply use the properties LoginModule but you can use whatever you want (think to override the domain property in conf/conf.d/ssh.properties if you don’t use PropertiesLogin name):
PropertiesLogin { org.apache.openejb.core.security.jaas.PropertiesLoginModule required Debug=false UsersFile="users.properties" GroupsFile="groups.properties"; };
This login module needs a users.properties and a groups.properties files we add in src/main/tomee/conf too:
# groups.properties admin = tomee
# users.properties tomee = tomee
Finally we need to specify the realm in our server.xml:
<?xml version='1.0' encoding='utf-8'?> <Server port="8005" shutdown="SHUTDOWN"> <Listener className="org.apache.tomee.catalina.ServerListener" /> <Listener className="org.apache.catalina.security.SecurityListener" /> <Service name="Catalina"> <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" /> <Engine name="Catalina" defaultHost="localhost"> <Realm className="org.apache.catalina.realm.JAASRealm" appName="PropertiesLogin" userClassNames="org.apache.openejb.core.security.jaas.UserPrincipal" roleClassNames="org.apache.openejb.core.security.jaas.GroupPrincipal" /> <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" /> </Engine> </Service> </Server>
Here we are, now simply run:
mvn tomee:build
And you’ll get in target/apache-tomee a TomEE enriched by a SSH server.
Note: to make it ready to use without tomee-maven-plugin simply add a setenv.sh in src/main/tomee/bin with the something like (use setenv.bat for windows):
if [ -n "${CATALINA_BASE}" ] ; then DIR="${CATALINA_BASE}" else DIR="${CATALINA_HOME}" fi export CATALINA_OPTS="-Djava.security.auth.login.config=$DIR/conf/login.config $CATALINA_OPTS"
We are now ready to use it. In development you can simply start your TomEE using:
mvn tomee:run
By default the SSH port used is 4222 (use conf/conf.d/ssh.properties to override it) so simply connect with:
ssh tomee@localhost -p 4222
Enter the password “tomee” and you should see the TomEE SSH console.
Bonus: add in tomee-maven-plugn the library:
<lib>unzip:org.apache.openejb:openejb-provisionning:${openejb.version}:zip</lib>
And you should be able to deploy application from maven:
tomee @ localhost> deploy mvn:org.superbiz/foo/1.0/war
Hey there. I was considering adding a hyperlink back to
your website since both of our web sites are based around the same niche.
Would you prefer I link to you using your site address: http:
//rmannibucau.wordpress.com/2012/10/18/create-a-tomee-accessible-through-ssh-with-tomee-maven-plugin/ or website
title: Create a TomEE accessible through SSH with TomEE Maven Plugin | RManniBucau.
blog(). Be sure to let me know at your earliest convenience.
Thankyou
Hi, IMO title looks more readable but just select the one which is the most consistent with your website.