WordPress Import Xml Internal Server Error

Musings of a SharePoint Administrator

SharePoint 2013 – Content Deployment fails with error “Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx) at Microsoft.SharePoint.Library.SPRequest.ImportNavigationXml”

After migrating a SharePoint 2007 environment to SharePoint 2013, I encountered countless nightmares during content deployment. I plan to consolidate the whole story in a separate blog.

But thought it would be useful to blog this immediately for those out there still using Content deployment in SharePoint 2013.

Import was failing and the error in ImportExport log was:

[*/*/2014 4:16:21 AM] Verbose: Performing final fixups.

[*/*/2014 4:16:53 AM] FatalError: Cannot complete this action.

Please try again.

[*/*/2014 4:16:53 AM] Debug: at Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx)

at Microsoft.SharePoint.Library.SPRequest.ImportNavigationXml(String bstrUrlWeb, String bstrNavXml, Boolean fClearNavigation)

[*/*/2014 4:17:21 AM] Progress: Import did not complete.

We finally had to open a case with Microsoft and they confirmed it was a bug fixed by http://support.microsoft.com/kb/2837677 and the specific issue is (as one of the issues listed in that KB)

When you use PRIME to import a site in SharePoint Server 2013, the import fails if global navigation is not inherited.

Describe the problem

Import-SPWeb and Content Deployment does not work in SharePoint 2013 if the site structure contains at least one subsite which does not inherit global navigation.

Here are steps took in order to reproduce the navigation error using PRIME

  1. Created a new Site Collection in a Web Application based on Publishing
  2. Created a new Sub-Site under this Site Collection. I chose the option “no” for “Use the top link bar from the parent site”
  3. After creating, exported the top level Site using export-spweb
  4. Then created a new Site Collection with the option to “choose a template later”
  5. Imported the top level Site that was exported in step 3 to the new Site Collection using import-spweb
  6. This failed with the error:

So, the final solution provided by Microsoft was

We went with option 1, hotfix http://support.microsoft.com/kb/2837677 and I am happy to say that content deployment completed successfully.

Yet another lesson that SharePoint achieves reasonable stability only with Service Pack.

Touching SCOM

You want to import the Microsoft Forefront Unified Access Gateway management pack. But you will be hit with an import error showing the message:

Forefront Unified Access Gateway could not be imported.
If any management packs in the Import list are dependent on this management pack, the installation of the dependent management packs will fail.
Database error. MPInfra_p_ManagementPackInstall failed with exception:
Database error. MPInfra_p_ManagementPackInstall failed with exception:
ManagementPack cannot be imported because it contains a Managed Type with the same name as an existing type: Teredo_Server_Class

Looking at the message it looks like the import is failing because there is a name conflict. Every class in SCOM must have a unique internal name. In this case there is already an management pack imported that defined a class with a name “Teredo_Server_Class” . So we are going to look what this MP is.

We are going to use PowerShell for this. Because in the SCOM console we can’t see the internal names , we only see the display names.

Prashant P Java Specialist’s Blog

Your friendly neighborhood coder

REST API exception handling using JAX RS in JEE 6

I couldn’t resist the temptation to control every aspect of my site, thus you will find me at my new internet address http://www.prashantp.org

It’s considered a good practice to use HTTP Status Codes in RESTful APIs for sharing the outcome of an API call.

There are plenty of HTTP Status codes to make use of. Unfortunately complex cases lead developers to returning custom errors rather than sticking to the HTTP standards. But there is a way to stick to the standard and still make use of custom errors as per the application needs. Let’s see an approach using JAXRS Exception mapping providers.

  • For simple requests the service may indeed return a single HTTP response code which makes sense.
  • But for complex requests which fail a more detailed error list (business specific) may be desired.

Let’s start building a JAXRS RESTful service to handle the simple case first and then see what we can do to handle the complex case later using the Exception mapping providers.

Consider a movie library service which returns the list of movies released on a given year.

Resource

Parameters: Year

Setup a Web project

Create a dynamic web project in eclipse and name it jaxrs-movie-service. I have used a JEE 6 server i.e. JBoss 7.

Note: You can use maven and create a maven-archetype-webapp project as well. We won’t need any jars in our lib as JAXRS is part of JEE 6.

Deployment descriptor updates

Update web.xml to match the below

Create an empty beans.xml under WEB-INF folder. (This will enable CDI capabilities which can be made use of if desired).

The source code

Let’s define a POJO which will hold the movie information.

Next, create the REST service which will expose the movie libraries movie list. Here we aren’t using any checked business exception handlers. This is a simple service which returns the HTTP Status code based on conditional constructs.

Once the above code is deployed as a WAR file in a JEE 6 server such as JBoss 7, we can then hit the URL:

jaxrs-movie-service – Is the context name of our application

/movie – Is the REST resource identified by @Path(“/movie”)

1971 – Is the input which maps to the getMovies method via @Path(“/”)

The above should result in the below response:

  • Status Code: 200 OK
  • Content-Type: application/json

This was simple to begin with, but in real world we would have some facade or service layer which would do the processing. The facade may throw business exceptions which would then result in passing a different response code with an appropriate message.

The complex case discussed below explains the same.

Complex case

Consider the movie library service would also require to list out movies based on a genre in the given order of ASC or DESC.

For simplicity let’s say we have only two genres “Action” and “Drama“.

In case of any problem the detailed message must be returned by the REST Service. This means we need to return some error messages along with the right HTTP Status code.

We can start throwing business exceptions but these won’t get translated to an appropriate HTTP Response code.

Here, we make use of Exception Mapping providers. These map a checked or runtime exception to an instance of Response. An exception mapping provider implements the ExceptionMapper interface and is annotated with @Provider.

Resource

Parameters: order, genre

Let’s create a application exception which would contain the error details.

Now, the Exception Mapper which will map our Business Exception to the correct Response code.

The MovieLibrary.java gets a new method as shown below:

If you invoke the service without any of the required parameters, it would return the HTTP status code of 400 along with the detailed messages. This works because our BusinessException thrown during validation checks is processed by the ExceptionHttpStatusResolver which translates the exception to the correct Response code.

When a resource method throws an exception for which there is an exception mapping provider, the matching provider is used to obtain a Response instance. The resulting Response is processed as if the method throwing the exception had instead returned the Response.

The above should result in the below response:

  • Status Code: 400 Bad Request
  • Content-Type: application/json

Conclusion

Thus we can make use of JAXRS Exception Mapping providers for returning HTTP Status codes and add the needed error details in the response body as well.

Post navigation

Leave a Reply Cancel reply

i downloaded the src code but its not giving json response body for exception handling case. could you pls check it.

Raj, Are you deploying this on JBoss 7 or a JEE 6 compliant server?
First thing to check would be that the project is deployed and working with a valid service invocation.
So a valid response should be returned for this URL: http://localhost:8080/jaxrs-movie-service/movie/1971

For an invalid URL you can try invoking this URL: http://localhost:8080/jaxrs-movie-service/movie/list?order=dummy
Try putting a breakpoint (in eclipse) to confirm the ExceptionHttpStatusResolver is getting called for an exception case.

Hi Prashant,
I’m using Tomcat and I’m application is not giving json response body for exception handling case, instead it giving following exception:

javax.ws.rs.WebApplicationException
at com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:268)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1029)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:941)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:932)
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:384)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:451)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:632)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
at java.lang.Thread.run(Thread.java:722)

Hi Prashant. Very useful article. Thank you.

I found that as soon as I add an interceptor to the method from an exception is thrown, my exception handler no longer gets called. Thoughts? sample code is below:
@ManagedBean
@Path(“/clinicalStudyService”)
public class ClinicalStudyService <

@EJB
private ClinicalStudyDataService clinicalStudyDataService;

@Inject
private ClinicalStudyValidator clinicalStudyValidator;

@POST
@Consumes(MediaType.TEXT_XML)
// @Interceptors()
public String addClinicalStudy(ClinicalStudy clinicalStudy) <
System.out.println(“Start – ” + clinicalStudy.getId());

System.out.println(“End – ” + clinicalStudy.getId());
return WebserviceResponseStatus.SUCCESS.getDescription();
>
>

@ManagedBean
public class ClinicalStudyValidator <

public void validate(ClinicalStudy clinicalStudy) <
if(StringUtils.isEmpty(clinicalStudy.getId())) <
throw new WebServiceException(“NCT ID is required for Clinical Study.”);
>
>
>

@Provider
public class ExceptionHttpStatusResolver implements ExceptionMapper <

@Override
public Response toResponse(WebServiceException webServiceException) <
return Response.status(Response.Status.BAD_REQUEST).entity(webServiceException.getMessage()).build();
>

As I web site possessor I believe the content material here is rattling great , appreciate it for your hard work. You should keep it up forever! Good Luck. fdabafccgded

Leave a Reply

Your email address will not be published. Required fields are marked *