Java Web start printing job - printing

I posted about the same problem before but got no answer. I am re-posting because I think its a simple problem that someone must have came across recently.
I have a JavaFX application that makes use of the awt.PrinterJob to print some Printable information. while on development everything works fine but when I sign the application and deploy it via Web Start clicking the same button to print the data just throws a Null pointer exception below:
Caused by: java.lang.NullPointerException
at javax.print.PrintServiceLookup.getServicesForContext(Unknown Source)
at javax.print.PrintServiceLookup.getListOfLookupServices(Unknown Source)
at javax.print.PrintServiceLookup.getAllLookupServices(Unknown Source)
at javax.print.PrintServiceLookup.lookupDefaultPrintService(Unknown Source)
at sun.print.Win32PrintServiceLookup.getWin32PrintLUS(Unknown Source)
at sun.awt.windows.WPrinterJob.getPrintService(Unknown Source)
at sun.print.RasterPrinterJob.setPrintable(Unknown Source)
at AdvancedSearchDetailedResultsTableViewController.printToImage(AdvancedSearchDetai..
I have another Java Swing app that I deploy the same way and its using the PrintJob with no issues. I thought that it could be something to do with JavaFX and awt but it works locally which made me think that it must have something to do with WebStart accessing printing services. I looked at JNLP API Printservices with no results.
Previous post link https://stackoverflow.com/questions/17403727/java-web-start-printerjob
Any ideas or workarounds would be much appreciated.
Thanks

Updating from Java 7u21 to 7u25 caused a similar problem in my JavaFX Web Start app, but I do not know the cause of the error yet. May be a permissions issue (see JDK 7u25 and JavaFX 2.2.25 Documentation Updates) or maybe a bug? Test your app with Java 7 update 21!

Related

Grails error-messages if I run the web app with tomcat 9

I'm updating a fairly large web app from Grails 2 to Grails 5. We are using the Shiro plugin (and others) and Java 11.
If I run the packaged war file under a tomcat-9 installation (currently with FreeBSD as the host os) I get the following errors:
org.apache.shiro.UnavailableSecurityManagerException: No SecurityManager accessible to the calling code, either bound to the org.apache.shiro.util.ThreadContext or as a vm static
singleton. This is an invalid application configuration.
at org.apache.shiro.SecurityUtils.getSecurityManager(SecurityUtils.java:123)
at org.apache.shiro.subject.Subject$Builder.<init>(Subject.java:626)
at org.apache.shiro.SecurityUtils.getSubject(SecurityUtils.java:56)
at org.apache.shiro.grails.AccessControl.accessControlMethod(AccessControl.groovy:35)
at org.apache.shiro.grails.AccessControl.accessControlMethod(AccessControl.groovy)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.invoke(StaticMetaMethodSite.java:44)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:89)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:157)
at shiro.ShiroGrailsPlugin$_doWithDynamicMethods_closure3.doCall(ShiroGrailsPlugin.groovy:253)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
etc.
But the app seems to work fine, if I'm not logged in, I'm redirected to the login page and afterwards to the pages of the app. Haven't tested with different permissions, but at first sight, it looks ok.
If I run it with "java -jar myApp.war", I don't have these error-messages.
The java-version for tomcat and the standalone start is the same.
Should be something with dependencies I think...
I cannot speak for the Grails side of things, but from a Shiro perspective:
It looks like you have a request that is being processed outside the scope of Shiro (i.e. either a request that is NOT behind the ShiroFilter), or you have a background or initialization thread calling a protected method (the stacktrace looks trimmed so it's hard to say)
If it's the former, the fix is to make sure all your requests go through the ShiroFilter (or equivalent Grails config), this will make sure a SecurityManager is bound to the request thread.
If it's the latter, take a look at: https://shiro.apache.org/static/1.9.1/apidocs/org/apache/shiro/web/servlet/AbstractShiroFilter.html
(this is often used for background threads running on behalf of a user)

Websites detecting and blocking Selenium Chromedriver

I got a task to update a URL in a test (using Selenium, Java and Chromedriver) to a new URL. The page is the same, just at a new location. This test worked fine with the old URL.
I brought up an instance of Chrome and verified I could access the URL.
Then I changed the URL, committed to git, and ran on our Jenkins machine and it failed. The screenshot said "This site can’t be reached". I told a co-worker that I think the URL must be wrong (though it worked on my desktop without Selenium). He tried it and it loaded fine. I tried it again from a regular Chrome window and it loaded fine. I tried from Eclipse using Selenium and I got the message about the site could not be accessed.
So I ran Eclipse, stopped it right when Chrome came up but hadn't loaded a URL yet. I manually entered the URL (from copy/paste) and got "This site cannot be accessed). Then I brought up a regular Chrome window and pasted the URL in and it loaded fine.
I decided to look for differences. So in my regular Chrome window it was "Version 77.0.3865.120 (Official Build) (64-bit)". I did the same on the version running under Chromedriver and got "Version 77.0.3865.120 (Official Build) (64-bit)". So the same.
I did a search for the latest Chromedriver. It said for version 77 to please use 77.0.3865.40. This was not what I was using. So I downloaded the correct version and thought "surely this will fix it". I verified it was 77.0.3865.40 coming up. But, as you guessed it, I got the same problem after updating to the most compatible Chromedriver.
Some searches said that basically nothing would be able to tell, but there was one property that Chromedriver inserts. I don't know whether this would be enough to block a session using Chromedriver?
The only thing I can think of is that we have iBoss and possibly iBoss is blocking it? Either that or somehow the site is blocking it.
I would like to share the URL with you but I do not know whether that would be violating company policy. If I get permission, I will share the URLs.
by the way, the error is "ERR TUNNEL CONNECTION FAILED"
Got some internal help to help fix some settings

SonarQube Service Starts, Runs and then Stops?

I have a Windows 2012 R2 server and I managed to install the SonarQube 5.4 server as a Windows Service. I also set up a user so the service can actually start without the infamous "It started then stopped" error a lot of people seem to get. Before installing the server as a windows service, I checked that it worked using StartSonar.bat and it did work just fine, so I was confident when I made it into a service.
But when I try to access http://localhost:9000 there is nothing there, and it appears that shortly after starting the service it stops without any message at all. I can't tell if this is because I try to access the site (which gives me ERR_EMPTY_RESPONSEin Google Chrome) or if it just closes down after a short while.
Anyone got any insight?
I'm a beginner. I came across the same issue and fixed it.
Ensure that the database is running.
My log file (located at sonarqube_home_dir/logs/sonar.log) included the following statement.
Caused by: org.h2.jdbc.JdbcSQLException: Wrong user name or password [28000-176]
Since I'm using the default database, I commented below lines
#sonar.jdbc.username=***
#sonar.jdbc.password=***
at sonarqube_home_dir/conf/sonar.properties.
This must happen due to many reasons like connection problems, permission problems so First, you have to see the logs. /sonarqube-7.6/logs$ tailf sonar.log. then you can find the reason. Once I had the same problem so I did like that. my error is something Directory does not exist: lib/jdbc/mysql
org.sonar.process.MessageException: Directory does not exist: lib/jdbc/mysql reason is I uninstall MySQL and remove all folders name contains "MySQL".
just check whether port 9001 already in used, stop it if already in used.

No content nodes after Umbraco 6 upgrade

I asked this question in the Umbraco forum three days ago and haven't had a single answer. I have a website whose content I can no longer edit and I know the people at SO are the best, so here goes:
I just upgraded a site from Umbraco version 4.6.1 to 6.0.0 and now the only thing that displays in the content tab in the backend is a "Content" node. The whole tree has disappeared but the site actually still works it's just that I can't reach any of the content in the backend--Media, Settings, Developer, etc. tabs all appear to be working as normal.
If I right-click on the only visble node, "Content", I get "Create", "Sort", "Republish Entire Site" and "Reload nodes".
Create gives me the expected create dialog box but I don't want to try creating anything yet until I know what's wrong.
Sort throws the following error:
Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
umbraco.cms.businesslogic.CMSNode..ctor(IUmbracoEntity entity) +32
umbraco.cms.businesslogic.Content..ctor(IContentBase contentBase) +18
umbraco.cms.businesslogic.web.Document.<GetRootDocuments>b__1(IContent c) +38
System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +151
System.Linq.Buffer`1..ctor(IEnumerable`1 source) +325
System.Linq.Enumerable.ToArray(IEnumerable`1 source) +78
umbraco.cms.businesslogic.web.Document.GetRootDocuments() +123
umbraco.cms.presentation.sort.OnPreRender(EventArgs e) +813
System.Web.UI.Control.PreRenderRecursiveInternal() +103
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2496
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
Republish works without error re-creating the umbraco.config file in the App_Data folder.
Reload nodes appears to be trying to, well, reload the nodes, but nothing shows up in the end.
I'm using a MySql database and I'm happy to hack at it with a few sql commands to get things working again as I suspect that a few errant node ids are probably to blame but I don't know what tables to look at.
All help gratefully received.
PS: Umbraco "About" shows the following version information -- "Umbraco v6.0.0 (Assembly version: 1.0.4779.24222)"
I'd suggest that rather than troubleshooting the issue at this point, which is more like chasing a rabbit down a hole, that you take a copy of your backups and attempt the upgrade again. It's possible that you could have missed a step in the upgrade process. Pay special attention to the upgrade notes and the version specific upgrade notes (pretty much every version specific note can apply to you).
If you find that you still have problems after the second attempt, I'd suggest a more granular upgrade path, such as upgrading to highest version of 4.7, then to the highest 4.11, and then finally the highest of 6.0, again paying attention to the upgrade notes and checking after each upgrade that the site still works.
In either case make sure that you are running the installer at the end as this will allow umbraco to make some necessary changes to your database.

Why JSF throw OutOfMemoryError in Tomcat 7?

I have a fresh and clean Tomcat7 ready in my Windows machine, when I remove the JSF jars (jsf-api-2.0.1.jar and jsp-impl-2.0.1.jar) from WEB-INF/lib, I hit this error:
Caused by: java.lang.ClassNotFoundException: javax.faces.FacesException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
... 10 more
When I put the 2 jars in WEB-INF/lib, I hit error:
java.lang.OutOfMemoryError: PermGen space
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2818)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1148)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1643)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
at org.apache.catalina.startup.ContextConfig.checkHandlesTypes(ContextConfig.java:1956)
at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:1919)
at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1806)
at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1765)
at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1751)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1255)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:882)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:317)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5081)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:774)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:291)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:727)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.startup.Catalina.start(Catalina.java:620)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Any clue on running JSF in Tomcat 7?
You haven't indicated if the error occurs instantly on deploy or after a while. If it occurs after a while, i.e. during your application run, your code will be to blame. Look at this excellent article that will help you use JDK 6 track down the source of the error.
A PermGen error is indicative of classloading issues pertaining to your application container.The Permanent Generation (PermGen for short) is the area where the JVM stores objects such as classes and string literals. Normally, the garbage collector is not supposed to operate frequently here. Classes loaded by the app server should be automatically cleaned up once the classloader for the web application (there is one per deployed webapp) is no longer being used. Tomcat has given me problems in this area in the past (especially when used within Netbeans). It seems to not be able to clean up after itself effectively after repeated redeploys. There are a handful of things you could do apart from increasing the size of the permgen space
1) You could move the common jars for the web applications running in that tomcat instance into the TOMCAT_HOME/lib. This way, you can expect your class libraries to not be loaded multiple times per requiring web application as is the default behaviour for tomcat(see this). Use this option with care however; if you eventually deploy a web application containing newer versions of the jar, you might run into NoClassDefFound errors.
2)You can try this -XX:MaxPermGen instead of (or in addition to) the -XX:MaxPermSize that mkyong suggested in his article.
Also take a look at this question and it's answers for further steps

Resources