users@jersey.java.net

Re: [Jersey] Re: NullPointerException

From: Roan Brasil Monteiro <roanbrasil_at_gmail.com>
Date: Fri, 23 Oct 2009 17:01:08 -0200

Hey Paul I am not deploying as war , I am using maven and I have it:

<plugin>
                <artifactId>maven-ear-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>

I have only one project named citespace-ws, when I am typing clean and
install on maven I am getting BUILD FAILED
/home/roan/Desktop/MyWorkspaces/workspace2/citespace-ws/src/main/java/com/citespace/articles/model/IImportedRDFEntity.java:[13,20]
generics are not supported in -source 1.3
(use -source 5 or higher to enable generics)
    public abstract Set<String> getSeeAlso();

/home/roan/Desktop/MyWorkspaces/workspace2/citespace-ws/src/main/java/com/citespace/articles/model/MetricValue.java:[15,1]
annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
@Entity

/home/roan/Desktop/MyWorkspaces/workspace2/citespace-ws/src/main/java/com/citespace/articles/model/ImportedRDFEntity.java:[16,1]
annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
@Embeddable

/home/roan/Desktop/MyWorkspaces/workspace2/citespace-ws/src/main/java/com/citespace/articles/model/ImportedRDFEntity.java:[22,14]
generics are not supported in -source 1.3
(use -source 5 or higher to enable generics)
    protected Set<String> seeAlso = new HashSet<String>();

/home/roan/Desktop/MyWorkspaces/workspace2/citespace-ws/src/main/java/com/citespace/articles/model/Metric.java:[15,1]
annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
@Entity

/home/roan/Desktop/MyWorkspaces/workspace2/citespace-ws/src/main/java/com/citespace/articles/model/BookEdition.java:[11,1]
annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
@Entity

/home/roan/Desktop/MyWorkspaces/workspace2/citespace-ws/src/main/java/com/citespace/cms/model/PersonName.java:[19,1]
annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
@Embeddable

/home/roan/Desktop/MyWorkspaces/workspace2/citespace-ws/src/main/java/com/citespace/cms/model/PersonName.java:[31,12]
generics are not supported in -source 1.3
(use -source 5 or higher to enable generics)
    private Set<String> alias = new HashSet<String>();

/home/roan/Desktop/MyWorkspaces/workspace2/citespace-ws/src/main/java/com/citespace/cms/model/PersonName.java:[102,14]
for-each loops are not supported in -source 1.3
(use -source 5 or higher to enable for-each loops)
        for(String s: alias) {

/home/roan/Desktop/MyWorkspaces/workspace2/citespace-ws/src/main/java/com/citespace/articles/model/Article.java:[14,1]
annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
@Entity

/home/roan/Desktop/MyWorkspaces/workspace2/citespace-ws/src/main/java/com/citespace/articles/model/PublishedCollection.java:[18,1]
annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
@Entity

/home/roan/Desktop/MyWorkspaces/workspace2/citespace-ws/src/main/java/com/citespace/articles/model/PublishedCollection.java:[27,13]
generics are not supported in -source 1.3
(use -source 5 or higher to enable generics)
    private List<CSDocument> parts = new ArrayList<CSDocument>();

/home/roan/Desktop/MyWorkspaces/workspace2/citespace-ws/src/main/java/com/citespace/articles/model/PublishedCollection.java:[61,19]
for-each loops are not supported in -source 1.3
(use -source 5 or higher to enable for-each loops)
        for(CSDocument p : getParts()) {

/home/roan/Desktop/MyWorkspaces/workspace2/citespace-ws/src/main/java/com/citespace/cms/model/Language.java:[28,1]
annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
@Entity

/home/roan/Desktop/MyWorkspaces/workspace2/citespace-ws/src/main/java/com/citespace/cms/model/Language.java:[78,11]
generics are not supported in -source 1.3
(use -source 5 or higher to enable generics)
    public Set<String> getEnglishNames() {

/home/roan/Desktop/MyWorkspaces/workspace2/citespace-ws/src/main/java/com/citespace/cms/model/Language.java:[122,17]
for-each loops are not supported in -source 1.3
(use -source 5 or higher to enable for-each loops)
        for(String eng : this.getEnglishNames()) {

/home/roan/Desktop/MyWorkspaces/workspace2/citespace-ws/src/main/java/com/citespace/citespacerest/http/MyResource.java:[10,1]
annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
@Path("/myresource")

/home/roan/Desktop/MyWorkspaces/workspace2/citespace-ws/src/main/java/com/citespace/articles/model/Book.java:[10,1]
annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
@Entity

/home/roan/Desktop/MyWorkspaces/workspace2/citespace-ws/src/main/java/com/citespace/articles/model/Book.java:[11,31]
generics are not supported in -source 1.3
(use -source 5 or higher to enable generics)
public class Book extends Serie<BookEdition> implements Serializable {

/home/roan/Desktop/MyWorkspaces/workspace2/citespace-ws/src/main/java/com/citespace/articles/model/MetricCategory.java:[6,7]
enums are not supported in -source 1.3
(use -source 5 or higher to enable enums)
public enum MetricCategory {

/home/roan/Desktop/MyWorkspaces/workspace2/citespace-ws/src/main/java/com/citespace/articles/model/Publication.java:[18,1]
annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
@Entity



2009/10/23 Paul Sandoz <Paul.Sandoz_at_sun.com>

> Hi,
> The issue is you are instantiating BaseDAOImpl yourself using "new".
> Stateless Session Beans are instantiated and managed by the EJB container
> and you get references to them using injection or JNDI. That is why the emf
> field is null.
>
> I also presume you want to use EJB 3.1 and EJBs in the war using the latest
> GlassFish?
>
> If so you can do:
>
> public class BaseDAO<T> {
>
> @PersistenceUnit(unitName = "citespacePU")
> public EntityManagerFactory emf;
>
> }
>
> @Stateless
> public class CountryDAO extends BaseDAO<Country> {
> ...
> }
>
> @Path("/user/")
> @ManagedBean
> public class UserResource {
>
> @EJB CountryDAO cdao;
>
> @GET
> @Produces("text/plain")
> public String registerUser() { ... }
>
>
> Paul.
>
> On Oct 23, 2009, at 7:29 PM, Roan Brasil Monteiro wrote:
>
> Ok.
> All are in my src/main/java sourcefolder;
>
> @Stateless
> public class BaseDAOImpl<T> implements BaseDAO<T>{
>
>
> @PersistenceUnit(unitName = "citespacePU")
> public EntityManagerFactory emf;
>
> ...
>
>
> @Remote
> public interface BaseDAO<T> {
> ...
>
>
>
> @Path("/user/")
> public class UserResource {
>
> @GET
> @Produces("text/plain")
>
> public String registerUser(){
>
> BaseDAOImpl<Country> countryDAO = new BaseDAOImpl<Country>(emf);
> List<Country> c = countryDAO.listCountry();
> ...
>
> 2009/10/23 Roan Brasil Monteiro <roanbrasil_at_gmail.com>
>
>> Hello,
>>
>> I got the Bookmark example, it has jersey e JPA integrate, I would like to
>> add EJB lib, and I did. My question is, do I need to set up the web.xml
>> file? What should I add? Currently my web.xml is like bellow. Do I need to
>> configure something else? I am getting NullPointerException when I made my
>> BaseDAOImpl with @Stateless anotation implementing a @Remote interface
>> BaseDAO and on the BaseDAOImpl I am injecting with @PersistenceUnit on
>> EntityManagerFactory, but I am getting NullPointerException, can someone
>> help me please? P.S.-> My Resource class is calling the BaseDAOImpl.
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
>> http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
>> <servlet>
>> <servlet-name>Jersey Web Application</servlet-name>
>>
>> <servlet-class>com.sun.jersey.server.impl.container.servlet.ServletAdaptor</servlet-class>
>> <init-param>
>>
>> <param-name>com.sun.jersey.config.feature.Redirect</param-name>
>> <param-value>true</param-value>
>> </init-param>
>> <init-param>
>> <param-name>unit:citespacePU</param-name>
>> <param-value>persistence/citespace</param-value>
>> </init-param>
>> <load-on-startup>1</load-on-startup>
>> </servlet>
>> <servlet-mapping>
>> <servlet-name>Jersey Web Application</servlet-name>
>> <url-pattern>/resources/*</url-pattern>
>> </servlet-mapping>
>> <session-config>
>> <session-timeout>
>> 30
>> </session-timeout>
>> </session-config>
>> <welcome-file-list>
>> <welcome-file>
>> index.jsp
>> </welcome-file>
>> </welcome-file-list>
>> <persistence-unit-ref>
>>
>> <persistence-unit-ref-name>persistence/citespace</persistence-unit-ref-name>
>> <persistence-unit-name>citespacePU</persistence-unit-name>
>> </persistence-unit-ref>
>> <resource-ref>
>> <res-ref-name>UserTransaction</res-ref-name>
>> <res-type>javax.transaction.UserTransaction</res-type>
>> <res-auth>Container</res-auth>
>> </resource-ref>
>> </web-app>
>>
>>
>> --
>> Atenciosamente,
>>
>> Roan Brasil Monteiro
>> http://roanbrasil.wordpress.com/
>>
>
>
>
> --
> Atenciosamente,
>
> Roan Brasil Monteiro
> http://roanbrasil.wordpress.com/
>
>
>


-- 
Atenciosamente,
Roan Brasil Monteiro
http://roanbrasil.wordpress.com/