[JBoss Seam] - Trouble W/ NullPointerException
by nathandennis
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
18 years, 4 months
[JBossWS] - return type polymorphism issue, please help
by beligum
Hi all, I guess this should be easy for some of you experts, so I hope to get an answer here, after searching for this bug for a couple of hours now.
Here's the situation:
| @XmlJavaTypeAdapter(AbstractInodeImpl.Adapter.class)
| public interface Inode extends Serializable, Comparable<Inode>, Cloneable
| {
| //definition of getters,setters,...
| }
|
| @Entity
| @Table(name="inode")
| @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
| @DiscriminatorColumn(
| name="type",
| discriminatorType=DiscriminatorType.STRING
| )
|
| @XmlSeeAlso({FileInode.class, DirectoryInode.class})
| public abstract class AbstractInodeImpl implements Inode
| {
| //implementation of getters,setters,...
|
| static public class Adapter extends XmlAdapter<AbstractInodeImpl, Inode>
| {
| public Inode unmarshal(AbstractInodeImpl v)
| {
| return v;
| }
| public AbstractInodeImpl marshal(Inode v)
| {
| return (AbstractInodeImpl)v;
| }
| }
| }
|
| @Entity
| @Name("directoryInode")
| @DiscriminatorValue("directory")
| public class DirectoryInode extends AbstractInodeImpl implements Serializable
| {
| // more implementation
| }
|
| @Entity
| @Name("fileInode")
| @DiscriminatorValue("file")
| public class FileInode extends AbstractInodeImpl implements Serializable
| {
| // even more...
| }
|
| @Stateless
| @WebService(name = "FileSystemService", serviceName = "FileSystemService")
| @Name("fileSystemService")
| @WebContext(contextRoot="/tumbolia/services", urlPattern="/FileSystemService")
| public class FileSystemServiceImpl implements FileSystemService, Serializable
| {
| @WebMethod
| public List<Inode> getAllChildren(String inodePath)
| {
| List<Inode> children = ((FileSystemManager)Component.getInstance("fileSystemManager", true)).getInodePathChildren(inodePath);
|
| return children;
| }
| }
|
I generate my JAXB beans with wsconsume or wsimport (have tried both) from the wsdl that was automatically generated.
When I call the webservice in the last bean, I get this exception:
| [javax.xml.bind.UnmarshalException: Unable to create an instance of com.acepostproduction.tumbolia.webservice.AbstractInodeImpl
| - with linked exception:
| [java.lang.InstantiationException]]
| com.acepostproduction.virtuolia.exceptions.WsException: [TumboliaFileSystemCommunicator] Error while calling getAllChildren(): javax.xml.bind.UnmarshalException
| - with linked exception:
| [javax.xml.bind.UnmarshalException: Unable to create an instance of com.acepostproduction.tumbolia.webservice.AbstractInodeImpl
| - with linked exception:
| [java.lang.InstantiationException]]
| at com.acepostproduction.virtuolia.communicator.TumboliaFileSystemCommunicator.getAllChildren(TumboliaFileSystemCommunicator.java:87)
| at com.acepostproduction.virtuolia.VirtuoliaDiskDriver.startSearch(VirtuoliaDiskDriver.java:340)
| ...
|
Any ideas why the polymorphism on the return value is failing?
It would be great if someone could give me a hint here.
bram
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4112791#4112791
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4112791
18 years, 4 months