我正在使用我的Web应用程序,它使用JBoss 7 AS作为应用程序服务器。我最近安装了JBoss 7并且启动顺利。现在当我尝试在WebContent文件夹下使用index.html运行非常简单的Web应用程序时,我得到以下错误:
HTTP Status 404 - The requested resource (/BookStore/index.html) is not available
我知道这意味着JBoss服务器无法找到该位置但是当我在控制台中没有看到任何错误时会出现什么问题。
这是我的 web.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name>BookStore</display-name>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.PRETTY_HTML</param-name>
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/index.html</welcome-file>
</welcome-file-list>
index.html 文件:
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Success</title>
</head>
<body>
<p>Hello World!</p>
</body>
</html>
在这种情况下我能做些什么?我正在使用Eclipse Indigo并澄清我在 HTTP状态404错误之前没有部署项目的.war文件。但是,当我尝试通过创建名为BookStore.war.dodeploy JBOSS_PATH / Standalone / Deployments 的文件来部署该特定.war文件时,我得到了部署失败错误,错误的根本原因是:
16:06:02,958 WARN [org.hibernate.engine.jdbc.internal.JdbcServicesImpl] (MSC service thread 1-4) HHH000342: Could not obtain connection to query metadata : No suitable driver found for jdbc:derby:C:\Users\Amir\workspace\BookStoreDB;create=true
16:06:02,966 INFO [org.hibernate.dialect.Dialect] (MSC service thread 1-4) HHH000400: Using dialect: org.hibernate.dialect.DerbyDialect
16:06:02,974 WARN [org.hibernate.dialect.DerbyDialect] (MSC service thread 1-4) HHH000430: The DerbyDialect dialect has been deprecated; use one of the version-specific dialects instead
16:06:02,980 INFO [org.hibernate.engine.jdbc.internal.LobCreatorBuilder] (MSC service thread 1-4) HHH000422: Disabling contextual LOB creation as connection was null
16:06:02,986 INFO [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] (MSC service thread 1-4) HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory
16:06:02,991 INFO [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (MSC service thread 1-4) HHH000397: Using ASTQueryTranslatorFactory
16:06:03,056 INFO [org.hibernate.validator.util.Version] (MSC service thread 1-4) Hibernate Validator 4.2.0.Final
16:06:03,554 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] (MSC service thread 1-4) HHH000228: Running hbm2ddl schema update
16:06:03,555 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] (MSC service thread 1-4) HHH000102: Fetching database metadata
16:06:03,555 ERROR [org.hibernate.tool.hbm2ddl.SchemaUpdate] (MSC service thread 1-4) HHH000319: Could not get database metadata: java.sql.SQLException: No suitable driver found for jdbc:derby:C:\Users\Amir\workspace\BookStoreDB;create=true
at java.sql.DriverManager.getConnection(Unknown Source) [rt.jar:1.6.0_35]
at java.sql.DriverManager.getConnection(Unknown Source) [rt.jar:1.6.0_35]
at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:173) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:51) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:194) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:178) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:457) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1737) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [rt.jar:1.6.0_35]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.6.0_35]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_35]
关于上述错误,我正在使用Embdedded Derby,我检查并确保它在库/ jar中有嵌入式Derby驱动程序。我也在使用Hibernate建立连接。有趣的是,当我运行JUnit测试时,我将一些数据保存到数据库中,但是由于某种原因我只是不明白为什么它在上面的错误中说
Could not obtain connection to query metadata : No suitable driver found for jdbc:derby:C:\Users\Amir\workspace\BookStoreDB;create=true
。
答案 0 :(得分:0)
经过深入研究后,我发现JBoss AS7实际上并不支持YET MyFaces。其中一位JBoss开发人员回答了以下问题:
Hello JBoss团队,
我想知道我是否可以使用MyFaces代替Mojarra作为jsf
实现。对不起,如果这不是提出这个问题的地方。由于
Rafael Castro
**对于AS7,我们目前无法让您使用MyFaces。它的 在待办事项清单上,但尚未安排发布。
斯坦**
以下是该讨论的网址Use MyFaces instead of Mojarra with JBoss AS7。
所以看来你必须使用以前版本的JBoss,例如JBoss 6.希望这会有所帮助。