S
sengsational
I have a test class in the same place as my servlet that I want to run
outside of the web container, but I can't get the command line right
to run the test class.
Inside my war file, it looks like this:
WEB-INF
classes
com.some.myapp
MyServlet.class
MyTest.class
So I changed to the directory that contained the war file and did
this:
C:\myapp\war>java -cp .;myapp.war WEB-INF/classes/
com.some.myapp.MyTest
Exception in thread "main" java.lang.NoClassDefFoundError: WEB-INF/
classes/com/some/myapp/MyTest (wrong name: com/some/myapp/MyTest)
I sort of knew that "WEB-INF/classes/com.some.myapp.MyTest" wasn't
going to work (it actually wasn't my first try). I tried:
java -cp .;myapp.war;WEB-INF/classes com.some.myapp.MyTest
but that came up with the plain NoClassDefFoundError (without the
"wrong name").
Then I tried this:
java -cp .;WEB-INF/classes -jar myapp.war com.some.myapp.MyTest
And got this:
Failed to load Main-Class manifest attribute from myapp.war
So I added:
Main-Class: com.some.myapp.MyTest
to the manifest.mf file repackaged and ran this:
java -cp .;WEB-INF/classes -jar myapp.war
and got a plain NoClassDefFoundError (without the "wrong name").
So the question is...
Can I run MyTest.class if it's packed in a war file like it is (under
WEB-INF/classes)?
--Dale--
outside of the web container, but I can't get the command line right
to run the test class.
Inside my war file, it looks like this:
WEB-INF
classes
com.some.myapp
MyServlet.class
MyTest.class
So I changed to the directory that contained the war file and did
this:
C:\myapp\war>java -cp .;myapp.war WEB-INF/classes/
com.some.myapp.MyTest
Exception in thread "main" java.lang.NoClassDefFoundError: WEB-INF/
classes/com/some/myapp/MyTest (wrong name: com/some/myapp/MyTest)
I sort of knew that "WEB-INF/classes/com.some.myapp.MyTest" wasn't
going to work (it actually wasn't my first try). I tried:
java -cp .;myapp.war;WEB-INF/classes com.some.myapp.MyTest
but that came up with the plain NoClassDefFoundError (without the
"wrong name").
Then I tried this:
java -cp .;WEB-INF/classes -jar myapp.war com.some.myapp.MyTest
And got this:
Failed to load Main-Class manifest attribute from myapp.war
So I added:
Main-Class: com.some.myapp.MyTest
to the manifest.mf file repackaged and ran this:
java -cp .;WEB-INF/classes -jar myapp.war
and got a plain NoClassDefFoundError (without the "wrong name").
So the question is...
Can I run MyTest.class if it's packed in a war file like it is (under
WEB-INF/classes)?
--Dale--