400 error (Bad Request) creating a Page with Experience Manager - tridion

I have an SDL Tridion 2011 SP1 HR1 image in which Experience Manager is installed. I can successfully browse my staging site, log in to ExM and change content and pages. However, when I try to create a new page I get a 400 (Bad Request) error. This is the logged error:
Unable to update the changes using OData Service.
The remote server returned an error: (400) Bad Request.
Component: Tridion.SiteEdit.FastTrackPublishing
Errorcode: 1003
User: NT AUTHORITY\NETWORK SERVICE
StackTrace Information Details:
at System.Net.HttpWebRequest.GetResponse()
at System.Data.Services.Client.DataServiceContext.SaveResult.BatchRequest(Boolean replaceOnUpdate)
at System.Data.Services.Client.DataServiceContext.SaveChanges(SaveChangesOptions options)
at Tridion.SiteEdit.FastTrackPublishing.ServiceImplementation.Preview(IEnumerable1 publishedItemsInfo, TcmUri publishingTargetId)
at Tridion.SiteEdit.FastTrackPublishing.ServiceImplementation.Preview(IEnumerable1 publishedItemsInfo, TcmUri publishingTargetId)
at SyncInvokePreview(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
I've just checked the CD log file and can see this error:
012-10-16 12:29:05,782 ERROR JPADAOFactory - Unable to load JPA DAO with name: TrackedRequest and class: com.tridion.storage.TrackedRequestDAO due too exception in DAO construction
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'TrackedRequestDAO' defined in URL [jar:file:/C:/ASP.NET/Preview/httpupload/bin/lib/tracking_core.jar!/com/tridion/storage/TrackedRequestDAO.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.tridion.storage.TrackedRequestDAO]: Constructor threw exception; nested exception is com.tridion.configuration.ConfigurationException: Unexpected dialect encountered: . TrackedRequest item type should be configured to use a supported database.
Inline editing was enabled for the already published content when I received the image but I needed to create the Content Type and Page Type myself. I did this in the usual manner, creating a Page, flagging it as a Page Type, adding the prototype content to it, and configuring the settings for naming and storage (for the created content). I also restarted IIS, shutdown the COM+ package and restarted the Tridion Service Host and Publisher services.
Can anyone explain why I'm getting this error, and how to fix it?
EDIT
So the error suggests it's an issue in the storage config. Here are the relevant sections:
<Storage Id="trackingDB" Class="com.tridion.storage.persistence.JPADAOFactory" Type="persistence" dialect="MSSQL">
<Pool CheckoutTimeout="120" IdleTimeout="120" MonitorInterval="60" Size="5" Type="jdbc"/>
<DataSource Class="com.microsoft.sqlserver.jdbc.SQLServerDataSource">
<Property Name="serverName" Value="SDLPE.pe.local"/>
<Property Name="portNumber" Value="1433"/>
<Property Name="databaseName" Value="tridion_tracking"/>
<Property Name="user" Value="encrypted:u9aIOj9uX2IcL1rI6U5ndA=="/>
<Property Name="password" Value="encrypted:vprUfrnluvIQAVRNSMTx5g=="/>
</DataSource>
</Storage>
And:
<Item cached="true" typeMapping="TrackedRequest" storageId="trackingDB"/>
EDIT
I've just been trawling through the log file and found this:
2012-10-16 14:12:43,148 DEBUG ConfigurationItemTypeLoader - Loaded mapping: trackedrequest to storage: trackingDB
2012-10-16 14:12:43,148 DEBUG ConfigurationItemTypeLoader - Loaded mapping: trackingbatch to storage: trackingDB
2012-10-16 14:12:43,148 DEBUG ConfigurationItemTypeLoader - Loaded mapping: synchronizationrecord to storage: trackingDB
2012-10-16 14:12:43,148 DEBUG ConfigurationItemTypeLoader - Loaded mapping: trackingitem to storage: trackingDB
It seems that the config should be picked up correctly, but still it can't read the dialect propely from the relevant storage definition.

In the end the issue was related to having Page Metadata specified for the Page Type. The errors I was seeing logged don't affect the performance of the website so were misleading me.

Related

Spring Boot exception: Could not open ServletContext resource [/WEB-INF/dispatcherServlet-servlet.xml]

I have developed this proof of concept https://github.com/DISID/disid-proofs/tree/master/spring-boot-weblogic to test the deployment of Spring Boot applications in Weblogic 12c (12.2.1).
The application deploys and starts successfully, but when I try to connect to it (i.e. /accounts?number=1234) the error below is shown:
Error 500--Internal Server Error
From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.5.1 500 Internal Server Error
The server encountered an unexpected condition which prevented it
from fulfilling the request.
And the log file has the exception:
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/dispatcherServlet-servlet.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/dispatcherServlet-servlet.xml]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:344)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:609)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:510)
at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run
Did I miss something?
Thanks,
I found a workaround putting a dummy dispatcherServlet-servlet.xml file under WEB-INF:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- Do not remove this file! -->
</beans>
I've reproduced this issue with WebLogic 12.2.1.0 (plain new install) using spring-boot-sample-war (with an additional weblogic.xml to handle logging). Also tried the latest patchset (WLS PATCH SET UPDATE 12.2.1.0.160419), but the issue remains.
For some reason WebLogic decides it needs to create the DispatcherServlet using it's own configuration as soon as you access the application available on /.
I've put in a service request to Oracle Support and we'll see what they think about this issue.
Update: 'Patch 23124727: CANNOT DEPLOY SPRING BOOT .WAR ON 12.2.1 DUE TO JAVA.IO.FILENOTFOUNDEXCEPTION' is available for Oracle WebLogic Server 12.2.1.0.0 and works with both the spring-boot-sample-war as well as a more advanced application.

Spring Security Active Directory bad credentials handling (error 49)

I have problem with Active Directory authentication in simple Spring web application. I'm using ActiveDirectoryLdapAuthenticationProvider and it seems to work fine for empty login fields and correct credentials. The problem is with invalid credentials (wrong login/pass or both). The application throws exception (error 500) to browser:
Error processing request
Context Path: /MYAPPNAME
Servlet Path: /login_check
Path Info: null
Query String: null
Stack Trace:
org.springframework.ldap.UncategorizedLdapException: Uncategorized exception occured during LDAP processing; nested exception is javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory com.sun.jndi.ldap.LdapCtxFactory from classloader ModuleClassLoader for Module "deployment.MYAPPNAME.war:main" from Service Module Loader [Root exception is javax.naming.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C090334, comment: AcceptSecurityContext error, data 52e, vece]] (...)
The console root error is:
javax.naming.AuthenticationException: [LDAP: error code 49 - 80090308:
LdapErr: DSID-0C090334, comment: AcceptSecurityContext error, data 52e, vece]
If the credentials are incorrect, shouldn't Spring send user to authentication-failure-url? I don't have any "manager" account to use for ldap BIND, I believe ActiveDirectoryLdapAuthenticationProvider is supposed to bind using credentials from login form. Spring documentation doesn't have anything about binding to AD.
It can probably be solved using custom authentication provider, but I was hoping there is an out-of-the-box solution. There are some similar questions, but none of them very precise or with any useful answer.
How to approach this error?
Is there a way to configure it in XML? Perhaps, to tell AD provider to tread binding error as failed login attempt?
Is custom authentication provider the only solution?
spring-security.xml
<bean id="roleVoter" class="org.springframework.security.access.vote.RoleVoter">
<property name="rolePrefix" value="" />
</bean>
<bean id="accessDecisionManager" class="org.springframework.security.access.vote.AffirmativeBased">
<constructor-arg name="decisionVoters" ref="roleVoter" />
</bean>
<s:http authentication-manager-ref="ldap-auth" access-decision-manager-ref="accessDecisionManager" use-expressions="false">
<s:intercept-url pattern="/list**" access="ADGROUP-XYZ" />
<s:form-login
login-page="/login"
login-processing-url="/login_check"
username-parameter="username"
password-parameter="password"
default-target-url="/list"
authentication-failure-url="/login?fail" />
<s:logout
invalidate-session="true"
logout-success-url="/login?logout"
logout-url="/logout"
delete-cookies="JSESSIONID" />
<s:csrf />
</s:http>
<s:authentication-manager id="ldap-auth">
<s:authentication-provider ref="adAuthenticationProvider" />
</s:authentication-manager>
<bean id="adAuthenticationProvider" class="org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider">
<constructor-arg value="company.local" />
<constructor-arg value="ldap://server.company.local:389/" />
<property name="useAuthenticationRequestCredentials" value="true"/>
<property name="convertSubErrorCodesToExceptions" value="true"/>
</bean>
EDIT: One ugly fix is to override ActiveDirectoryLdapAuthenticationProvider and change throw LdapUtils.convertLdapException(e); to throw badCredentials(e);.
There is a issue with JBoss EAP initial context.This has been fixed in the latest wildfly versions.check the below links
https://jira.spring.io/browse/SEC-2754
https://issues.jboss.org/browse/WFLY-4149

Thymeleaf template engine swallowing exceptions

I'm using thymeleaf 2.0.5 with spring 3 mvc configured as follows in webmvc-config.xml
<bean id="templateResolver"
class="org.thymeleaf.templateresolver.ServletContextTemplateResolver"
p:prefix="/WEB-INF/templates/"
p:suffix=".html"
p:templateMode="HTML5" />
<bean id="templateEngine"
class="org.thymeleaf.spring3.SpringTemplateEngine"
p:templateResolver-ref="templateResolver" />
<bean id="viewResolver"
class="org.thymeleaf.spring3.view.ThymeleafViewResolver"
p:templateEngine-ref="templateEngine" />
The above configuration is working fine. The problem is that when an exception is thrown I see the following cryptic message in the logs:
ERROR org.thymeleaf.TemplateEngine - [THYMELEAF][1] Exception processing template "dataAccessFailure": Error resolving template "dataAccessFailure", template might not exist or might not be accessible by any of the configured Template Resolvers
Is there a way to configure the view resolver to exclude certain patterns?
As per the accepted answer I changed the following bean config in webmvc-config.xml
<bean id="viewResolver"
class="org.thymeleaf.spring3.view.ThymeleafViewResolver"
p:templateEngine-ref="templateEngine"
p:viewNames="index,questionnaires/*" />
You can configure your template resolver to only resolve certain view names by means of the template resolver's viewNames property. In this property you can enter several patterns (separated by commas) and use wildcards like e.g. admin/*.
Disclaimer, due to StackOverflow rules: I am thymeleaf's author.
Could you possibly have an error page mapped to "dataAccessFailure" in your web.xml. Something like:
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/dataAccessFailure</location>
</error-page>

Reduce logs generated by SpringMVC application

I have a SpringMVC 3 application which uses Spring Security, AOP, HIbernate etc.
But when I run it in Tomcat or Jetty, it generates a huge amount of log.
How can I reduce this log?
I want a log level starting from WARNING.
Example of the log:
21:16:08.393 [qtp12506312-25] DEBUG o.s.s.w.s.HttpSessionEventPublisher - Publishing event: org.springframework.security.web.session.HttpSessi onCreatedEvent[source=org.eclipse.jetty.server.session.HashedSess ion:db7nzoxke45es1k02gbug79d#6784961]
21:16:08.394 [qtp12506312-25] DEBUG o.s.s.w.s.HttpSessionRequestCache - DefaultSavedRequest added to Session: DefaultSavedRequest[http://xx.xx.xx.xx:8080/favicon.ico]
21:16:08.394 [qtp12506312-25] DEBUG o.s.s.w.a.ExceptionTranslationFilter - Calling Authentication entry point.
21:16:08.440 [qtp12506312-25] DEBUG o.s.s.web.DefaultRedirectStrategy - Redirecting to 'http://xx.xx.xx.xx:8080/default;jsessionid=db7nzoxke45es1k02gbug79d'
21:16:08.441 [qtp12506312-25] DEBUG o.s.s.w.c.HttpSessionSecurityContextRepository - SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession.
21:16:08.441 [qtp12506312-25] DEBUG o.s.s.w.c.SecurityContextPersistenceFilter - SecurityContextHolder now cleared, as request processing completed
21:16:08.518 [qtp12506312-26] DEBUG o.s.s.web.util.AntPathRequestMatcher - Checking match of request : '/default'; against '/loginform.jsp'
21:16:08.518 [qtp12506312-26] DEBUG o.s.s.web.util.AntPathRequestMatcher - Checking match of request : '/default'; against '/loginform2.jsp'
21:16:08.518 [qtp12506312-26] DEBUG o.s.s.web.util.AntPathRequestMatcher - Checking match of request : '/default'; against '/default'
21:16:08.518 [qtp12506312-26] DEBUG o.s.security.web.FilterChainProxy - /default has an empty filter list
If you are using logback for logging then change the root logger's log lever to WARNING, you can find the logback.xml file in the classpath
Ex:
<root level="WARN">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
If you are using log4j, you can find the log4j.properties file in your classpath. Change the rootlogger level to WARNING again
log4j.rootLogger=WARNING , A1

External properties loader with Tomcat server

I am trying to deploy a spring mvc webapp into a tomcat server. I have been testing locally using the maven-jetty-plugin. In my spring configuration I am using a properties placeholder, and pulling my properties from an external file:
<context:property-placeholder ignore-resource-not-found="true" ignore-unresolvable="true"/>
<bean id="modelPropertyPlaceholder" class="org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer">
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
<property name="searchContextAttributes" value="true"/>
<property name="contextOverride" value="true"/>
<property name="ignoreResourceNotFound" value="true"/>
<property name="ignoreUnresolvablePlaceholders" value="true"/>
<property name="locations">
<list>
<value>classpath:default.model.properties</value>
<value>file:/etc/app/app.properties</value>
<value>${config}</value>
</list>
</property>
</bean>
This worked with my jetty plugin...however when I deploy the WAR file to the tomcat server I receive the following error:
org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
In my external properties file I have the driver class and connect url defined. as so:
jndi.jpa.rms.datasource=jdbc/testDS
rms.db.driver=com.mysql.jdbc.Driver
rms.db.url=jdbc:mysql://testdatabaseurl:3306/test
rms.db.user=sa
rms.db.password=asfdas
rms.db.checkconnsql=select 1
rms.hibernate.generateddl=false
rms.hibernate.showsql=true
rms.hibernate.dbdialect=org.hibernate.dialect.MySQLDialect
Update:
It seems that tomcat does pickup the external properties file:
14:23:09.803 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Finished creating instance of bean 'modelPropertyPlaceholder'
14:23:09.810 [main] INFO o.s.w.c.s.ServletContextPropertyPlaceholderConfigurer - Loading properties file from class path resource [default.model.properties]
14:23:09.810 [main] INFO o.s.w.c.s.ServletContextPropertyPlaceholderConfigurer - Loading properties file from URL [file:/etc/app/app.properties]
14:23:09.810 [main] INFO o.s.w.c.s.ServletContextPropertyPlaceholderConfigurer - Loading properties file from ServletContext resource [/${config}]
14:23:09.811 [main] WARN o.s.w.c.s.ServletContextPropertyPlaceholderConfigurer - Could not load properties from ServletContext resource [/${config}]: Could not open ServletContext resource [/${config}]
I'm not sure why tomcat isn't picking up the connection url and driver.
Is this a tomcat issue or am I missing something? Thanks
It's not a Tomcat issue, you must have made some minor mistake and properties are not loaded.
Are properties files located in proper place on your Tomcat environment?
Are you sure that in those properties files you have not left some keys blank?
If both answers to that questions are true, try changing your config with following:
<context:property-placeholder location="ADD_PATH_TO_YOUR_FILES SEPARATED_WITH_SPACES"/>
I guess that you are mixing here two property placeholders, one 'regular' and the other - bounded to servlet context. I can bet that somehow they get overlapped and one of them is getting silently ignored.
I would just stick to property-placeholder.
Old question, but...
Judging from the log output, it appears that Spring has not resolved your ${config} reference, or else this would have been substituted into the path given in the last log message:
Could not load properties from ServletContext resource [/${config}]: Could not open ServletContext resource [/${config}]
Here's a case I just encountered where it resolved ${catalina.home}/conf/myprops.properties correctly but was unable to load the referenced file:
Could not load properties from ServletContext resource [/D:/somepath/apache-tomcat/conf/myprops.properties]: Could not open ServletContext resource [/D:/somepath/apache-tomcat/conf/myprops.properties]
I tracked down the error in my case - I needed to prefix the external file reference with 'file:'. That is, it should have been file:${catalina.home}/conf/myprops.properties
(It is possible the Spring version difference may have impacted on the log output for you though also, and that it did resolve the reference but just did not show this in the output. For reference, I'm using Spring 4.1.6 at present).

Resources