Results 1 to 10 of 10

Thread: NullPointerException thrown by Roo Shell prevents Roo from adding ITDs to a service

  1. #1
    Join Date
    Nov 2007
    Posts
    177

    Default NullPointerException thrown by Roo Shell prevents Roo from adding ITDs to a service

    Hello,

    I've created a Spring service by adding the @RooService annotation to an interface and providing an implementation (see java code below) and I now systematically get the following NPE from the Roo Shell:
    Code:
    NullPointerException at org.springframework.roo.addon.layers.service.ServiceInterfaceLocatorImpl.getServiceInterfaces(ServiceInterfaceLocatorImpl.java:44)
    Here are the interface and the classes:
    Code:
    import java.util.Map;
    
    import org.springframework.roo.addon.layers.service.RooService;
    
    import com.kadjoukor.domain.Member;
    import com.kadjoukor.domain.Message;
    
    @RooService(domainTypes = Message.class)
    public interface MessageService {
    	
    	Map<Member, Message> retrieveLatestMessages(Member member);
    
    }
    Code:
    import java.util.Collection;
    import java.util.HashMap;
    import java.util.Map;
    
    import com.kadjoukor.domain.Member;
    import com.kadjoukor.domain.Message;
    
    public class MessageServiceImpl implements MessageService {
    
    	@Override
    	public Map<Member, Message> retrieveLatestMessages(Member member) {
    		Collection<Message> sentMessages = member.getSentMessages();
    		Collection<Message> receivedMessages = member.getReceivedMessages();
    		Map<Member, Message> latestMessages = new HashMap<Member, Message>();
    		for (Message receivedMessage : receivedMessages) {
    			Member sender = receivedMessage.getSender();
    			latestMessages.put(sender, receivedMessage);
    		}
    		for (Message sentMessage : sentMessages) {
    			Member recipient = sentMessage.getRecipient();
    			if (sentMessage.getSendDate().after(latestMessages.get(recipient).getSendDate())) {
    				latestMessages.put(recipient, sentMessage);
    			}
    
    		}
    		return latestMessages;
    	}
    
    }
    Code:
    import java.util.Date;
    
    import javax.persistence.Column;
    import javax.persistence.Lob;
    import javax.persistence.ManyToOne;
    import javax.persistence.Temporal;
    import javax.persistence.TemporalType;
    import javax.validation.constraints.NotNull;
    import javax.validation.constraints.Size;
    
    import org.springframework.format.annotation.DateTimeFormat;
    import org.springframework.roo.addon.equals.RooEquals;
    import org.springframework.roo.addon.javabean.RooJavaBean;
    import org.springframework.roo.addon.jpa.activerecord.RooJpaActiveRecord;
    import org.springframework.roo.addon.tostring.RooToString;
    
    @RooJavaBean
    @RooToString
    @RooEquals
    @RooJpaActiveRecord
    public class Message {
    
    	@NotNull
    	@ManyToOne
    	private Member sender;
    
    	@NotNull
    	@ManyToOne
    	private Member recipient;
    
    	@NotNull
    	@Temporal(TemporalType.TIMESTAMP)
    	@DateTimeFormat(pattern = "dd/MM/yyyy HH:mm:ss")
    	private Date sendDate;
    
    	@NotNull
    	@Lob
    	@Size(min = 5, max = 500)
    	@Column(length = 500)
    	private String message;
    
    }
    I am pretty sure it is something to do with a reserved keyword as all my other service work fine and don't cause the Roo shell to throw such an exception.

    Regards,

    J.

    P.S. I have opened an jira here: https://jira.springsource.org/browse/ROO-3308

  2. #2
    Join Date
    Dec 2005
    Posts
    930

    Default

    I commented on ROO-3308. Please attach the whole project to the ticket
    Alan Stewart
    Spring Roo Committer
    twitter @alankstewart

  3. #3
    Join Date
    Nov 2007
    Posts
    177

    Default

    Hi Alan,
    Done.
    Julien.

  4. #4
    Join Date
    Dec 2005
    Posts
    930

    Default

    I added a null check. Please test too see if the behaviour is what you expect now.
    Alan Stewart
    Spring Roo Committer
    twitter @alankstewart

  5. #5
    Join Date
    Nov 2007
    Posts
    177

    Default

    Alan,

    1. Can you please briefly describe what was the problem and how I can circumvent it using Spring Roo 1.2.2?
    2. I've dowloaded the indicated commit and run a mvn package. Can you please advise how to get a running Roo from the packaged jars?
    3. When will Spring Roo 1.2.3 is due to be released?

    Regards,
    J.

  6. #6
    Join Date
    Nov 2007
    Posts
    177

    Default

    See my latest comment on Jira: https://jira.springsource.org/browse/ROO-3308

  7. #7
    Join Date
    Dec 2005
    Posts
    930

    Default

    You are correct - I added a better message to tell users about the domainTypes attribute being an array of types, and closed the issue.
    Alan Stewart
    Spring Roo Committer
    twitter @alankstewart

  8. #8
    Join Date
    Nov 2007
    Posts
    177

    Default

    Alan, I sent you a very important IM regarding this thread. Have you had a chance to read it?

  9. #9
    Join Date
    Dec 2005
    Posts
    930

    Default

    I haven't received anything as yet.
    Alan Stewart
    Spring Roo Committer
    twitter @alankstewart

  10. #10
    Join Date
    Nov 2007
    Posts
    177

    Default

    Strange.. I have resent it to you anyway.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •