在Java应用程序中找到类,但在JSF中找不到类? [英] Class found in a Java application but not in JSF?
问题描述
我正在尝试将bacnet4j与JSF一起使用.
I'm trying to use bacnet4j with JSF.
我在.java中构建了一个应用程序,该应用程序可以打开/关闭灯,但是如果我尝试从JSF页面(与我的管理bean进行通信)调用相同的方法,则会给我:
I build an application in .java which turn on/off a lamp, but if I try to call the same method from a JSF page (which communicates with my manage bean) , gives me :
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: com/serotonin/bacnet4j/type/Encodable
root cause
java.lang.NoClassDefFoundError: com/serotonin/bacnet4j/type/Encodable
root cause
java.lang.ClassNotFoundException: com.serotonin.bacnet4j.type.Encodable
但是我很确定该类在那里,因为如果我的Java应用程序不起作用,对吗?
But I'm pretty sure that the class is there, because if not my java application don't work, right ?
知道为什么会这样吗?
推荐答案
包含此类的JAR文件应放在webapp的/WEB-INF/lib
文件夹中.
The JAR file containing this class should go in webapp's /WEB-INF/lib
folder.
普通的Java应用程序不使用与Java Web应用程序相同的类路径.对于纯Java应用程序,类路径通常由java
命令中的-cp
或-classpath
参数指定,或者,如果未指定,则由%CLASSPATH%
环境变量指定,或者如果是JAR,则由JAR的Class-Path
条目指定c6>.对于Java Web应用程序,类路径默认覆盖Webapp的/WEB-INF/lib
和/WEB-INF/classes
文件夹以及服务器的/lib
(及更多)文件夹以及您可以在服务器特定的配置中指定的任何自定义文件夹,例如shared.loader
属性如果是Tomcat,则为/conf/catalina.properties
.
A plain Java Application does not use the same classpath as a Java Web Application. For a plain Java Application the classpath is usually specified by -cp
or -classpath
argument in java
command, or if unspecified, by %CLASSPATH%
environment variable, or if being a JAR, by Class-Path
entry in JAR's /META-INF/MANIFEST.MF
. For a Java Web Application the classpath covers by default the webapp's /WEB-INF/lib
and /WEB-INF/classes
folder and server's /lib
(and more) folders and any custom folders which you can specify in server-specific configuration, such as shared.loader
property of /conf/catalina.properties
in case of Tomcat.
这篇关于在Java应用程序中找到类,但在JSF中找不到类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!