• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dynamic loading of class from external jar and NoClassDefFoundError

 
Ranch Hand
Posts: 82
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi to all.
I don't know if this is the correct thread to post in my question.

What is the situation?
I've a web application, we call it WA, that uses JSF. WA run on Glassfish 3.
This application has some panel (extended from primefaces.Panel) and i want to bind the panel to some object P:

The panel must be loaded dynamically from an external jar.

The P class is something like


The ModTest class is in another jar file, called ModTest.jar. I want to load the class at runtime from the external jar so i can change the "panel" without recompile WA.

So, I built a bean B that read from database the path of jar file and the classname.
B then must instantiate an object A of tipe P and return A.pannello to show it on screen.

The loader function is:




What is the problem?
It works untill instance = classToLoad.newInstance(); at this time throw java.lang.NoClassDefFoundError: com/bss/primefaces/panel/BssPanel.
com/bss/primefaces/panel/BssPanel is missing or it is not found. That class is in another library, component.jar.
The ModTest.jar hasn't component.jar inside but WA.war has it.

What are the questions?
- ModTest.jar is a maven project so, how i can force to put all dependency jar in ModTest.jar? It solve the problem? I need to create a normal java project?
otherwise
- There is a way to provide the necessary jar without modifing ModTest.jar, like read it from glassfish's lib directory? How I must provide all the dependencies in the correct way?

Thanks, sorry for my bad English.
 
daniele licitra
Ranch Hand
Posts: 82
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Solved.

In external jar ModTest.jar, in pom.xml, put the maven plugin:


now all dependency are exploded inside the jar. It works.
reply
    Bookmark Topic Watch Topic
  • New Topic