Count not initialize Class JRLoader - glassfish

I'm trying to embed a JR report into a EJB and then serve rendered as pdf with a webservice.
I put the report file into src\reports folder. The getResourceAsStream method work fine and return a stream, but when I call JRLoader.loadObject I get this error:
java.lang.NoClassDefFoundError: Could not initialize class net.sf.jasperreports.engine.util.JRLoader
I'm developing with NetBeans and running on GlassFish server (on Windows)
InputStream reportStream = this.getClass().getResourceAsStream("/reports/AlterDesignReport.jasper");
JasperReport jasperReport = (JasperReport)JRLoader.loadObject(reportStream);
PS: this the report is taken from example projects from JasperReports, but i tryed with my report to

Related

[Content_Types].xml unknown error in ASP.NET Core 5 (EPPlus)

I am trying to use EPPlus to manipulate my xlsm template and download to client. I believe there is no issue with excel package as I am able to save the package locally. But I need content disposition to download to client when it is live...
I have tried many different ways, return file, return filecontentresult, return streamcontentresult but all result in the same unknown error (attached in screenshot, as I could not translate it)..
Solved... you cannot use Ajax to call excel export function in controller. instead, call directly using html action link and return file ActionResult and it will initiate download in client browser.
similar resolution can be found here.
Response.WriteFile() -- not working asp net mvc 4.5

How To run Coded UI Test method from from Unit Test project where selenium web driver is used

I have created a unit test project with Selenium to perform some UI actions. In one of page i need to upload file from local machine, and for that i am using SendKey method available in c# but that is not consistent so i thought if we can add a small recorded coded UI method which would just do windows interaction like select file from window control. I browse through MSDN and tried all links but its not happening. Please help me in this regards
say I have created a Unit test Project "Test" and inside that created a Unit Test class added selenium web driver references and inside it a Test Method in which i launched the browser and reached till the point where i need to upload file.
Now I added a coded UI test file and recorded the uploading the file part in CodeUITestMethod1() in new class CodedUITest.
Now when i try to call codedUITestMethod1() from my first test class its giving errors like "PlayBack.dll "or "UITest.dll" or some other Dll could not be Found. But i have added all the coded UI and these dlls and i ensure that i call PlayBack.Initilize() before codedUITestMethod1() is called but everytime i get some errors at PlayBack.Initilize() method.
I have taken refrence from follwing links :
https://blogs.msdn.microsoft.com/gautamg/2010/03/30/how-to-get-uitesting-methods-working-outside-the-testmethod-of-coded-ui-test/
http://blogs.microsoft.co.il/shair/2010/07/15/running-codedui-test-from-another-application/
I have used visual studio 2013 for this work . Pleas Help

PDPageContentStream drwastring method is not working

I am trying to create a new pdf document using a java program using the pdfbox API, but
Exception in thread "main"
java.lang.NoClassDefFoundError:org/apache/commons/logging/LogFactory
Every time I am facing same error. I have already added external jar file to classpath, It is also showing that the drawString method of PDPageContentStream object is deprecated.
What could be the problem with this?

Windows Phone 8.1 File Picker UnauthorizedAccessException

I have a problem trying to replicate the File Picker example in link, I create a new application using a Universal Application Windows store template.
I extract the content of the class Scenario02 and create a similar one in my example. This class implements an interface called IFileOpenPickerContinuable which I extract from the class ContinuationManager and create a file in my project with the same name to implement that interface.
I don't get any compilation errors when I run the application. When the line openPicker.PickMultipleFilesAndContinue(); is executed, it throw a exception.
'UnauthorizedAccessException'(Access is denied. Exception from HRESULT: 0x80070005) exception.
In the Microsoft example they don't modify any of the manifests of the application. Do you know what can I be missing?
(Question solved in a question edit. Converted to a community wiki answer.)
The OP wrote:
Solved! The problem was trying to launch the data picker in the class constructor.

How to check if PDF was successfully opened in the browser using WatiN?

I am using WatiN library to do a quick smoke test on a web site after deployment. Among other things, I want to make sure that when I click on a specific link on my page, a PDF is opened in the browser. Clicking the link is easy, but how can I detect if Acrobat Reader was successfully opened in the browser window? I would like to catch situations like 404, server errors, or time-outs...
Rub,
I found one bug report and one feature request on this issue. Both the bug and feature request are closed but I am still not able to attach to a IE window that is hosting a PDF document.
In fact the window that is hosting the PDF file is not even an item in the IE.InternetExplorers() or the InternetExplorersNoWait() collections.
I'm using WatiN 2.0.10.928 and IE7 on Windows XP.
My solution was to use add a COM reference to Interop.ShDocVw.dll and check for the window myself since IE windows that host PDF viewers are not items in the WatiN.IE.InternetExplorers() collection for some reason.
Do NOT add a reference to Interop.ShDocVw.dll by using Add Reference -> COM -> Microsoft Internet Controls v1.1. If you do theres a good chance you'll recieve this exception:
System.IO.FileLoadException: Could not load file or assembly 'Interop.SHDocVw, Version=1.1.0.0, Culture=neutral ... or one of its dependencies. The located assembly's manifest definition does not match the assembly reference (Exception from HRESULT: 0x80131040)
Instead you need to reference the ShDocVw.dll thats distributed with WatiN. Check out the 'WatiN Error Could not Load Assembly' StackOverflow question for more info:
WatiN Error Could not Load Assembly
using System.IO;
using SHDocVw;
namespace PDF_SPIKE
{
class Program
[STAThread]
static void Main(string[] args)
{
SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindowsClass();
string pdfViewerURL = "http://YourURL/document.pdf";
bool pdfOpened = false;
string filename;
foreach ( SHDocVw.InternetExplorer ie in shellWindows )
{
filename = Path.GetFileNameWithoutExtension( ie.FullName ).ToLower();
if ( filename.Equals("iexplore") && ie.LocationURL.Equals(pdfViewerURL))
pdfOpened = true;
}
if ( pdfOpened )
Console.WriteLine( "Your PDF file is OPENED" );
else
Console.WriteLine( "Your PDF file was NOT found." );
}
Thanks, MoMo, for this answer. It was very helpful to me as well.
I would just like to give an additional solution to this answer just in case anyone else runs into same problem I did.
I initially received an error implementing this line:
SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindowsClass();
"SHDocVw.ShellWindowsClass cannot be embedded, use applicable interface instead"
The solution can be found here:
http://www.debugging.com/bug/24258
You need to right click on the reference Interop.ShDocVW.dll and set the embed interop types to false.