Possible Duplicate:
can’t locate db4o database file
I'm trying to create a simple CRUD application with DB4O and JSF. In my web project I have two packages:
com.crud.bean
containing the CRUDClient.java
com.crud.entities
containing the DB4O entities Client.java
The webContent contains one JSP file addClient.jsp
containing a form with a client necessary fields.
I will declare CRUDClient.java
as a Managed bean in faces-config.xml
to use its functions and attributes in the JSP file.
But when I run the project I get the following error
15:44:32,444 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC00001:Failed to start service jboss.deployment.unit."DB_WEB.war".POST_MODULE:org.jboss.msc.service.StartException in service jboss.deployment.unit."DB_WEB.war".POST_MODULE: Failed to process phase POST_MODULE of deployment "DB_WEB.war"atorg.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.ja va:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_01]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_01]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_01]
Caused by: java.lang.NoClassDefFoundError: com/db4o/ObjectContainer
at java.lang.Class.getDeclaredConstructors0(Native Method) [rt.jar:1.7.0_01]
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source) [rt.jar:1.7.0_01]
at java.lang.Class.getConstructor0(Unknown Source) [rt.jar:1.7.0_01]
at java.lang.Class.getConstructor(Unknown Source) [rt.jar:1.7.0_01]
at org.jboss.as.web.deployment.jsf.JsfManagedBeanProcessor.deploy(JsfManagedBeanProcessor.java:108)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService. java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
... 5 more
Caused by: java.lang.ClassNotFoundException: com.db4o.ObjectContainer from [Module "deployment.DB_WEB.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
... 11 more
How is this caused and how can I solve it?
Caused by: java.lang.ClassNotFoundException: com.db4o.ObjectContainer
This just means that the mentioned class (or at least the JAR file containing the mentioned class) is missing in the runtime classpath. The package name hints that it's a DB4O class which is usually provided in flavor of a JAR file.
The webapp's default runtime classpath covers among others the webapp's /WEB-INF/lib
folder. So if you make sure that you drop the DB4O JAR file in there and rebuild/redeploy/restart, then this exception should disappear.
Note that this problem is unrelated to JSF/JSP. It's just basic Java. The package name of the exception also hints that, it's from the java.lang
package, not javax.faces
nor javax.servlet
package, which would otherwise make it indeed a JSF/JSP(Servlet) related problem.
Another unrelated note which I'd like to make is that JSP is deprecated since JSF 2.0 about 3 years ago. Perhaps you were reading outdated JSF 1.x targeted resources? As to learning JSF, I recommend to read up to date tutorials. You can start at our JSF wiki page.