Free Support Forum - groupdocs.com

Groupdocs viewer for Java with AngularJS


#1

HI there,


I am trying to intrgrate groupdocs viewer for java with AngularJS. I can see the document frame but it errors out stating “The document couldn’t be loaded…”.

In the server.log, I see Null pointer:

Jan 05, 2016 3:41:25 PM com.groupdocs.viewer.handlers.a.e preLoadFiles

INFO: Indexing files. Please wait…

Jan 05, 2016 3:41:26 PM cpo.clouddesk.groupdocs.viewer.servlet.ViewDocumentHandlerServlet doPost

SEVERE: null

java.lang.RuntimeException: java.lang.NullPointerException

at com.groupdocs.viewer.internal.a.eb.k(Unknown Source)

at com.groupdocs.viewer.internal.c.a.w.U.(Unknown Source)

at com.groupdocs.viewer.b.a.m.a(Unknown Source)

at com.groupdocs.viewer.b.a.m.(Unknown Source)

at com.groupdocs.viewer.b.b.(Unknown Source)

at com.groupdocs.viewer.handlers.ViewerHandlerBasic.viewDocument(Unknown Source)

at com.groupdocs.viewer.handlers.ViewerHandler.viewDocumentHandler(Unknown Source)

at cpo.clouddesk.groupdocs.viewer.servlet.ViewDocumentHandlerServlet.doPost(ViewDocumentHandlerServlet.java:25)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.nuxeo.wss.servlet.BaseWSSFilter.doFilter(BaseWSSFilter.java:131)

at org.nuxeo.wss.servlet.FailSafeWSSFilter.doFilter(FailSafeWSSFilter.java:56)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.nuxeo.ecm.core.management.jtajca.internal.Log4jWebFilter.doFilter(Log4jWebFilter.java:67)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.nuxeo.ecm.platform.ui.web.rest.FancyURLFilter.doFilter(FancyURLFilter.java:129)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.nuxeo.ecm.platform.web.common.requestcontroller.filter.NuxeoThreadTrackerFilter.doFilter(NuxeoThreadTrackerFilter.java:28)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.nuxeo.ecm.webdav.service.WIRequestFilter.doFilter(WIRequestFilter.java:59)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.nuxeo.ecm.platform.web.common.requestcontroller.filter.NuxeoRequestControllerFilter.doFilter(NuxeoRequestControllerFilter.java:140)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.nuxeo.ecm.platform.web.common.requestcontroller.filter.NuxeoCorsFilter.doFilter(NuxeoCorsFilter.java:52)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.nuxeo.ecm.platform.web.common.exceptionhandling.NuxeoExceptionFilter.doFilter(NuxeoExceptionFilter.java:78)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.nuxeo.ecm.platform.web.common.encoding.NuxeoEncodingFilter.doFilter(NuxeoEncodingFilter.java:73)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)

at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)

at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)

at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

at java.lang.Thread.run(Thread.java:745)

Caused by: java.lang.NullPointerException

at com.groupdocs.viewer.internal.a.dd.a(Unknown Source)

at com.groupdocs.viewer.internal.a.dd.j(Unknown Source)

… 57 more


Header Script



Viewer Script

$(function () {

var thumbsImageBase64Encoded = null;

$(’#test’).groupdocsViewer({

backgroundColor: ‘’,

convertWordDocumentsCompletely: false,

currentSearchHighlightColor: ‘’,

downloadPdfFile: false,

enableStandardErrorHandling: true,

fileDisplayName: ‘’,

filePath: (‘d’.length > 0) ? ‘d’ : null,

height: 650,

ignoreDocumentAbsence: false,

initialZoom: 100,

jqueryFileDownloadCookieName: ‘’,

loadAllPagesOnSearch: false,

localizedStrings: null,

minimumImageWidth: 0,

onlyShrinkLargePages: true,

openThumbnails: true,

preloadPagesCount: 0,

preloadPagesOnBrowserSide: false,

preventTouchEventsBubbling: false,

printWithWatermark: false,

quality: 100,

searchForSeparateWords: false,

searchHighlightColor: ‘’,

showDownload: true,

showDownloadErrorsInPopup: false,

showFolderBrowser: true,

showHeader: true,

showImageWidth: false,

showOnePageInRow: false,

showPaging: true,

showPrint: true,

showSearch: true,

showThumbnails: true,

showViewerStyleControl: true,

showZoom: true,

supportPageReordering: false,

supportPageRotation: true,

useVirtualScrolling: false,

supportTextSelection: true,

thumbnailsContainerBackgroundColor: ‘’,

thumbnailsContainerBorderRightColor: ‘’,

thumbnailsContainerWidth: 0,

thumbsImageBase64Encoded: thumbsImageBase64Encoded,

toolbarBorderBottomColor: ‘’,

toolbarButtonBorderColor: ‘’,

toolbarButtonBorderHoverColor: ‘’,

toolbarButtonsBoxShadowHoverStyle: ‘’,

toolbarButtonsBoxShadowStyle: ‘’,

toolbarInputFieldBorderColor: ‘’,

treatPhrasesInDoubleQuotesAsExactPhrases: false,

useAccentInsensitiveSearch: false,

useEmScaling: false,

useHtmlBasedEngine: true,

useHtmlThumbnails: false,

useImageBasedPrinting: true,

useInnerThumbnails: true,

usePdfPrinting: false,

usePngImagesForHtmlBasedEngine: true,

useRtl: false,

viewerStyle: 1,

watermarkColor: ‘’,

watermarkFontSize: 0,

watermarkPosition: ‘’,

watermarkText: ‘’,

width: 650,

zoomToFitHeight: false,

zoomToFitWidth: true

});

});


#2
Hello ,

Thank you for your inquiry.

Could you please share with us some additional information about your usage. We need to know changes which you have made in the application.properties and also will be useful if you share with us a screenshot of your browser console , when you try to open your file, for example like this(http://prntscr.com/9msm5l) .

We will wait your details.

--------

Best regards,
Evgen Efimov

http://groupdocs.com
Your Document Collaboration APIs
Follow us on LinkedIn, Twitter, Facebook and Google+


#3

Hi there,

Please find the screen shot attached. Also, please find below the properties:

#Application path
#Application path is used in application for receiving and sending requests
#Path can be absolute, relative, empty or null
#groupdocs.viewer.applicationPath=http://127.0.0.1:8080/
#groupdocs.viewer.applicationPath=custom-url
#Note=custom-url prefix will be used in addition to application and context path, ex=http://127.0.0.1:8080/custom-url
#groupdocs.viewer.applicationPath=null
#groupdocs.viewer.applicationPath=
#Note=null or empty value will set default application request URI, in this case http://127.0.0.1:8080/

groupdocs.viewer.applicationPath=http://localhost:8080/nuxeo

#Files path=absolute path to files (documents) directory.
groupdocs.viewer.filePath=http://localhost:8080/nuxeo

#License path=path to GroupDocs Viewer for Java license, for trial version set it as null.
groupdocs.viewer.licensePath=null

#Locales path
#Locales path is used to change application locale if supported
#If locales path is null, then viewer’s default locales will be used
#Note=locales path is a directory path, do not specify full path to locale file. System will automatically detect system locale and set it using one of the existing locales from specified directory.
groupdocs.viewer.localesPath=null

#Upload path
#Set relative path for file uploads
#Example=‘uploadPath=uploads’, this way file will be uploaded into /assets/uploads/
#Set null for default directory, the default directory is assets/ directory
groupdocs.viewer.uploadPath=null

#Cache path
#Cache custom location as absolute path
#Example: D:/Projects/GroupDocs/Apps/temp/
groupdocs.viewer.cachePath: null

#Cache
#Use cache generated files
groupdocs.viewer.useCache=true

#Browser cache
#Use browser cache
groupdocs.viewer.useBrowserCache=true

#Total max cache size for temp directory (in MB)
#Set null or 0 for unlimited size
groupdocs.viewer.maxCacheSize=0

#File expiration date
#File upload expiration date in minutes
#Set to 0 if file is never expired
groupdocs.viewer.expirationDate=0

#Encryption key
#NOTE=key must be 16 characters long!
groupdocs.viewer.encryptionKey=GroupDocsEncrypt

#Charset
#Default charset is UTF-8
#Set parameter as null for default charset
encoding=UTF-8

#Custom path for TTF fonts (for Linux)
groupdocs.viewer.fontsPath=null

#
# FRONT-END (UI) CONFIGURATION
#

#HTML output
#If true all documents will be converted to HTML instead of images
#IMPORTANT=if this flag is set to ‘true’, useCache flag should be ‘true’ as well
groupdocs.viewer.useHtmlBasedEngine=true

#Use png images For html based engine
groupdocs.viewer.usePngImagesForHtmlBasedEngine=true

#Use virtual scrolling
groupdocs.viewer.useVirtualScrolling=false

# BASIC VISUAL OPTIONS
#------------------------

#Quality
#Default quality of generated images
groupdocs.viewer.quality=100

#Width
#Viewer width
#Note=set 0 to use 100% initial width
groupdocs.viewer.width=650

#Height
#Viewer height
groupdocs.viewer.height=650

#Initial zoom
groupdocs.viewer.initialZoom=100

#Zoom to fit width
groupdocs.viewer.zoomToFitWidth=true

#Zoom to fit height
groupdocs.viewer.zoomToFitHeight=false

#Custom css for html mode
groupdocs.viewer.customDocumentCss=

#Viewer style
groupdocs.viewer.viewerStyle=1


# CONTROL BUTTONS OPTIONS
#------------------------

#Show header
groupdocs.viewer.showHeader=true

#Show folder browser button
groupdocs.viewer.showFolderBrowser=true

#Show print button
groupdocs.viewer.showPrint=true

#Show download button
groupdocs.viewer.showDownload=true

#Show zoom button
groupdocs.viewer.showZoom=true

#Show paging
groupdocs.viewer.showPaging=true

#Show viewer style control
groupdocs.viewer.showViewerStyleControl=true

#Show search
groupdocs.viewer.showSearch=true

#Show download errors in popup
groupdocs.viewer.showDownloadErrorsInPopup=false

#Show image width
groupdocs.viewer.showImageWidth=false


# THUMBNAILS OPTIONS
#-------------------

#Show thumbnails
groupdocs.viewer.showThumbnails=true

#Open thumbnails
groupdocs.viewer.openThumbnails=true

#Thumbnails container width
#NOTE=minimum 0
groupdocs.viewer.thumbnailsContainerWidth=0

#Use inner thumbnails
groupdocs.viewer.useInnerThumbnails=true


# PRINT & DOWNLOAD OPTIONS
#-------------------------

#Use pdf printing
groupdocs.viewer.usePdfPrinting=false

# Print margins enabled
groupdocs.viewer.pdfPrintMarginsEnabled=true

#Use image based printing
groupdocs.viewer.useImageBasedPrinting=true

#Print with watermark
groupdocs.viewer.printWithWatermark=false

#Download file as PDF
groupdocs.viewer.downloadPdfFile=false

#jQuery file download name
groupdocs.viewer.jqueryFileDownloadCookieName=

#Image web request timeout
groupdocs.viewer.imageWebRequestTimeout=5000


# SEARCH OPTIONS
#---------------

#Search for separate words
groupdocs.viewer.searchForSeparateWords=false

#Treat phrases in double quotes as exact phrases
groupdocs.viewer.treatPhrasesInDoubleQuotesAsExactPhrases=false

#Load all pages on search
groupdocs.viewer.loadAllPagesOnSearch=false


# WATERMARK OPTIONS
#------------------

#Watermark text
#NOTE: leave empty to disable
groupdocs.viewer.watermarkText=

#Watermark color
#Default: black
#Values: use CSS color values (#fff, #ffffff, rgb(0,0,0), rgba(0,0,0,1), red, white, etc)
#NOTE: leave empty for default
groupdocs.viewer.watermarkColor=

#Watermark font size (in pt)
#NOTE: set 0 to default auto-sized (depends on text length and document size: width and height)
#NOTE: if useHtmlBasedEngine=true then default size is 16px
groupdocs.viewer.watermarkFontSize=0

#Watermark position
#Default: horizontal
#Values: diagonal, horizontal, vertical
#NOTE: leave empty for default
groupdocs.viewer.watermarkPosition=


# OTHER OPTIONS
#--------------

#Show Hidden Slides
groupdocs.viewer.showHiddenSlides=false

#Pre-load pages count
groupdocs.viewer.preloadPagesCount=0

#Minimum image width
groupdocs.viewer.minimumImageWidth=0

#Support text selection
#Set if user will be able to select(copy) text
groupdocs.viewer.supportTextSelection=true

#Support page reordering
groupdocs.viewer.supportPageReordering=false

#Only shrink large pages
groupdocs.viewer.onlyShrinkLargePages=true

#Enable standard error handling
groupdocs.viewer.enableStandardErrorHandling=true

#preventTouchEventsBubbling
groupdocs.viewer.preventTouchEventsBubbling=false

#Show one page in row
groupdocs.viewer.showOnePageInRow=false

#Use em scaling
groupdocs.viewer.useEmScaling=false

#File display name
#Will display file name on each document opening
groupdocs.viewer.fileDisplayName=

#Convert Word Documents Completely
groupdocs.viewer.convertWordDocumentsCompletely=false

#Ignore Document Absence
groupdocs.viewer.ignoreDocumentAbsence=false

#Pre-load pages on browser side
groupdocs.viewer.preloadPagesOnBrowserSide=false

#Support page rotation
groupdocs.viewer.supportPageRotation=true

#Image resolution
groupdocs.viewer.imageResolution=72


# STYLING OPTIONS
#----------------

#Background color
#NOTE=leave empty for default
groupdocs.viewer.backgroundColor=

#Search highlight color
groupdocs.viewer.searchHighlightColor=

#Current search highlight color
groupdocs.viewer.currentSearchHighlightColor=

#Toolbar buttons box shadow style
#NOTE=leave empty for default
groupdocs.viewer.toolbarButtonsBoxShadowStyle=

#Toolbar buttons box shadow hover style
#NOTE=leave empty for default
groupdocs.viewer.toolbarButtonsBoxShadowHoverStyle=

#Thumbnails container background color
#NOTE=leave empty for default
groupdocs.viewer.thumbnailsContainerBackgroundColor=

#Thumbnails container border right color
#NOTE=leave empty for default
groupdocs.viewer.thumbnailsContainerBorderRightColor=

#Toolbar border bottom color
#NOTE=leave empty for default
groupdocs.viewer.toolbarBorderBottomColor=

#Toolbar input field border color
#NOTE=leave empty for default
groupdocs.viewer.toolbarInputFieldBorderColor=

#Toolbar button border color
#NOTE=leave empty for default
groupdocs.viewer.toolbarButtonBorderColor=

#Toolbar button border hover color
#NOTE=leave empty for default
groupdocs.viewer.toolbarButtonBorderHoverColor=

#4

Hi there,

I was able to figure out the reason and looks like the absolute path to the file was the problem.
I no longer have the “NullPointer exception”.

However , I do have a question. All of our files are stored in our file system. The file system stored the file internally and gives our application a path which does not contain file extensions. It is a URL with an ID to the file on the file system. When attempting to load the URL, The document viewer complains that the “Extension of the file is not supported”.

Is there a work around to simply access the file a URL.

I tried implementing the CustomeInputDataHandler but still the URL without file extension is not supported.

Any advise is greatly appreciated.


#5
Hello,

We glad to hear that you have solved your previous issue.

You are right, for view files from your file system you will should implement all methods for CustomInputDataHandler class as it described in this article . If you already implemented it , then please make sure that these methods will be called in the ViewerHandler.

If you will have more questions please feel free to contact us.

-------

Best regards,
Evgen Efimov

http://groupdocs.com
Your Document Collaboration APIs
Follow us on LinkedIn, Twitter, Facebook and Google+


#6

Hi there,

The integration with the document viewer is now working. However, I have 2 questions that I need your assistance:

1) Occasional error in the logs

Occasionally, I see “The document couldn’t be loaded” message on the viewer and in the logs, I see the below error:

java.io.IOException: Stream Closed

at java.io.FileInputStream.readBytes(Native Method)

at java.io.FileInputStream.read(FileInputStream.java:243)

at com.groupdocs.viewer.internal.o.a.a.a.c.copyLarge(Unknown Source)

at com.groupdocs.viewer.internal.o.a.a.a.c.copyLarge(Unknown Source)

at com.groupdocs.viewer.internal.o.a.a.a.c.copy(Unknown Source)

at com.groupdocs.viewer.b.a.f.O(Unknown Source)

at com.groupdocs.viewer.b.a.f.M(Unknown Source)

at com.groupdocs.viewer.handlers.ViewerHandlerBasic.viewDocument(Unknown Source)

at com.groupdocs.viewer.handlers.ViewerHandler.viewDocumentHandler(Unknown Source)

at cpo.clouddesk.groupdocs.viewer.servlet.ViewDocumentHandlerServlet.doPost(ViewDocumentHandlerServlet.java:25)


2) Application.properties

Can the width and Height properties be made percentage basis ? I wonder how the viewer renders for different screen resolution.