I downloaded the jetty-runner JAR version 9.2.10.v20150310 from maven repo (
http://mvnrepository.com/artifact/org.eclipse.jetty/jetty-runner/9.2.10.v20150310).
I then tried to run my packaged *.war file with "java -jar jetty-runner.jar
my-package.war", and all works fine and dandy.

Now let's imagine this project setup:

   1. I have a project called war-project, which packages to
   "my-package.war"
   2. I have a dependency to that war-project in another project called
   jar-project.
   3. jar-project also has a dependency to jetty-runner and has a Main
   class.

jetty-runner's main class is called Runner.

Now, when I execute Runner.main(new String[] { "my-package.war" }) (which
is the same as above java command), I get all sorts of exceptions basically
saying that my spring context got read twice. That happens because Spring
reads all 'application-context.xml' files classpath, which happens to be
the same file twice: once from the war, and once from the dependency that
'jar-project' has to 'war-project'.

Is there a way to somehow limit the Jetty's classpath, or is there no other
way, but to reorganize my project structure? I understand it sounds a bit
strange, but maybe a solution exists and someone actually knows it.

I wouldn't want to change anything in the 'war-project', because of project
specifics.

This is a question in Stackoverflow:
http://stackoverflow.com/questions/29217400/embedded-jetty-reads-two-application-contexts
This is a source code on github, if you'd like to tinker with it a bit:
https://github.com/guilty/jetty-test

And a little bit of disclaimer: I don't actually use Runner.main() in my
actual code, but it is a common ground and it reproduces my issue to the
letter. If I can manage to solve this issue with jetty-runner, I will be
able to solve it with an embedded Jetty server. Also, don't ask why
jar-project depends on war-project. Short explanation is that it needs some
API classes. I know I could extract it to a separate project and then my
problem would go away, but I still want to research into this a bit before.

Thank you in advance.

-- Paulius
_______________________________________________
jetty-users mailing list
[email protected]
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to