java - 访问地址时出现服务器错误,但没有堆栈跟踪
问题描述
我有一个带有单个映射的 hybris 网站。每次我尝试访问特定的网址时:
有没有办法调试这样的错误?
这是页面的控制器:
@Controller
@RequestMapping(value = "/cart")
public class CartPageController extends AbstractPageController
{
private static final String CART_CMS_PAGE = "cartPage";
private static final Integer DEFAULT_COOKIE_EXPIRY_AGE = 5184000;
private static final String DEFAULT_CART_IDENTIFIER_COOKIE_NAME = "cart.identifier.cookie.name";
private static final Logger LOG = Logger.getLogger(CartPageController.class);
@Resource(name = "cartFacade")
private CartFacade cartFacade;
@Resource(name = "userService")
private UserService userService;
@Resource(name = "baseStoreService")
private BaseStoreService baseStoreService;
@Resource(name = "catalogVersionService")
private CatalogVersionService catalogVersionService;
@RequestMapping(method = RequestMethod.GET)
public String showCart(HttpServletRequest request, HttpServletResponse response, final Model model)
throws CMSItemNotFoundException
{
CartData cartData = cartFacade.getSessionCartWithEntryOrdering(true);
final String cartCookieIdentifier = getCartCookieIdentifier();
if (!cartFacade.hasEntries())
{
final String cartId = getCookieValue(request, cartCookieIdentifier);
final Optional<CartData> cartDataOptional = cartFacade.getCartsForCurrentUser().stream()
.filter(c -> c.getCode().equals(cartId)).findFirst();
if (cartDataOptional.isPresent())
{
cartData = cartDataOptional.get();
}
}
setCookieValue(response, cartCookieIdentifier, cartData.getCode());
model.addAttribute("cart", cartData);
setupPageModel(model);
String model1 = getViewForPage(model);
return model1;
}
protected void setupPageModel(Model model) throws CMSItemNotFoundException
{
storeCmsPageInModel(model, getContentPageForLabelOrId(CART_CMS_PAGE));
setUpMetaDataForContentPage(model, getContentPageForLabelOrId(CART_CMS_PAGE));
}
protected String getCookieValue(final HttpServletRequest request, final String cookieName)
{
return Arrays.stream(request.getCookies())
.filter(c -> c.getName().equals(cookieName))
.findFirst()
.map(Cookie::getValue)
.orElse(null);
}
protected void setCookieValue(final HttpServletResponse response, final String cookieName, final String cookieValue)
{
final Cookie cookie = new Cookie(cookieName, cookieValue);
cookie.setMaxAge(DEFAULT_COOKIE_EXPIRY_AGE);
response.addCookie(cookie);
}
protected String getCartCookieIdentifier()
{
final String baseStoreId = getCurrentBaseStoreId();
final String catalogId = getCurrentProductCatalogId();
if (StringUtils.isNotEmpty(baseStoreId) && StringUtils.isNotEmpty(catalogId))
{
return baseStoreId + "-" + catalogId;
}
return DEFAULT_CART_IDENTIFIER_COOKIE_NAME;
}
protected String getCurrentBaseStoreId()
{
final BaseStoreModel baseStore = baseStoreService.getCurrentBaseStore();
return baseStore == null ? StringUtils.EMPTY : baseStore.getUid();
}
protected String getCurrentProductCatalogId()
{
for (final CatalogVersionModel catalogVersionModel : catalogVersionService.getSessionCatalogVersions())
{
if (!((catalogVersionModel.getCatalog() instanceof ContentCatalogModel) || (catalogVersionModel
.getCatalog() instanceof ClassificationSystemModel)))
{
return catalogVersionModel.getCatalog().getId();
}
}
return StringUtils.EMPTY;
}
}
页面的内容jsp
并不那么重要,因为它可能是空的,并且这种行为仍然会发生。我不知道这到底是什么原因。是否有任何有效的方法来调试此类问题?
解决方案
这是创建 B2B 站点时的常见错误。一种解决方法是打开 /smartedit 并从那里登录到您的站点。Hybris 将创建一个适当的会话,您应该能够打开该站点。
可能的长期解决方案:如果您正在创建 B2B 站点,请检查您的 Storefront 扩展中的 spring-filter-config.xml 并检查此部分。它应该如下所示:
<alias name="b2cAcceleratorSiteChannels" alias="acceleratorSiteChannels"/>
<util:set id="b2cAcceleratorSiteChannels" value-type="de.hybris.platform.commerceservices.enums.SiteChannel">
<ref bean="SiteChannel.B2C"/>
<ref bean="SiteChannel.B2B"/>
</util:set>
如果一切正常,您可以删除 SiteChannel.B2C
推荐阅读
- python - 深度学习 YOLO 对象检测:如何迭代图像上定义的网格中的单元格
- macros - Racket:由定义为 macroname.0 的宏生成的宏
- hdfs - 对象存储的 HDFS 连接器:不包含有效的主机:端口权限
- python - Python regexp 捕获多行组
- python - Python:速率限制脚本的多次执行
- c++ - 有没有办法在 C++ 源代码中用空格编写大量数字以使其更具可读性?
- mysql - 带参数的 MySQL 函数出错
- .htaccess - 无法重定向查询字符串 url
- openshift - openshift 指标部署程序错误
- javascript - 使用 fs-extra 和 Chokidar node.js 同步文件