Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Glassfish: Problem connecting two projects, one a WAR and another just a JAR  RSS feed

Pat Farrell
Posts: 4686
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not really Tomcat, but both are servlet containers and there is a lot of common code, so...

I've been building a system using two NB projects. One is the library of
all the POJO's, persistance, utilities, etc. (call the lib) and the
other is the UI stuff with servlets, jsp pages, beans, etc. For the most
part it works well.

They projects are not connected directly. You have to build the lib and
its jar file first, and then build the web app.

In the web/WEB-INF/lib of the webapp, the library jar file is referenced as
which simply provides a relative path to where the library's jar file is

But, for a new section of code, I need to read the Jar files and look
for classes with specific annotations. And while all that code works,
there is a problem.

To access the jar files, I do

Set resourcePaths = servletContext.getResourcePaths("/WEB-INF/lib");

and when I do this, the library file is not included. Clearly something,
Netbeans, the JVM, Glassfish, or something does not consider that

So I tried creating a symlink to the library jar file in the
"/WEB-INF/lib" directory. Which works to allow the Web app to work, but
makes it impossible to step into the library classes during debugging.
This makes the solution impractical.

I've thought about changing the build.xml in its
<target name="-post-jar"> section to copy the jar file, but that
will fail is I only want to work, test, and debug the jar file.

So I have two questions:
1) what is causing what looks to be functionally identical setups to
perform differently in practice
2) what's the "best" approach to fix this?

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!