2019-07-30 09:35

报错位置:
protected void doStart() throws Exception {
try {
this._metadata.setAllowDuplicateFragmentNames(this.isAllowDuplicateFragmentNames());
Boolean validate = (Boolean)this.getAttribute("org.eclipse.jetty.webapp.validateXml");
this._metadata.setValidateXml(validate != null && validate);
this.preConfigure();
super.doStart();
this.postConfigure();
if (this.isLogUrlOnStart()) {
this.dumpUrl();
}
} catch (Throwable var2) {
LOG.warn("Failed startup of context " + this, var2); // 这里打出的异常信息
this._unavailableException = var2;
this.setAvailable(false);
if (this.isThrowUnavailableOnStartupException()) {
throw var2;
}
}


java.lang.NoClassDefFoundError: com/alibaba/druid/pool/DruidDataSource
at com.jfinal.plugin.druid.DruidPlugin.start(DruidPlugin.java:180)
at com.config.MainConfig.configPlugin(MainConfig.java:94)
at com.jfinal.core.Config.configPluginWithOrder(Config.java:70)
at com.jfinal.core.Config.configJFinal(Config.java:59)
at com.jfinal.core.JFinal.init(JFinal.java:61)
at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:63)
at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:139)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:741)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:374)
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1497)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1459)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:847)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:287)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
at org.eclipse.jetty.server.Server.start(Server.java:416)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
at org.eclipse.jetty.server.Server.doStart(Server.java:383)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at com.jfinal.server.jetty.JettyServer.doStart(JettyServer.java:154)
at com.jfinal.server.jetty.JettyServer.start(JettyServer.java:70)
at com.jfinal.core.JFinal.start(JFinal.java:160)
at com.jfinal.core.JFinal.start(JFinal.java:182)
at com.config.MainConfig.main(MainConfig.java:25)
Caused by:
java.lang.ClassNotFoundException: com.alibaba.druid.pool.DruidDataSource
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:565)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at com.jfinal.plugin.druid.DruidPlugin.start(DruidPlugin.java:180)
at com.config.MainConfig.configPlugin(MainConfig.java:94)
at com.jfinal.core.Config.configPluginWithOrder(Config.java:70)
at com.jfinal.core.Config.configJFinal(Config.java:59)
at com.jfinal.core.JFinal.init(JFinal.java:61)
at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:63)
at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:139)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:741)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:374)
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1497)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1459)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:847)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:287)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
at org.eclipse.jetty.server.Server.start(Server.java:416)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
at org.eclipse.jetty.server.Server.doStart(Server.java:383)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at com.jfinal.server.jetty.JettyServer.doStart(JettyServer.java:154)
at com.jfinal.server.jetty.JettyServer.start(JettyServer.java:70)
at com.jfinal.core.JFinal.start(JFinal.java:160)
at com.jfinal.core.JFinal.start(JFinal.java:182)
at com.config.MainConfig.main(MainConfig.java:25)

2019-07-30 09:28

DruidPlugin druidPlugin = new DruidPlugin(p.get("jdbcUrl"), p.get("user"), p.get("password").trim());
try {
druidPlugin.start(); //此行报错
ActiveRecordPlugin arp = new ActiveRecordPlugin("MysqlConnect", druidPlugin);
arp.start();


List resultRecordList = new ArrayList<>();
resultRecordList = Db.use("MysqlConnect").find("SELECT * FROM blog");

for (Record ItemRc : resultRecordList) {
System.out.println(ItemRc.get("title").toString());
}
}
catch (Exception e)
{
e.printStackTrace();
System.out.println (e.getMessage());
}

问题1, druidPlugin.start(); 报错:
2019-07-30 09:21:23.022:WARN:oejw.WebAppContext:main: Failed startup of context o.e.j.w.WebAppContext@6379eb{/,file:///E:/work/DataCore/DbCore/web/,UNAVAILABLE}
java.lang.NoClassDefFoundError: com/alibaba/druid/pool/DruidDataSource
at com.jfinal.plugin.druid.DruidPlugin.start(DruidPlugin.java:180)
at com.config.MainConfig.configPlugin(MainConfig.java:94)
at com.jfinal.core.Config.configPluginWithOrder(Config.java:70)
at com.jfinal.core.Config.configJFinal(Config.java:59)
at com.jfinal.core.JFinal.init(JFinal.java:61)
at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:63)
at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:139)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:741)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:374)
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1497)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1459)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:847)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:287)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
at org.eclipse.jetty.server.Server.start(Server.java:416)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
at org.eclipse.jetty.server.Server.doStart(Server.java:383)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at com.jfinal.server.jetty.JettyServer.doStart(JettyServer.java:154)
at com.jfinal.server.jetty.JettyServer.start(JettyServer.java:70)
at com.jfinal.core.JFinal.start(JFinal.java:160)
at com.jfinal.core.JFinal.start(JFinal.java:182)
at com.config.MainConfig.main(MainConfig.java:25)

2019-07-29 15:41

问题已搞定, 是路径设置问题导致的,多谢支持!

2019-07-26 10:29

blog例子已经可以运行通过,自己重建一个工程却跑不通

http://www.jfinal.com/feedback/6252 这个贴子我也看了,问题还是没有解决。

我的web文件夹目录是 “web” ,
修正方法调用 JFinal.start("web", 80, "/");
可以依然还是无法调用到 configRoute 、configConstant 方法,感觉是配置不对,但不清楚是该配置哪? 求指导一下。


< filter >
< filter-name > jfinal
< filter-class > com.jfinal.core.JFinalFilter
< init-param >
< param-name > configClass
< param-value > com.demo.common.DemoConfig



< filter-mapping >
< filter-name > jfinal
< url-pattern > /*

2019-07-25 18:04

报错信息:
HTTP ERROR 404
Problem accessing /. Reason:
Not Found


Powered by Jetty:// 9.4.z-SNAPSHOT

下面是代码信息


web.xml 配置如下:

< filter >
< filter-name >jfinal< /filter-name>
< filter-class >com.jfinal.core.JFinalFilter
< init-param >
< param-name > configClass < /param-name>
< param-value >com.demo.common.DemoConfig< /param-value >


< filter-mapping >
< filter-name > jfinal < /filter-name >
< url-pattern >/*




-----------------------------------------
com.demo.common.DemoConfig 代码如下:
-----------------------------------------

package com.demo.common;
import com.demo.index.IndexController;
import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.core.JFinal;
import com.jfinal.kit.Prop;
import com.jfinal.kit.PropKit;
import com.jfinal.template.Engine;

public class DemoConfig extends JFinalConfig {
static Prop p;
public static void main(String[] args) {
JFinal.start("WebRoot", 80, "/");
}

static void loadConfig() {
if (p == null) {
p = PropKit.useFirstFound("demo-config-pro.txt", "demo-config-dev.txt");
}
}


public void configConstant(Constants me) {
loadConfig();

me.setDevMode(p.getBoolean("devMode", false));
me.setInjectDependency(true);
me.setInjectSuperClass(true);
}

/**
* 配置路由
*/
public void configRoute(Routes me) {
me.add("/", IndexController.class, "/index"); // 第三个参数为该Controller的视图存放路径
}

public void configEngine(Engine me) {
}

public void configPlugin(Plugins me) {
}


public void configInterceptor(Interceptors me) {
}

public void configHandler(Handlers me) {
}
}

-----------------------------------------
IndexController 代码如下:
-----------------------------------------

package com.demo.index;

import com.jfinal.core.Controller;

public class IndexController extends Controller {
public void index() {
renderText(" hello OK ");

}
}


IDE 为 IntelliJ IDFEA 2019 ,JFinal 4.3 , jetty 启用

根据提示,应该是程序根本就没有调用 com.demo.common.DemoConfig , 不清楚是什么地方没配置对? 希望专家给予指导,谢谢,