[jboss-user] [JBoss Seam] - Trouble W/ NullPointerException
nathandennis
do-not-reply at jboss.com
Thu Dec 13 23:19:31 EST 2007
Having trouble with a NPE. I'm sure this is something simple
jboss4.2.1
seam 2.0 +
| @Stateful
| @Name("uploadAction")
| @Scope(ScopeType.SESSION)
| public class FileUploadAction implements FileUploadLocal{
|
| @PersistenceContext
| private EntityManager em;
|
| @Out(scope=ScopeType.CONVERSATION, required=false)
| FtpRemote send;
|
|
| private String medianame;
| private Long size;
| .
| .
| .
|
| public void UploadFile() throws NullPointerException {
|
|
| if(!medianame.equals("")){
| try{
| // create empty file with specified name and path
| File os = new File("/var/temp/filewritetemp/"+getMediaName());
| FileOutputStream oStream =new FileOutputStream(os);
| oStream.write(getIs());
|
|
|
|
| File file = new File("/var/temp/filewritetemp/" + getMediaName());
| size = file.length();
| dob = new Date();
| fis = new FileInputStream("/var/temp/filewritetemp/" + getMediaName());
| try{
| ftpFile(fis);
| }catch (Exception e){
| e.printStackTrace();
| }
| .
| .
| .
| }
|
|
| public void ftpFile(FileInputStream fis){
| send = new FtpRemote();
| send.findServer(fis);
| }
| ...
which calls
| @Stateless
| @Name("ftpRemote")
| public class FtpRemote implements FtpRemoteLocal {
|
| private String login;
| .
| .
| .
|
| @In
| EntityManager em;
|
| @In(required=false)
| @Out(required=false)
| ReturnServer host;
|
| public void findServer(FileInputStream fis){
| host = new ReturnServer();
|
| ....
and it breaks just before the query
|
| @Stateless
| public class ReturnServer
| {
| @In
| EntityManager em;
|
| private String server;
| private ArrayList<Server> serverlist;
| .
| .
| .
|
|
| @In(create=true)
| private ServerList result;
|
| public String findServer(){
| queryServer();
| requestServer();
| return server;
| }
|
| @SuppressWarnings("unchecked")
| public void queryServer() {
| System.out.println("made it to -- line before QUERY");
| List<Server> resultList = em.createQuery("select s from " +
| "Server s where s.status = 'online' order by s.usedspace desc")
| .setMaxResults(5).setFirstResult(0).getResultList();
| System.out.println("made it to -- line after QUERY");
| serverlist = new ArrayList(resultList.subList(0, resultList.size()));
|
| }
|
I've convinced myself that this is a fundamental misunderstanding EJB3 annotations. I'm just not sure how to fix it.
| [q22:35:16,598 INFO [STDOUT] made it to -- line before QUERY
| 22:35:16,598 ERROR [STDERR] java.lang.NullPointerException
| 22:35:16,599 ERROR [STDERR] at com.dcg.action.ReturnServer.queryServer(ReturnServer.java:66)
| 22:35:16,599 ERROR [STDERR] at com.dcg.action.ReturnServer.findServer(ReturnServer.java:41)
|
any direction would be greatly appreciated.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4112796#4112796
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4112796
More information about the jboss-user
mailing list