Frustration on impossible to import files of jasper in my managed Bean?

Mr President.

I manage not to import from jasper and binding file in my bean managed in my application.

My application look like this

Jasper folder app folder.gif

The folder contains files

Jasper lib.gif

The Application looks like

jasper report app.gif

The bean code is as

import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.sql.Connection;
import java.util.HashMap;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.servlet.ServletContext;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.type.WhenNoDataTypeEnum;
import net.sf.jasperreports.engine.util.JRLoader;
import oracle.adf.model.BindingContext;
import oracle.adf.model.binding.DCIteratorBinding;
import oracle.binding.BindingContainer;




public class JasperBean
{
  public JasperBean()
  {
  }


  public String runReportAction()
  {
    DCIteratorBinding empIter = (DCIteratorBinding) getBindings().get("EmployeesView1Iterator");
    String empId = empIter.getCurrentRow().getAttribute("EmployeeId").toString();
    Map m = new HashMap();
    m.put("employeeId", empId);
    try
    {
      runReport("empReport.jasper", m);
    }
    catch (Exception e)
    {
    }
    return null;
  }


  public BindingContainer getBindings()
  {
    return BindingContext.getCurrent().getCurrentBindingsEntry();
  }

  public Connection getDataSourceConnection(String dataSourceName)
      throws Exception
    {
      Context ctx = new InitialContext();
      DataSource ds = (DataSource)ctx.lookup(dataSourceName);
      return ds.getConnection();
    }

  private Connection getConnection() throws Exception
  {
    return getDataSourceConnection("hrDS");
  }

  public  ServletContext getContext()
    {
      return (ServletContext)getFacesContext().getExternalContext().getContext();
    }
  public  HttpServletResponse getResponse()
    {
      return (HttpServletResponse)getFacesContext().getExternalContext().getResponse();
    }
  public static FacesContext getFacesContext()
    {
      return FacesContext.getCurrentInstance();
    }
  public void runReport(String repPath, java.util.Map param) throws Exception
  {
    Connection conn = null;
    try
    {
      HttpServletResponse response = getResponse();
      ServletOutputStream out = response.getOutputStream();
      response.setHeader("Cache-Control", "max-age=0");
      response.setContentType("application/pdf");
      ServletContext context = getContext();
      InputStream fs = context.getResourceAsStream("/reports/" + repPath);
      JasperReport template = (JasperReport) JRLoader.loadObject(fs);
      template.setWhenNoDataType(WhenNoDataTypeEnum.ALL_SECTIONS_NO_DETAIL);
      conn = getConnection();
      JasperPrint print = JasperFillManager.fillReport(template, param, conn);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      JasperExportManager.exportReportToPdfStream(print, baos);
      out.write(baos.toByteArray());
      out.flush();
      out.close();
      FacesContext.getCurrentInstance().responseComplete();
    }
    catch (Exception jex)
    {
      jex.printStackTrace();
    }
    finally
    {  
      close(conn);
    }
  }

  public void close(Connection con)
   {
     if (con != null)
     {
       try
       {
         con.close();
       }
       catch (Exception e)
       {
       }
     }
   }
}


I am unable to get the import to

  DCIteratorBinding empIter = (DCIteratorBinding) getBindings().get("EmployeesView1Iterator");
      JasperReport template = (JasperReport) JRLoader.loadObject(fs);
      template.setWhenNoDataType(WhenNoDataTypeEnum.ALL_SECTIONS_NO_DETAIL);
JasperPrint print = JasperFillManager.fillReport(template, param, conn);
JasperExportManager.exportReportToPdfStream(print, baos);


Mr President, I'll be very grateful for any guidance on this topic.

Concerning

User, tell us your version of Jdev, please!

It is insufficient to simply add the jar in a folder in the workspace. You must create a new library in your project or in the world at Jdev do you use the library in all projects.

Open your project and select the node of the library and classpath. Here, you click on the new button, give the library a name like jasper and that each of the jars to your classpath registration record. If you have a jar source and doc, you can add them too. Select the check box by default deploy. Save the new library and add it to the project.

Now recompile the project and it should work. If you still see red underlines in your editor, close Jdev, delete the class of each project file in the workspace and start Jdev.

Timo

Tags: Java

Similar Questions

  • Impossible to import files: error "unable to read the files.

    All of a sudden I can no longer import files.  I get a message "Unable to read file" whenever I try to import, disc or iPhone.  It is not a problem of memory; I have a lot of memory on my hard drive.  Does anyone have an idea how to solve this problem?  Should I reinstall LR?  If so, how do I?  Thank you!

    It is almost always a problem of permission to write (despite the ambiguous message).  LR ' t for some write reason the files to the selected location.

    We need to learn a little more about your system... OS to start.

    I highly recommend reinstall Lightroom until everything has been eliminated.

  • Impossible to import files in LR6 help

    I have been using the opening. I bought LR6 for Mac. opening files imported correctly. However, I can't import from memory card. I get this message "the following files were not imported because they could be read DSC_1790.JPG (2); HELP DSC_1790.NEF.

    Hi neil,

    You can try to copy these images to the desktop and try to import the Lightroom. Check if it still gives you the error message.

    Thank you

  • Impossible to import files

    4.4 LR will not import my files (RAW), I can see the files on the screen to import, but when I hit import I get a message cannot read the files.

    It's the first time that this happens all the time I'v been using LR, can someone help me with this please.

    Thank you for your help, Geoff, I fixed it in the end by reloading the program. then I found that the card reader was not working all the time, so I combined it and used an old, all ok now.

  • Impossible to import the raw files from canon g16 in lightroom 4

    I have a new Canon g16 and can't import raw files into my lightroom 4.  I downloaded the recommended dng converter (canon g16 was one of the devices listed on the support list) and I always get the error message on lightroom being impossible to import and raw riles the g16.  When I checked for software updates, it says there is none - that my lightroom software 4 was "aware".  Does this mean I have to buy lightroom 5 or 6?

    Hi kerryem,

    Canon 16 G has been initially supported by Lightroom 5.2.See devices supported by Adobe Camera Raw

    Please switch to Lightroom latest version 6 to be able to process raw images from new cameras.

    Alternatively, you can use the DNG Converter to convwert G16 raw to DNG files and then import them into Lightroom 4. see help Photoshop | Digital negative converter Adobe 9.x

    Kind regards

    Assani

  • Just bought the new Canon 5 d. Impossible to import RAW files into LR5.

    Just bought the new Canon 5 d. Impossible to import RAW files into LR5. Any suggestions?

    Support for the camera was only added in Lightroom 6, you can upgrade to level or you cam d/load the latest DNG Converter and convert them to DNG format that will be readable in Lightroom 5...

  • Windows Movie Maker-impossible to import the .mov file

    C:\Users\guillermina newwest\newwest medina\Pictures\2010-06-17 126.com MOV cannot be imported. __

    IM using windows movie maker on vista and it repeats this to me

    can you please give me a solution to this problem

    Below are links that can shed some light for your problems. Help you find answers.

    Problems with importing files into Windows Movie Maker

    http://Windows.Microsoft.com/en-us/Windows-Vista/problems-importing-files-into-Windows-Movie-Maker

    http://Windows.Microsoft.com/en-us/Windows-Vista/importing-files-into-Windows-Movie-Maker-frequently-asked-questions

    Farewell.

  • Impossible to import music files into wondows movie maker. Help!

    Hi, im trying to import some .mp3 files in movie maker (with vista) and I get an error message saying that "it contains no valid audio data" and others that are important, I can't use as windows the song is more than 24 hours, when the song is actually 4 or 5 minutes. Why this is happening and how to fix it?

    Hi r.achtel,

    What is the format of the file that is having problems with the length of the song? This only happens with this specific file format?

    Please provide the complete error message you receive.

    Step 1: You can follow the procedure presented by John Inzer, MVP Saturday, August 8, 2009 17:50 in the link below:

    http://social.answers.Microsoft.com/forums/en-us/vistamedia/thread/8e6841de-4EDB-4AF6-B179-3498b2461f6d

    Step 2: Run SFC (System File Checker) Scan  

    The System File Checker (SFC) utility allows administrators to perform an analysis of all protected resources to make sure they are the correct version. Whether SFC should find all incorrect versions in one of these protected resources, SFC will be replaced by the correct versions.

    You can still run a SFC scan on the windows vista computer. To run a scan suite SFC as follows:

    (a) click Start and in the start search bar type cmd, right-click on the command prompt icon in the box programs and then click Run as administrator.

    (b) at the command prompt type sfc/scannow , and then press ENTER.

    For more information, see the link below

    Solve problems with importing files in Windows Movie Maker

    http://Windows.Microsoft.com/en-us/Windows-Vista/troubleshoot-problems-with-importing-files-into-Windows-Movie-Maker

    Thank you, and in what concerns:

    Ajay K

    Microsoft Answers Support Engineer

    Visit our Microsoft answers feedback Forum and let us know what you think.

  • ACS - impossible to import the file

    Hello!

    I am doing tests on GBA through the CLI.

    I would like to import files from a remote repository to test the command "import data".

    I've created a repository of the CLI and when I do a repository 'show', I can see the contents of the directory.

    When I run the command 'import - data', I got the error "unable to import the file""repository remote «repository_name»»

    What could be the cause?

    I use a linux sftp server.

    Kind regards

    Angélique

    Hey,.

    You are missing this:

    the synchronization host key

    http://www.Cisco.com/c/en/us/TD/docs/net_mgmt/cisco_secure_access_contro...

    Concerning

    Ed

  • Impossible to import pp CC bdm files, right?

    Hello

    try to import files bdm for first pro cc and having no success.

    any advice or assistance would be appreciated.

    Thank you.

    BDM files aren't video files but a part of the structure of avchd.

    Copy the entire hard disk map then import in the first with the media browser.

  • Impossible to import Canon RAW files in LR4.2

    I tried the import and convert to DNG RAW files of a CF card with images taken on a brand new Canon D5 Mark III. None of the images can be imported and try to install the latest version of the plugin Adobe Camera RAW also failed. The error message reads "the following files were imported not because they cannot be read. (3)"can anyone help?

    Update: I've now tried to import files from an SD card to format newly and am having the same problem.

    The simplest interpretation of error messages, this is the place you are trying to put the files is not writable.  Do you have the permission to the location?  You use a function of OS level to copy the files here and do more?

  • Cannot download and install programssince a corruption of important files... explore 8 is an example

    I had an incident that caused the corruptions of important files and loss of some programs. I was previously using Internet Explorer 8 and now IE7.  When I try to download and install IE8, it blocks the download, runs for hours without having to download anything. Other programs are also not download... arrive almost at the end, they never end. Very frustrating.  Maybe it has more to do with the installer?

    Hello

    1. You did any recent changes?

    I suggest you to follow these steps and check if that helps:

    Method 1:
    Try to run the scan on the computer online and check if it helps:
    http://www.Microsoft.com/security/scanner/en-us/default.aspx

    Method 2:
    Try to perform the clean boot and check if it helps:
    http://support.Microsoft.com/kb/310353

    NOTE: When you are finished troubleshooting, make sure that restore you the computer mode normal startup such as suggested in step 7 of the above article.

    Method 3:
    If you have problems installing programs, then run this fixit and check if that helps:
    http://support.Microsoft.com/mats/Program_Install_and_Uninstall

    It will be useful.

  • Hi, I just downloaded trial of adobe lightroom. However, when I try to import my images it does allow me to. It shows the preview where I choose my pictures to import, but once I click on import, it is said that it is impossible to import my thread

    Hi, I just downloaded trial of adobe lightroom. However, when I try to import my images it does allow me to. It shows the preview where I choose my pictures to import, but once I click on import, it is said that it is impossible to import my files, which are in jpg format.

    Hi chelseac46438928,

    Please make sure that you have permissions to the folder where you try to import images.

    Or you can try to change the location of import of images in Lightroom.

    Kind regards

    Tanuj

  • Impossible to import RAW Nikon D810 to LR5, IMac user

    Just started using a D810 and impossible to import RAW files into LR5. I am a user of the IMac. What I am doing wrong. No update is required, so Adobe said. Can anyone help? Thank you.

    With the help of Nikon Transfer is not necessary, but if you are going to use, make sure that you use the latest version of the software. It is a well-known problem that using old versions of Nikon Transfer on new NAVE of new camera models format files will corrupt the NEF files in transit.

  • I need help importing files from remote server

    Hello

    My computer has become corrupted, and I lost everything. My backup system has not (unknow reason at this moment) ALL .muse files are saved.

    I pray there is a way for me to import the files from the server in muse...

    Thanks in advance!

    Geneviève

    Muse allows you layout of your Web site, and then generates the code so that you don't have to. Impossible to import the code implemented in muse.

    Next time, install google reader on your computer and save your muse files to that!

Maybe you are looking for

  • Additional window of Firefox in Firefox

    Hey all,. I know the title is confusing and doesn't mean anything, but I couldn't find a better way to describe it. This is what it looks like when I open firefox: http://screencast.com/t/glp7JP8q Grateful for your help!

  • Purchase of a used (without the original invoice) macbook air

    I'm about to buy a macbook air. The seller gave me the serial number only and not the original Bill. The product is under warranty. Is it safe to buy it?

  • HP Envy dv6 7200 CTO: has stopped working

    Hello world. I have a problem with a stopped working error. When I opened the call of duty 4 Multipalyer and play for 5 to 6 minutes (sometimes up to 15 min) it give stopped working error (iw3mp.exe has stopped working). I use coolpad for the laptop

  • PTR DNS records Server 2008 R2

    Hello I am fairly new to controllers Windows Server and domain, looking for a DNS on my Server 2008 R2, I see the PTR records for machines that are no longer on the field, and some Machines have multiple PTR records. How can I get the server of range

  • PC will not open in Mode safe

    My moms ADVENT PC has stopped working and will not open in safe mode. If I try to open it in normal mode it gets stuck in a loop of trying to open and then automatically close down and then try to open it again. I have checked for viruses, it has bee