This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 270224 - Testing RESTful WebService fails when clicking "Test Resource Uri" from within NetBeans
Summary: Testing RESTful WebService fails when clicking "Test Resource Uri" from withi...
Status: STARTED
Alias: None
Product: webservices
Classification: Unclassified
Component: REST (show other bugs)
Version: 8.2
Hardware: Macintosh Mac OS X
: P3 normal (vote)
Assignee: Milan Kuchtiak
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-28 09:00 UTC by ashleyholmes
Modified: 2017-08-02 17:14 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Screenshot of error message (225.36 KB, image/png)
2017-03-28 09:00 UTC, ashleyholmes
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ashleyholmes 2017-03-28 09:00:40 UTC
Created attachment 163964 [details]
Screenshot of error message

Product Version: NetBeans IDE 8.2 (Build 201609300101)
Updates: NetBeans IDE is updated to version NetBeans 8.2 Patch 1
Java: 1.8.0_71; Java HotSpot(TM) 64-Bit Server VM 25.71-b15
Runtime: Java(TM) SE Runtime Environment 1.8.0_71-b15
System: Mac OS X version 10.11.6 running on x86_64; UTF-8; en_US (nb)

I have a simple CRUD web app using REST which is able to parse XML however not JSON. It is the JSON which I need to display in the browser by removing the MediaType.APPLICATION_XML. Hopefully I have supplied enough details to resolve this issue.

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

/**
 *
 * @author ashleyholmes
 */
@Stateless
@Path("com.ashleyholmes.entity.blanchardstown")
public class BlanchardstownFacadeREST extends AbstractFacade<Blanchardstown> {

    @PersistenceContext(unitName = "WebRestPU")
    private EntityManager em;

    public BlanchardstownFacadeREST() {
        super(Blanchardstown.class);
    }

    @POST
    @Override
    @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
    public void create(Blanchardstown entity) {
        super.create(entity);
    }

    @PUT
    @Path("{id}")
    @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
    public void edit(@PathParam("id") String id, Blanchardstown entity) {
        super.edit(entity);
    }

    @DELETE
    @Path("{id}")
    public void remove(@PathParam("id") String id) {
        super.remove(super.find(id));
    }

    @GET
    @Path("{id}")
    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
    public Blanchardstown find(@PathParam("id") String id) {
        return super.find(id);
    }

    @GET
    @Override
    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
    public List<Blanchardstown> findAll() {
        return super.findAll();
    }

    @GET
    @Path("{from}/{to}")
    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
    public List<Blanchardstown> findRange(@PathParam("from") Integer from, @PathParam("to") Integer to) {
        return super.findRange(new int[]{from, to});
    }

    @GET
    @Path("count")
    @Produces(MediaType.TEXT_PLAIN)
    public String countREST() {
        return String.valueOf(super.count());
    }

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }
    
}

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>faces/index.xhtml</welcome-file>
    </welcome-file-list>
</web-app>

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<blanchardstowns>
<blanchardstown>
<email>zasdcdfrtgvbghyujikm</email>
<firstname>zxcvbnmkjhgfdswertyu</firstname>
<id>10</id>
<lastname>zxswerfdcvgbhyujnmkl</lastname>
<username>asdfghjklpoiuytrewqa</username>
</blanchardstown>
<blanchardstown>
<email>asdfasdfa</email>
<firstname>asdfasdf</firstname>
<id>100</id>
<lastname>asdfasdf</lastname>
<username>qwertyui</username>
</blanchardstown>
<blanchardstown>
<email>asdfasdf</email>
<firstname>asdfasdf</firstname>
<id>5</id>
<lastname>asdfasdf</lastname>
<username>asdfsadf</username>
</blanchardstown>
</blanchardstowns>
Comment 1 Anda77 2017-07-26 12:50:04 UTC
I have the same problem.

Did you resolved?
Comment 2 clucgdc 2017-07-29 03:44:29 UTC
Here are a few things you can try:
- Make sure the web application is deployed and running
- Verify there is file ApplicationConfig.java

If you still have this problem, please attach the source folder.


Link to a video that it works on my machine: https://youtu.be/ucJrbXevauU
Comment 3 Anda77 2017-08-02 09:57:50 UTC
Ok, thanks.

My app was not deployed because of 

------------------------------------------------------------------------
Failed to execute goal on project RestDbMaven: Could not resolve dependencies for project error:RestDbMaven:war:3.0-74b: Could not find artifact org.glassfish.embedded:glassfish-embedded-all:jar:3.0-Prelude-Embedded-SNAPSHOT -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

My POM.xml is: 

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>error</groupId>
    <artifactId>RestDbMaven</artifactId>
    <version>3.0-74b</version>
    <packaging>war</packaging>


    <name>RestDbMaven</name>

    <properties>
        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    </properties>

    <dependencies>
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>eclipselink</artifactId>
            <version>2.5.2</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
            <version>2.5.2</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
            <version>2.4</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-server</artifactId>
            <version>2.4</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet</artifactId>
            <version>2.4</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-moxy</artifactId>
            <version>2.4</version>
        </dependency>
        <dependency>
            <groupId>org.apache.derby</groupId>
            <artifactId>derby</artifactId>
            <version>10.13.1.1</version>
        </dependency>
        <dependency>

            <groupId>org.apache.maven</groupId>

            <artifactId>maven-plugin-api</artifactId>

            <version>2.0</version>

        </dependency>

        <dependency>

            <groupId>org.apache.maven</groupId>

            <artifactId>maven-project</artifactId>

            <version>2.0</version>

        </dependency>



        <dependency>
            <groupId>org.glassfish.embedded</groupId>
            <artifactId>glassfish-embedded-all</artifactId>
            <version>3.0-Prelude-Embedded-SNAPSHOT</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.glassfish</groupId>
                <artifactId>maven-embedded-glassfish-plugin</artifactId>
                <version>3.0-74b</version>
                <configuration>
                    <goalPrefix>embedded-glassfish</goalPrefix>
                    <app>test.war</app>
                    <port>8080</port> 
                    <contextRoot>test</contextRoot> 
                    <autoDelete>true</autoDelete>
                </configuration>
                <executions>
                    <execution>
                        <phase>install</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <compilerArguments>
                        <endorseddirs>${endorsed.dir}</endorseddirs>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${endorsed.dir}</outputDirectory>
                            <silent>true</silent>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>javax</groupId>
                                    <artifactId>javaee-endorsed-api</artifactId>
                                    <version>7.0</version>
                                    <type>jar</type>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>
Comment 4 Anda77 2017-08-02 09:59:43 UTC
I don't have any AppConfig.java
Comment 5 Anda77 2017-08-02 17:14:16 UTC
If you delete web.xml from webapp it works.