导入Icake源码,登陆出错。InvocationTargetException

导入Icake源码,登陆出错。InvocationTargetException

"D:\Tomcat 8.5\bin\catalina.bat" run
[2019-11-03 03:06:06,486] Artifact icake:war exploded: Waiting for server connection to start artifact deployment...
Using CATALINA_BASE:   "C:\Users\Administrator\.IntelliJIdea2019.2\system\tomcat\Unnamed_icake_2"
Using CATALINA_HOME:   "D:\Tomcat 8.5"
Using CATALINA_TMPDIR: "D:\Tomcat 8.5\temp"
Using JRE_HOME:        "C:\Program Files\Java\jdk1.8.0_201"
Using CLASSPATH:       "D:\Tomcat 8.5\bin\bootstrap.jar;D:\Tomcat 8.5\bin\tomcat-juli.jar"
03-Nov-2019 15:06:07.938 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/8.5.45
03-Nov-2019 15:06:07.941 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Aug 14 2019 22:21:25 UTC
03-Nov-2019 15:06:07.941 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         8.5.45.0
03-Nov-2019 15:06:07.942 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Windows 10
03-Nov-2019 15:06:07.942 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            10.0
03-Nov-2019 15:06:07.942 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
03-Nov-2019 15:06:07.942 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             C:\Program Files\Java\jdk1.8.0_201\jre
03-Nov-2019 15:06:07.942 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.8.0_201-b09
03-Nov-2019 15:06:07.942 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
03-Nov-2019 15:06:07.942 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         C:\Users\Administrator\.IntelliJIdea2019.2\system\tomcat\Unnamed_icake_2
03-Nov-2019 15:06:07.942 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         D:\Tomcat 8.5
03-Nov-2019 15:06:07.943 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\Administrator\.IntelliJIdea2019.2\system\tomcat\Unnamed_icake_2\conf\logging.properties
03-Nov-2019 15:06:07.943 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
03-Nov-2019 15:06:07.943 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=
03-Nov-2019 15:06:07.943 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099
03-Nov-2019 15:06:07.943 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
03-Nov-2019 15:06:07.943 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.password.file=C:\Users\Administrator\.IntelliJIdea2019.2\system\tomcat\Unnamed_icake_2\jmxremote.password
03-Nov-2019 15:06:07.944 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.access.file=C:\Users\Administrator\.IntelliJIdea2019.2\system\tomcat\Unnamed_icake_2\jmxremote.access
03-Nov-2019 15:06:07.944 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1
03-Nov-2019 15:06:07.944 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
03-Nov-2019 15:06:07.944 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
03-Nov-2019 15:06:07.944 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
03-Nov-2019 15:06:07.944 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\Administrator\.IntelliJIdea2019.2\system\tomcat\Unnamed_icake_2
03-Nov-2019 15:06:07.945 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=D:\Tomcat 8.5
03-Nov-2019 15:06:07.945 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=D:\Tomcat 8.5\temp
03-Nov-2019 15:06:07.945 信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jdk1.8.0_201\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;D:\Xshell\;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Java\jdk-10\bin;C:\Program Files\Java\jdk1.8.0_201\bin;C:\Program Files\Java\jdk1.8.0_201\jre\bin;D:\apache-maven-3.6.2\bin;C:\Program Files\MySQL\MySQL Shell 8.0\bin\;D:\IntelliJ IDEA 2019.2.3\bin;;.]
03-Nov-2019 15:06:08.114 信息 [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
03-Nov-2019 15:06:08.175 信息 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
03-Nov-2019 15:06:08.338 信息 [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
03-Nov-2019 15:06:08.344 信息 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
03-Nov-2019 15:06:08.344 信息 [main] org.apache.catalina.startup.Catalina.load Initialization processed in 984 ms
03-Nov-2019 15:06:08.403 信息 [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
03-Nov-2019 15:06:08.403 信息 [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.45
03-Nov-2019 15:06:08.418 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
03-Nov-2019 15:06:08.430 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
03-Nov-2019 15:06:08.433 信息 [main] org.apache.catalina.startup.Catalina.start Server startup in 88 ms
Connected to server
[2019-11-03 03:06:08,830] Artifact icake:war exploded: Artifact is being deployed, please wait...
03-Nov-2019 15:06:10.806 信息 [RMI TCP Connection(3)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
[2019-11-03 03:06:12,305] Artifact icake:war exploded: Artifact is deployed successfully
[2019-11-03 03:06:12,306] Artifact icake:war exploded: Deploy took 3,476 milliseconds
03-Nov-2019 15:06:18.425 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [D:\Tomcat 8.5\webapps\manager]
03-Nov-2019 15:06:18.590 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [D:\Tomcat 8.5\webapps\manager] has finished in [164] ms
java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.imooc.icake.global.GlobalController.service(GlobalController.java:51)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at com.imooc.icake.global.EncodingFilter.doFilter(EncodingFilter.java:22)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:528)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:810)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NumberFormatException: null
	at java.lang.Integer.parseInt(Integer.java:542)
	at java.lang.Integer.parseInt(Integer.java:615)
	at com.imooc.icake.controller.DefaultController.detail(DefaultController.java:69)
	... 30 more

错误日志信息。

正在回答

登陆购买课程后可参与讨论,去登陆

1回答

同学你好。从报错信息可以看到,真正的报错是DefaultController中的detail方法里,parseInt时出现了空指针异常:

http://img1.sycdn.imooc.com//climg/5dbe92790922d51606550076.jpg

那么去代码中寻找,可以看到这里parseInt的参数是直接从request中直接获取的参数,也就是在请求的时候,不能只使用“http://localhost:8080/detail.do”,应该在后面带上id呢~

http://img1.sycdn.imooc.com//climg/5dbe94780933958613030294.jpg

如果解答了同学的疑问,望采纳~

祝学习愉快~

  • 慕尼黑0101671 提问者 #1
    也就是说那个源码里面也是有问题的么
    2019-11-04 08:14:43
  • 芝芝兰兰 回复 提问者 慕尼黑0101671 #2
    同学你好。同学访问一下“http://localhost:8080/detail.do?id=100”试一下呢?即便在登录后,直接访问“http://localhost:8080/detail.do”而不带id都是会报错的呢~因为没有id,就无法区分想要访问的是哪一个蛋糕的详情,自然是无法展示的。这是符合逻辑的呢,不是代码的问题哦~祝学习愉快~
    2019-11-04 10:50:44
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师