create project using eclipse , project springmvc, run project , default has following controller:
package com.app.test; import java.text.dateformat; import java.util.date; import java.util.locale; import org.slf4j.logger; import org.slf4j.loggerfactory; import org.springframework.stereotype.controller; import org.springframework.ui.model; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.requestmethod; /** * handles requests application home page. */ @controller public class homecontroller { private static final logger logger = loggerfactory.getlogger(homecontroller.class); /** * selects home view render returning name. */ @requestmapping(value = "/", method = requestmethod.get) public string home(locale locale, model model) { logger.info("welcome home! client locale {}.", locale); date date = new date(); dateformat dateformat = dateformat.getdatetimeinstance(dateformat.long, dateformat.long, locale); string formatteddate = dateformat.format(date); model.addattribute("servertime", formatteddate ); return "home"; } }
everything return template set again default hello world , current time. run , worked well. however, console display errors i'm not sure may normal spring though because generated eclipse.
then decide add following dependency:
<dependency> <groupid>org.hibernate</groupid> <artifactid>hibernate-core</artifactid> <version>4.3.5.final</version> </dependency>
add it. build project , run again in server , have no caption, white page. in console again out errors.
here pom.hml file
<?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelversion>4.0.0</modelversion> <groupid>com.app</groupid> <artifactid>test</artifactid> <name>testmvc</name> <packaging>war</packaging> <version>1.0.0-build-snapshot</version> <properties> <java-version>1.6</java-version> <org.springframework-version>3.1.1.release</org.springframework-version> <org.aspectj-version>1.6.10</org.aspectj-version> <org.slf4j-version>1.6.6</org.slf4j-version> </properties> <dependencies> <!-- spring --> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-context</artifactid> <version>${org.springframework-version}</version> <exclusions> <!-- exclude commons logging in favor of slf4j --> <exclusion> <groupid>commons-logging</groupid> <artifactid>commons-logging</artifactid> </exclusion> </exclusions> </dependency> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-webmvc</artifactid> <version>${org.springframework-version}</version> </dependency> <!-- aspectj --> <dependency> <groupid>org.aspectj</groupid> <artifactid>aspectjrt</artifactid> <version>${org.aspectj-version}</version> </dependency> <dependency> <groupid>org.hibernate</groupid> <artifactid>hibernate-core</artifactid> <version>4.3.5.final</version> </dependency> <!-- logging --> <dependency> <groupid>org.slf4j</groupid> <artifactid>slf4j-api</artifactid> <version>${org.slf4j-version}</version> </dependency> <dependency> <groupid>org.slf4j</groupid> <artifactid>jcl-over-slf4j</artifactid> <version>${org.slf4j-version}</version> <scope>runtime</scope> </dependency> <dependency> <groupid>org.slf4j</groupid> <artifactid>slf4j-log4j12</artifactid> <version>${org.slf4j-version}</version> <scope>runtime</scope> </dependency> <dependency> <groupid>log4j</groupid> <artifactid>log4j</artifactid> <version>1.2.15</version> <exclusions> <exclusion> <groupid>javax.mail</groupid> <artifactid>mail</artifactid> </exclusion> <exclusion> <groupid>javax.jms</groupid> <artifactid>jms</artifactid> </exclusion> <exclusion> <groupid>com.sun.jdmk</groupid> <artifactid>jmxtools</artifactid> </exclusion> <exclusion> <groupid>com.sun.jmx</groupid> <artifactid>jmxri</artifactid> </exclusion> </exclusions> <scope>runtime</scope> </dependency> <!-- @inject --> <dependency> <groupid>javax.inject</groupid> <artifactid>javax.inject</artifactid> <version>1</version> </dependency> <!-- servlet --> <dependency> <groupid>javax.servlet</groupid> <artifactid>servlet-api</artifactid> <version>2.5</version> <scope>provided</scope> </dependency> <dependency> <groupid>javax.servlet.jsp</groupid> <artifactid>jsp-api</artifactid> <version>2.1</version> <scope>provided</scope> </dependency> <dependency> <groupid>javax.servlet</groupid> <artifactid>jstl</artifactid> <version>1.2</version> </dependency> <!-- test --> <dependency> <groupid>junit</groupid> <artifactid>junit</artifactid> <version>4.7</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <artifactid>maven-eclipse-plugin</artifactid> <version>2.9</version> <configuration> <additionalprojectnatures> <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature> </additionalprojectnatures> <additionalbuildcommands> <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand> </additionalbuildcommands> <downloadsources>true</downloadsources> <downloadjavadocs>true</downloadjavadocs> </configuration> </plugin> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-compiler-plugin</artifactid> <version>2.5.1</version> <configuration> <source>1.6</source> <target>1.6</target> <compilerargument>-xlint:all</compilerargument> <showwarnings>true</showwarnings> <showdeprecation>true</showdeprecation> </configuration> </plugin> <plugin> <groupid>org.codehaus.mojo</groupid> <artifactid>exec-maven-plugin</artifactid> <version>1.2.1</version> <configuration> <mainclass>org.test.int1.main</mainclass> </configuration> </plugin> </plugins> </build> </project>
these main exceptions stops application.
exception sending context initialized event listener instance of class org.springframework.web.context.contextloaderlistener javax.xml.parsers.factoryconfigurationerror: provider javax.xml.parsers.documentbuilderfactory cannot found @ javax.xml.parsers.documentbuilderfactory.newinstance(unknown source) @ org.apache.log4j.xml.domconfigurator.doconfigure(domconfigurator.java:772) @ org.apache.log4j.xml.domconfigurator.doconfigure(domconfigurator.java:696) @ org.apache.log4j.helpers.optionconverter.selectandconfigure(optionconverter.java:471) @ org.apache.log4j.logmanager.<clinit>(logmanager.java:125) @ org.slf4j.impl.log4jloggerfactory.getlogger(log4jloggerfactory.java:64) @ org.slf4j.loggerfactory.getlogger(loggerfactory.java:270) @ org.apache.commons.logging.impl.slf4jlogfactory.getinstance(slf4jlogfactory.java:156) @ org.apache.commons.logging.impl.slf4jlogfactory.getinstance(slf4jlogfactory.java:132) @ org.apache.commons.logging.logfactory.getlog(logfactory.java:272) @ org.springframework.web.context.contextloader.initwebapplicationcontext(contextloader.java:270) @ org.springframework.web.context.contextloaderlistener.contextinitialized(contextloaderlistener.java:111) @ org.apache.catalina.core.standardcontext.listenerstart(standardcontext.java:4994) @ org.apache.catalina.core.standardcontext.startinternal(standardcontext.java:5492) @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:150) @ org.apache.catalina.core.containerbase.addchildinternal(containerbase.java:901) @ org.apache.catalina.core.containerbase.addchild(containerbase.java:877) @ org.apache.catalina.core.standardhost.addchild(standardhost.java:649) @ org.eclipse.gemini.web.tomcat.internal.tomcatservletcontainer.startwebapplication(tomcatservletcontainer.java:125) @ org.eclipse.gemini.web.internal.standardwebapplication.start(standardwebapplication.java:109) @ org.eclipse.gemini.web.extender.webcontainerbundlecustomizer.addingbundle(webcontainerbundlecustomizer.java:49) @ org.osgi.util.tracker.bundletracker$tracked.customizeradding(bundletracker.java:482) @ org.osgi.util.tracker.bundletracker$tracked.customizeradding(bundletracker.java:1) @ org.osgi.util.tracker.abstracttracked.trackadding(abstracttracked.java:262) @ org.osgi.util.tracker.abstracttracked.track(abstracttracked.java:234) @ org.osgi.util.tracker.bundletracker$tracked.bundlechanged(bundletracker.java:457) @ org.eclipse.osgi.framework.internal.core.bundlecontextimpl.dispatchevent(bundlecontextimpl.java:847) @ org.eclipse.osgi.framework.eventmgr.eventmanager.dispatchevent(eventmanager.java:230) @ org.eclipse.osgi.framework.eventmgr.listenerqueue.dispatcheventsynchronous(listenerqueue.java:148) @ org.eclipse.osgi.framework.internal.core.framework.publishbundleeventprivileged(framework.java:1523) @ org.eclipse.osgi.framework.internal.core.framework.publishbundleevent(framework.java:1459) @ org.eclipse.osgi.framework.internal.core.framework.publishbundleevent(framework.java:1454) @ org.eclipse.osgi.framework.internal.core.bundlehost.startworker(bundlehost.java:391) @ org.eclipse.osgi.framework.internal.core.abstractbundle.start(abstractbundle.java:299) @ org.eclipse.osgi.framework.internal.core.abstractbundle.start(abstractbundle.java:291) @ com.sap.core.js.deployer.watchservice.wardeployer.update(wardeployer.java:313) @ com.sap.core.js.deployer.watchservice.filesystemeventslistener.onchange(filesystemeventslistener.java:51) @ org.eclipse.virgo.util.io.filesystemchecker.notifylisteners(filesystemchecker.java:245) @ org.eclipse.virgo.util.io.filesystemchecker.check(filesystemchecker.java:166) @ com.sap.core.js.deployer.watchservice.watchtask.run(watchtask.java:29) @ java.lang.thread.run(thread.java:745)| exception sending context destroyed event listener instance of class org.springframework.web.context.contextloaderlistener java.lang.noclassdeffounderror: not initialize class org.apache.log4j.logmanager @ org.slf4j.impl.log4jloggerfactory.getlogger(log4jloggerfactory.java:64) @ org.slf4j.loggerfactory.getlogger(loggerfactory.java:270) @ org.apache.commons.logging.impl.slf4jlogfactory.getinstance(slf4jlogfactory.java:156) @ org.apache.commons.logging.impl.slf4jlogfactory.getinstance(slf4jlogfactory.java:132) @ org.apache.commons.logging.logfactory.getlog(logfactory.java:272) @ org.springframework.web.context.contextcleanuplistener.<clinit>(contextcleanuplistener.java:43) @ org.springframework.web.context.contextloaderlistener.contextdestroyed(contextloaderlistener.java:144) @ org.apache.catalina.core.standardcontext.listenerstop(standardcontext.java:5035) @ org.apache.catalina.core.standardcontext.stopinternal(standardcontext.java:5687) @ org.apache.catalina.util.lifecyclebase.stop(lifecyclebase.java:232) @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:160) @ org.apache.catalina.core.containerbase.addchildinternal(containerbase.java:901) @ org.apache.catalina.core.containerbase.addchild(containerbase.java:877) @ org.apache.catalina.core.standardhost.addchild(standardhost.java:649) @ org.eclipse.gemini.web.tomcat.internal.tomcatservletcontainer.startwebapplication(tomcatservletcontainer.java:125) @ org.eclipse.gemini.web.internal.standardwebapplication.start(standardwebapplication.java:109) @ org.eclipse.gemini.web.extender.webcontainerbundlecustomizer.addingbundle(webcontainerbundlecustomizer.java:49) @ org.osgi.util.tracker.bundletracker$tracked.customizeradding(bundletracker.java:482) @ org.osgi.util.tracker.bundletracker$tracked.customizeradding(bundletracker.java:1) @ org.osgi.util.tracker.abstracttracked.trackadding(abstracttracked.java:262) @ org.osgi.util.tracker.abstracttracked.track(abstracttracked.java:234) @ org.osgi.util.tracker.bundletracker$tracked.bundlechanged(bundletracker.java:457) @ org.eclipse.osgi.framework.internal.core.bundlecontextimpl.dispatchevent(bundlecontextimpl.java:847) @ org.eclipse.osgi.framework.eventmgr.eventmanager.dispatchevent(eventmanager.java:230) @ org.eclipse.osgi.framework.eventmgr.listenerqueue.dispatcheventsynchronous(listenerqueue.java:148) @ org.eclipse.osgi.framework.internal.core.framework.publishbundleeventprivileged(framework.java:1523) @ org.eclipse.osgi.framework.internal.core.framework.publishbundleevent(framework.java:1459) @ org.eclipse.osgi.framework.internal.core.framework.publishbundleevent(framework.java:1454) @ org.eclipse.osgi.framework.internal.core.bundlehost.startworker(bundlehost.java:391) @ org.eclipse.osgi.framework.internal.core.abstractbundle.start(abstractbundle.java:299) @ org.eclipse.osgi.framework.internal.core.abstractbundle.start(abstractbundle.java:291) @ com.sap.core.js.deployer.watchservice.wardeployer.update(wardeployer.java:313) @ com.sap.core.js.deployer.watchservice.filesystemeventslistener.onchange(filesystemeventslistener.java:51) @ org.eclipse.virgo.util.io.filesystemchecker.notifylisteners(filesystemchecker.java:245) @ org.eclipse.virgo.util.io.filesystemchecker.check(filesystemchecker.java:166) @ com.sap.core.js.deployer.watchservice.watchtask.run(watchtask.java:29) @ java.lang.thread.run(thread.java:745)|
solution: decided problem in following way: in pom.xml add these dependencies:
<dependency> <groupid>xerces</groupid> <artifactid>xercesimpl</artifactid> <version>2.11.0</version> </dependency> <dependency> <groupid>xalan</groupid> <artifactid>xalan</artifactid> <version>2.7.2</version> </dependency>
Comments
Post a Comment