Java - HtmlUnit - Unable to save HTML to file (in some cases) - java

I am having intermittent issues saving the response HTML in HtmlUnit.
Caused by: java.io.IOException: Unable to save file:C:\ccview\PP50773_4.0_walter\TSC_hca\Applications\HCA_J2EE\HCA\target\HtmlUnitTests\single\1\com\pnc\tsc\hca\ui\test\SiteCrawler\crawlSiteAsProvider\10.SiteCrawler.crawl.html
at com.pnc.tsc.hca.ui.util.GetUtil.save(GetUtil.java:128)
at com.pnc.tsc.hca.ui.util.GetUtil.add(GetUtil.java:75)
at com.pnc.tsc.hca.ui.util.GetUtil.click(GetUtil.java:49)
at com.pnc.tsc.hca.ui.test.SiteCrawler.crawl(SiteCrawler.java:87)
at com.pnc.tsc.hca.ui.test.SiteCrawler.crawl(SiteCrawler.java:61)
at com.pnc.tsc.hca.ui.test.SiteCrawler.crawl(SiteCrawler.java:63)
at com.pnc.tsc.hca.ui.test.SiteCrawler.crawl(SiteCrawler.java:63)
at com.pnc.tsc.hca.ui.test.SiteCrawler.crawl(SiteCrawler.java:63)
at com.pnc.tsc.hca.ui.test.SiteCrawler.crawl(SiteCrawler.java:54)
at com.pnc.tsc.hca.ui.test.SiteCrawler.crawlSiteAsProvider(SiteCrawler.java:50)
... 15 more
Caused by: java.lang.RuntimeException: java.io.IOException: The system cannot find the path specified
at com.gargoylesoftware.htmlunit.html.XmlSerializer.getAttributesFor(XmlSerializer.java:165)
at com.gargoylesoftware.htmlunit.html.XmlSerializer.printOpeningTag(XmlSerializer.java:126)
at com.gargoylesoftware.htmlunit.html.XmlSerializer.printXml(XmlSerializer.java:83)
at com.gargoylesoftware.htmlunit.html.XmlSerializer.printXml(XmlSerializer.java:93)
at com.gargoylesoftware.htmlunit.html.XmlSerializer.printXml(XmlSerializer.java:93)
at com.gargoylesoftware.htmlunit.html.XmlSerializer.asXml(XmlSerializer.java:73)
at com.gargoylesoftware.htmlunit.html.XmlSerializer.save(XmlSerializer.java:55)
at com.gargoylesoftware.htmlunit.html.HtmlPage.save(HtmlPage.java:2259)
at com.pnc.tsc.hca.ui.util.GetUtil.save(GetUtil.java:126)
... 24 more
Caused by: java.io.IOException: The system cannot find the path specified
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(File.java:883)
at com.gargoylesoftware.htmlunit.html.XmlSerializer.createFile(XmlSerializer.java:216)
at com.gargoylesoftware.htmlunit.html.XmlSerializer.getAttributesFor(XmlSerializer.java:160)
... 32 more
Now, the parent directory exists and some other files have already been written to the directory. Looking at the filename, I don't see anything that would stand out as a red flag indicating the filename is bad.
What can I do to correct this error?
Thanks,
Walter

Well, you are well within the maximum path length. The exception trace clearly believes it is a path problem.
I would try some additional tests to help isolate the problem. Check the directory before writing with: File.exists(), File.isDirectory(), File.isWritable(). Similar checks on the file itself. May want to see if the disk is full too.
If you can get a little more information on the source of the problem, we can get it resolved.

Related

Error: NoClassDefFoundError When Using Eclipse To Run COMSOL Model

I am trying to use Eclipse to run a COMSOL model and I have read the guide from programming reference manual. However, Eclipse always report the error as follows,
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter at com.comsol.client.interfaces.b.(SourceFile:60) at com.comsol.client.interfaces.b.(SourceFile:39) at com.comsol.clientapi.engine.APIEngine$c.b(SourceFile:497) at com.comsol.clientapi.engine.APIEngine.a(SourceFile:115) at com.comsol.clientapi.engine.APIEngine.connect(SourceFile:98) at com.comsol.clientapi.engine.APIEngine.connect(SourceFile:87) at com.comsol.clientapi.engine.ClientModelUtil.connect(SourceFile:145) at com.comsol.clientapi.engine.ClientModelUtil.connect(SourceFile:133) at com.comsol.model.util.ModelUtil.connect(SourceFile:248) at PFCZM_3PBending_QuasiBrittle.main(PFCZM_3PBending_QuasiBrittle.java:16750) Caused by: java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:636) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519) ... 10 more
I believe I have imported the JAR files correctly and set the path for the project and it seems that the error is due to lack of source file for COMSOL API JAR files. I have checked those JAR file and found they are indeed all class files without definition. How can I solve this problem? Thanks!

Cannot access './../modules/com/google/appengine/main/appengine-api-1.0-sdk-*-capedwarf*': No such file or directory

Running Capedwarf shows this error:
xybrek#ubuntu:~/CapeDwarf_WildFly_2.0.0.Final/bin$ ./capedwarf.sh /path/to/war
ls: cannot access './../modules/com/google/appengine/main/appengine-api-1.0-sdk-*-capedwarf*': No such file or directory
Exception in thread "main" org.jboss.modules.ModuleLoadException: Error loading module from /home/xybrek/CapeDwarf_WildFly_2.0.0.Final/modules/com/google/appengine/main/module.xml
at org.jboss.modules.ModuleXmlParser.parseModuleXml(ModuleXmlParser.java:155)
at org.jboss.modules.ModuleXmlParser.parseModuleXml(ModuleXmlParser.java:132)
at org.jboss.modules.LocalModuleFinder$1.run(LocalModuleFinder.java:154)
at org.jboss.modules.LocalModuleFinder$1.run(LocalModuleFinder.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at org.jboss.modules.LocalModuleFinder.findModule(LocalModuleFinder.java:148)
at org.jboss.modules.ModuleLoader.findModule(ModuleLoader.java:455)
at org.jboss.modules.ModuleLoader.loadModuleLocal(ModuleLoader.java:358)
at org.jboss.modules.ModuleLoader.preloadModule(ModuleLoader.java:305)
at org.jboss.modules.Module.addPaths(Module.java:1036)
at org.jboss.modules.Module.link(Module.java:1406)
at org.jboss.modules.Module.relinkIfNecessary(Module.java:1434)
at org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:242)
at org.jboss.modules.Main.main(Main.java:385)
Caused by: org.jboss.modules.xml.XmlPullParserException: Failed to add resource root 'appengine-api-1.0-sdk-1.9.24-capedwarf.jar' at path 'appengine-api-1.0-sdk-1.9.24-capedwarf.jar' (position: END_TAG seen ...</filter>\n </resource-root>... #33:25) caused by: java.io.FileNotFoundException: /home/xybrek/CapeDwarf_WildFly_2.0.0.Final/modules/com/google/appengine/main/appengine-api-1.0-sdk-1.9.24-capedwarf.jar (No such file or directory)
at org.jboss.modules.ModuleXmlParser.parseResourceRoot(ModuleXmlParser.java:723)
at org.jboss.modules.ModuleXmlParser.parseResources(ModuleXmlParser.java:572)
at org.jboss.modules.ModuleXmlParser.parseModuleContents(ModuleXmlParser.java:394)
at org.jboss.modules.ModuleXmlParser.parseDocument(ModuleXmlParser.java:219)
at org.jboss.modules.ModuleXmlParser.parseModuleXml(ModuleXmlParser.java:153)
... 13 more
=========================================================================
What could be the fix for this? There's no such jar anywhere.
It looks like the bytecode modification didn't yet kick in.
(we modify GAE API jar on the fly the first time, as we need some bytecode hacks)

NullPointerException with LWJGL 3 Initialization

I'm trying to setup a new project in IntelliJ using LWJGL version 3. I just tried out this example: Whenever I try to run it,
I get a java.lang.ExceptionInInitializerError caused by a java.lang.NullPointerException while loading the library.
My natives are in project_root/lib/lwjgl/native/macosx/x64, so my vm argument is:
-Djava.library.path=lib/lwjgl/native/macosx/x64
I have also added lwjgl to the classpath.
The stack trace is:
Exception in thread "main" java.lang.ExceptionInInitializerError
at test.HelloWorld.execute(HelloWorld.java:18)
at test.HelloWorld.main(HelloWorld.java:80)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: java.lang.NullPointerException
at org.lwjgl.LWJGLUtil.loadLibrarySystem(LWJGLUtil.java:326)
at org.lwjgl.Sys$1.run(Sys.java:36)
at java.security.AccessController.doPrivileged(Native Method)
at org.lwjgl.Sys.<clinit>(Sys.java:33)
... 7 more
The solution is to specify an absolute path for java.library.path, rather than a relative one.
On the LWJGL forums, there was a user with a similar problem (I found this by searching for the problematic line and doing some hunting on the forum). The relevant part of the conversation is:
lightbringer writes:
I think I figured it out. In LWJGLUtil.java I took out some code and ran it from my main()`. I got an
java.lang.UnsatisfiedLinkError: Expecting an absolute path of the library: lib/native\lwjgl.dll`
inside loadLibrary(). System.load() apparently needs an absolute path but you are passing it a relative path.
I tested with -Djava.library.path=E:\Dropbox\private\projects\solariad\redist\lib\native and this indeed did work as expected.
The root of the issue is LWJGL's use of System.load(), which is not problematic in itself, but it does requires an absolute path name to the libraries it loads (see source as well).
If you take a look at LWJGLUtil.java (although the version at the time of this writing does not correspond exactly to your stack trace) and Sys.doLoadLibrary(), you can see that it attempts to load libraries by going through all the path strings in java.library.path, appending the library name, and trying System.load() on those paths. Since load() requires an absolute path the implication is that java.library.path must contain the absolute path to the LWJGL libraries as well.
It is unfortunate that the root cause of the problem was muddled by the NPE but, you know, it's a hard knock life for us poor programmers!

How to clear console in java (Using netbeans)

I am using jdj 1.7,netbeans 7 versions. I wrote a program that's working fine. Now i want to clear the console window after many outputs in the console. I tried the below line Runtime.getRuntime().exec("cls"); also tried with exec("clear"). But i am getting these errors:
Exception in thread "main" java.io.IOException: Cannot run program "cls": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
at java.lang.Runtime.exec(Runtime.java:593)
at java.lang.Runtime.exec(Runtime.java:431)
at java.lang.Runtime.exec(Runtime.java:328)
at Periodical.main(Book.java:88)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.(ProcessImpl.java:81)
at java.lang.ProcessImpl.start(ProcessImpl.java:30)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
What's the problem here. How can i clear the console? Thank you
If you want to keep it portable you might want to use a library like jcurses. That will save you the trouble of having to detect what kind of console/terminal you are on and will give you a lot of other nice features like cursor and color control.

Exception in thread "main" org.jboss.xb.binding.JBossXBRuntimeException: Failed to create a new SAX parser

I've created a stand-alone web services client in Java. I'm able to generate the WSDL properly but when when i execute my run.bat file, I get the exception above long with the exception below. I googled for the exception shown in the title and found a .jar file that contained it. I added this to my JBOSS_HOME/lib directory as well as the Client/lib directory. not sure why i'm still seeing this. ANY advice would be greatly appreciated.
Exception in thread "main" org.jboss.xb.binding.JBossXBRuntimeException: Failed to create a new SAX parser
at org.jboss.xb.binding.UnmarshallerFactory$UnmarshallerFactoryImpl.newUnmarshaller(UnmarshallerFactory.java:100)
at org.jboss.ws.metadata.config.JBossWSConfigFactory.parse(JBossWSConfigFactory.java:76)
at org.jboss.ws.metadata.config.JBossWSConfigFactory.getConfig(JBossWSConfigFactory.java:149)
at org.jboss.ws.metadata.umdm.EndpointMetaData.initEndpointConfigMetaData(EndpointMetaData.java:872)
at org.jboss.ws.metadata.umdm.EndpointMetaData.initEndpointConfig(EndpointMetaData.java:849)
at org.jboss.ws.metadata.builder.jaxws.JAXWSClientMetaDataBuilder.rebuildEndpointMetaData(JAXWSClientMetaDataBuilder.java:292)
at org.jboss.ws.core.jaxws.spi.ServiceDelegateImpl.getPortInternal(ServiceDelegateImpl.java:267)
at org.jboss.ws.core.jaxws.spi.ServiceDelegateImpl.getPort(ServiceDelegateImpl.java:198)
at javax.xml.ws.Service.getPort(Service.java:141)
at com.firstcoverage.ws.client.om.WSStandAloneReportingSoapServiceService.getWSStandAloneReportingSoapServicePort(WSStandAloneReportingSoapServiceService.java:68)
at com.firstcoverage.ws.client.StandAloneReportingSoapClientFactory.ConnectToFCStandAloneReportingSoapWS(StandAloneReportingSoapClientFactory.java:70)
at com.firstcoverage.ws.client.StandAloneReportingSoapClientFactory.CreateInstance(StandAloneReportingSoapClientFactory.java:35)
at com.firstcoverage.ws.client.Reporter.main(Reporter.java:89)
Caused by: org.jboss.xb.binding.JBossXBException: Failed to create a new SAX parser
at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.<init>(SaxJBossXBParser.java:96)
at org.jboss.xb.binding.UnmarshallerImpl.<init>(UnmarshallerImpl.java:55)
at org.jboss.xb.binding.UnmarshallerFactory$UnmarshallerFactoryImpl.newUnmarshaller(UnmarshallerFactory.java:96)
... 12 more
Caused by: javax.xml.parsers.ParserConfigurationException: Feature 'http://apache.org/xml/features/xinclude' is not recognized.
at org.apache.xerces.jaxp.SAXParserFactoryImpl.newSAXParser(Unknown Source)
at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.<init>(SaxJBossXBParser.java:92)
... 14 more
Looks like i had too many jar files. removed the local jar files referencing xerces and i was cool
ref: http://community.jboss.org/wiki/whydoigetjavalangclasscastexceptionorgapachexercesparsersxincludeawareparserconfigurationinas-5
It could be not exact the same thing from the above link of the jobss site.
You might try to get your application using JAXB, JAXB-impl library from sun.
Here it forced to use org.jboss.xb.binding.

Categories