[英]working as servlet but not as java class. why?
I am working on SAML SSO Authentication. 我正在研究SAML SSO身份验证。 I have created a servlet to generate SAML metadata and i deployed it and run it and I got the output.
我创建了一个servlet来生成SAML元数据,并部署并运行它,然后得到了输出。 Same time I have created a java class to generate SAML Metadata with the same code and tried to run it independently.
同时,我创建了一个Java类以使用相同的代码生成SAML元数据,并尝试独立运行它。 I have added the same Jar files that I have used for that servlet application.
我添加了与该servlet应用程序相同的Jar文件。 But I got the Exception given below.
但是我在下面给出了异常。 Can anybody help me to find the difference between running an application independently and by using java servlet??
谁能帮助我找到独立运行应用程序与使用Java servlet的区别? Thanks in advance.
提前致谢。
Exception: 例外:
Running as servlet in a web container means all sorts of stuff is on the classpath that is automatically provided by the servlet container. 在Web容器中作为Servlet运行意味着各种东西都在servlet容器自动提供的类路径上。
Running using main() means you have to put all needed stuff on the classpath yourself. 使用main()运行意味着您必须自己将所有需要的东西放到类路径上。 The ClassNotFoundException you got should be clear enough in that respect.
在这方面,您得到的ClassNotFoundException应该足够清楚。
(Pls note that although I did say "the" classpath, in a servlet container things are typically not quite that simple. But that's not the point. Also note that running as a servlet, and using features of libraries provided for the container, may even mean your stuff cannot run as an independent java program simply because the library stuff was deliberately intended for servlet container use exclusively.) (请注意,尽管我确实说了“ the”类路径,但是在servlet容器中,事情通常并不那么简单。但这并不是重点。还请注意,以servlet的身份运行,并使用为容器提供的库功能,可能会甚至意味着您的东西不能仅仅作为库的东西专门用于servlet容器而仅仅作为独立的Java程序运行。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.