9 Replies Latest reply: Mar 23, 2011 4:25 PM by Saif KHan RSS

Error creating WebArchive

Saif KHan Newbie

Hi,

 

I am using JSFUnit 2.0.0 + Arquillian to test jsf 2.0 + primefaces application. I am facing issues creating WebArchive. Following is my code to

create WebArchive:

 

 

WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war")

                .setWebXML(new File("src/main/webapp/WEB-INF/web.xml"))

                .addPackage(Package.getPackage("com.permit.ui.arquillian")) // my test package

                .addResource(new File("src/main/webapp", "index.xhtml"))

                .addWebResource(EmptyAsset.INSTANCE, "beans.xml")

                .addWebResource(new File("src/main/webapp/WEB-INF/faces-config.xml"), "faces-config.xml")

                .addManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));

 

 

 

Now webapp contains lot of folders and resources. Is there any pattern way of adding resources like "src/main/webapp/**.*" Now when I add resource which requires lot of other resources I get following exception:

 

 

com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException: 500 Server Error for http://localhost:9090/test/ui/login.jsf

 

 

 

Any help will be highly appreciated.

  • 1. Error creating WebArchive
    Aslak Knutsen Master

    Currently not possible, but we're aiming for it:

     

    https://issues.jboss.org/browse/SHRINKWRAP-256

    https://issues.jboss.org/browse/SHRINKWRAP-249

     

    The easiest solution for now would be to create a little util in your project to recursivly loop over folder X and add the files to the archive.

  • 2. Error creating WebArchive
    Andrew Rubinger Master

    Yeah, this is gonna be a popular one.  Let's get it into SW 1.0.0-alpha-13.

     

    S,

    ALR

  • 3. Error creating WebArchive
    Karel Piwko Master

    You can also use archive merging workaround present at https://issues.jboss.org/browse/SHRINKWRAP-247

     

    Karel

  • 4. Error creating WebArchive
    Saif KHan Newbie

    Guys thank you for your quick reply it really helped. Currently I am doing it like this:

     

    public void addResourcesToWebArchive(String rootFolderPath, WebArchive war ){

           

            File rootDir = new File(rootFolderPath);

               

            if(rootDir.isDirectory()){

                   

                String[] fileList = rootDir.list();

                   

                for(String filename : fileList){

                       

                    if(!filename.equals(".svn") && !filename.equals("WEB-INF") ){

                           

                        if(new File(rootFolderPath+File.separatorChar+filename).isDirectory()){

                               

                            war.addDirectory(convertLocalToWebPath(rootFolderPath + File.separatorChar + filename));

                            addResourcesToWebArchive(rootFolderPath + File.separatorChar + filename , war);

                               

                        }else{

                               

                            war.addResource( new File( convertLocalToWebPath( rootFolderPath + File.separatorChar + filename ) ) );

                               

                        }

                    }

                }

            }

        }

           

        public String convertLocalToWebPath(String localPath){

       

            localPath = localPath.replace('\\', '/');

            return localPath.substring(localPath.indexOf("src/"));

           

        }

  • 5. Error creating WebArchive
    Craig Greenhalgh Newbie

    Hi, slightly off topic but this has stumped me for days!

     

    I'm trying to do exactly the same as you,

     

    Which version of primefaces are you using? My test works fine with standard components, soon as I switch these to the primefaces equivilant....BOOM!

     

    I have tried 2.2.1 and 3.0-snap

     

    Did you have any problems doing this?

     

    Thanks in advance,

     

    Craig

  • 6. Error creating WebArchive
    Andrew Rubinger Master

    Could you open a new Thread and attach some context, ie. logging output of archive.toString(true) and the stacktrace?

     

    S,

    ALR

  • 7. Error creating WebArchive
    Saif KHan Newbie

    Hi Andrew,

     

    Sorry to reply so late. I am using jsf2 with primefaces 2.2.1. Right now I am busy in some other task and I have paused this activity.

    But my archive is successfully created (with the code mentioned in my previous post) and deployed.  

     

    Saif

  • 8. Error creating WebArchive
    Andrew Rubinger Master

    My question above was for Craig.

  • 9. Error creating WebArchive
    Saif KHan Newbie

    Oops! sorry to interfere