TedTrippin
TedTrippin

Reputation: 3662

Added faces-config.xml but still getting Target Unreachable

I have a JSF app running on embedded jetty. It works when I run it from eclipse but not from command line. I realised it was because eclipse uses the folders and cli uses the jar. I assumed, after googling, it was because my jar was missing a faces-config.xml. I added one in the META-INF folder but I'm still getting Target unreachable errors for the beans in my xhtml.

Pic of faces-config.xml

How can I check that JSF is in fact scanning my jar for @ManagedBean?

Ps. I build my projects' jar with maven, copy it to my lib folder then run it from cli with java -cp "lib\*" com.test.MainSystem

Upvotes: 0

Views: 171

Answers (1)

TedTrippin
TedTrippin

Reputation: 3662

After debugging AnnotationConfiguration I could see that Jetty only scans jars under WEB-INF.

Fortunately, they provide a method for adding external jars. Adding this got me up and running...

WebAppContext webapp = new WebAppContext();

// Add "this" jar to the list of jars to scan for annotations
String jarPath = JettyServer.class.getProtectionDomain().getCodeSource().getLocation().getPath();
webapp.setExtraClasspath(jarPath);

Upvotes: 1

Related Questions