Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Running from EAR

 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I'd like to know if it's possible to run an application from an EAR file. If so, how do I do it? Currently, I get an "Exception in thread "main" java.lang.NoClassDefFoundError".

My EAR file contains all the libraries bound on APP-INF/lib, and the JAR file with the Main-Class correctly set on the "/", the root. Outside the EAR file, it works fine.

Can anybody help?

Thanks in advance!
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the EAR file in the CLASSPATH ?
 
Tiago Fernandez
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it is... I guess I'm still missing something.
 
author & internet detective
Posts: 40198
816
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tiago,
The Java file would be in a jar (an ear uses the jar format) within a jar (the code itself would be in a jar file.) I'm not sure whether you can do this, but I suspect not. I'll be keeping an eye on this thread to see if someone else knows.

When you deploy the ear, it is unzipped/jar'd. Then you have loose jars for your libraries. At this point, it is definitely possible to run a Java program - main method.
 
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tiago,

An EAR file is meant for deployment on an appserver. It typically contains jar files that describe EJBs and/or web warchives (WAR files). The standard Java runtime will not execute an EAR file similar to a Jar file so you cannot pass it on the command line to the java executable. You may drop it into an application server like JBoss or WebSphere, assuming it is properly constructed and includes all of the relevant deployment XML files. What you are probably looking for is a solution like One Jar which allows you to nest jar files in one another. Hope that helps some
 
Every time you till, you lose 30% of your organic matter. But this tiny ad is durable:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic