Dear Ketki,
Greetings !
Apologies for the delay happened on this.
I have tried this at my end and have come up with a slight different solution which is working.
So, instead of installing both at once, we will install this differently.
1) Installing Java. We will do this by installing the Java module directly from forgepuppet and just use it.
puppet module install puppetlabs-java --version 1.4.0

So, above it is installing that module into my /home/edureka/.puppet/modules/ directory.
So, I have copied it to /etc/puppet/modules/ directory with below command by going into the actual directory first and then below command
sudo cp -R java /etc/puppet/modules/
Now, in the /etc/puppet/manifests/site.pp file , enter below content
node 'test02.edureka.com'
{
include java
}
The above one will install java in machine as showed below :


Now once Java is installed, now we will installed Tomcat with below content in site.pp file
class tomcat {
group{'tomcat':
name =>'tomcat',
ensure => present,
}
user{'tomcat':
name =>'tomcat',
ensure => present,
groups => 'tomcat',
require => Group['tomcat'],
}
exec {'gettomcat':
path => '/bin:/usr/sbin:/usr/bin:/sbin',
command => 'wget http://redrockdigimark.com/apachemirror/tomcat/tomcat-8/v8.5.14/bin/apache-tomcat-8.5.14.tar.gz',
cwd => '/tmp',
require => Exec['install'],
}
exec {'extracttomcat':
path => '/bin:/usr/sbin:/usr/bin:/sbin',
cwd => '/tmp',
command => 'sudo mkdir -p /opt/tomcat && tar xvf apache-tomcat-8*tar.gz -C /opt/tomcat --strip-components=1',
require => Exec['gettomcat'],
}
This will install tomcat as well in machine, as shown below :

So, now all tomcat and Java are installed. We need to Start tomcat and check whether we are able to see it or not on browser.
*Become a root user
cd /opt/tomcat/bin
./startup.sh
You will get a message like below :


However, to use this tomcat you need to create users and roles etc as shown below by editing the tomcat-users.xml file and giving below credentials :

Let us know if you need any help.
Please note if you are not happy with the response on this ticket, please escalate it to escalations@edureka.in.
We assure you that we will get back to you within 24 hours
Please do provide your feedback from below options incase if you are satisfied with the response.
Regards,
Yeshwanth at Edureka
edureka! Support Team