struts2使用json返回数据,报错:Parent package is not defined: json-default - [unknown location]

使用struts2的struts-json插件时,一直报错:找不到json-default的位置,下面是我的查错步骤:

1.将struts-json版本更改为低版本,结果还是报这个错
2.重新导入maven依赖,还是不行
3.查看struts-json包内的struts-plugin.xml是否有json-default的package以及json的结果类型,发现有。
4.静下心想了一下整个package的调用过程,都找不到原因
5.最后怀疑是war包的问题,war包内没有这个jar包,打开war包看了一下,确实是这个问题,将jar包放入war包内,问题解决。

下面是报错内容:

 Unable to load configuration. - [unknown location]
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:69)
    at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:957)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:463)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:496)
    at org.apache.struts2.dispatcher.InitOperations.initDispatcher(InitOperations.java:73)
    at org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:61)
    at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:270)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:251)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:102)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4530)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5176)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:713)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:695)
    at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1729)
    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 org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:289)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
    at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:457)
    at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:406)
    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 org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:289)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
    at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:468)
    at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)
    at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
    at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1408)
    at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
    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 sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
    at sun.rmi.transport.Transport$1.run(Transport.java:200)
    at sun.rmi.transport.Transport$1.run(Transport.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: Parent package is not defined: json-default - [unknown location]
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.buildPackageContext(XmlConfigurationProvider.java:689)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:539)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:326)
    at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:108)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:196)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
    ... 55 more

原文地址:https://www.cnblogs.com/mlr-wjy/p/12010298.html

时间: 2024-10-08 02:03:10

struts2使用json返回数据,报错:Parent package is not defined: json-default - [unknown location]的相关文章

Struts2实现文件上传报错(三)

1.具体错误如下 usage: java org.apache.catalina.startup.Catalina [ -config {pathname} ] [ -nonaming ] { -help | start | stop } 2014-5-1 23:17:23 org.apache.catalina.core.AprLifecycleListener init 信息: Loaded APR based Apache Tomcat Native library 1.1.27 usin

Struts2实现文件上传报错(四)

1.具体错误如下 2014-5-2 21:38:29 com.opensymphony.xwork2.util.logging.jdk.JdkLogger error 严重: Exception occurred during processing request: null java.lang.NullPointerException at com.you.file.upload.action.FileUploadAction.execute(FileUploadAction.java:56)

Struts2实现文件上传报错(一)

1.具体报错如下 2014-5-1 23:02:38 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() for servlet [jsp] in context with path [/UploadFile] threw exception [An exception occurred processing JSP page /file.jsp at line 28 25: <table> 26

Struts2实现文件上传报错(二)

编译Lua时,出现这样的错误: gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o lua.o lua.clua.c:67:31: error: 查阅了一下,centOS上需要安装readline-devel ncurses-devel yum install readline-devel ncurses-devel 测试平台成功. [[email protected] lua-5.2.3]# make linux test cd src &

JS请求报错:Unexpected token T in JSON at position 0

<?php /* 最近做一个ajax validate表单验证提交的代码,在ajax提交的时候 JS请求报错:Unexpected token T in JSON at position 0 描述: 这是一个请求,参数的地方报这要的错,请问是为什么? 百思不得其解啊 解决方案1: 去看下json的格式要求,JSON.parse()方法对json串要求很严格 解决方案2: http://www.bejson.com/ 用这个网址测试试试json格式是不是有误,换行,单引号什么的会导致报错,格式要求

VC++ 通过ADO连接数据库查询时返回空值报错的解决方案

当数据库的字段值允许为空时, 而且此时内容也为空时,则执行查询会出错,例如 CString str = pRecordset->GetFields()->GetItem((long)0)->GetValue(); 或者 str= pRecordset->GetCollect("posInfo"); 会弹出如下窗口提示出错! 更加奇怪的是  catch(...)也抓不到异常 今天碰着个问题算是头弄大了  最后终于弄好了 报错的原因:   在GetCollct返回了

mysql数据库中不能插入0000-00-00 00:00:00日期数据(报错Invalid datetime format: 1292 Incorrect datetime value: &#39;0000-00-00 00:00:00&#39;)

报错信息 SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'settlementTime' at row 1 我最后把mysql设置成可空,接受null型 参考:https://yq.aliyun.com/articles/17124 mysql数据库中不能插入0000-00-00 00:00:00日期数据(报错Invalid dat

【微信】微信小程序 微信开发工具中新创建的json文件,编译报错VM1781:2 pages/module/module.json 文件解析错误 SyntaxError: Unexpected end of JSON input

如果新创建报错:编译报错VM1781:2 pages/module/module.json 文件解析错误  SyntaxError: Unexpected end of JSON input 解决方法: 在JSON文件中添加 即可解决 { } 原文地址:https://www.cnblogs.com/sxdcgaq8080/p/9076271.html

mysql插入数据 报错[Err] 1136 - Column count doesn&#39;t match value count at row 1(表中有自增列)

版本:8.0.16 创建了一张表:create table user_table(uid int primary key auto_increment,uname varchar(10))auto_increment=1 插入数据报错: 经查找 ,有三种方式可以解决这个问题: 1.插入数据得时候,带入列名: insert into user_table("uname") values ("刘一") 2.自增键这列设置为0 insert into user_table