Announcement Announcement Module
Collapse
No announcement yet.
NullPointerException thrown by Roo Shell prevents Roo from adding ITDs to a service Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    I commented on ROO-3308. Please attach the whole project to the ticket

    Comment


    • #3
      Hi Alan,
      Done.
      Julien.

      Comment


      • #4
        I added a null check. Please test too see if the behaviour is what you expect now.

        Comment


        • #5
          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.

          Comment


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

            Comment


            • #7
              You are correct - I added a better message to tell users about the domainTypes attribute being an array of types, and closed the issue.

              Comment


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

                Comment


                • #9
                  I haven't received anything as yet.

                  Comment


                  • #10
                    Strange.. I have resent it to you anyway.

                    Comment

                    Working...
                    X