This doesn't make sense. I have downloaded EnterpriseDT Pro for evaluation as a possible library to use within an app. I have a simple POJO command line app that runs this fine:
---------------------------------------------
Working POJO Imports
---------------------------------------------
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.File;
import com.enterprisedt.net.ftp.FTPClient;
import com.enterprisedt.util.debug.Level;
import com.enterprisedt.util.debug.Logger;
---------------------------------------------
Working POJO Code Snippet
---------------------------------------------
// set up logger so that we get some output
Logger log = Logger.getLogger(HelloClientPOJO.class);
Logger.setLevel(Level.INFO);
try {
log.info("Creating FTP client");
FTPClient _ftpClient = new FTPClient();
String hostname = "123.123.123.123";
String username = "letmein";
String password = "please!";
String filename1 = "C://test/file1.txt";
String new_filename1 = "file1.txt";
String s1 = readTextFile(filename1);
log.info("Setting remote host");
_ftpClient.setRemoteHost(hostname);
log.info("Connecting to server " + hostname);
_ftpClient.connect();
log.info("Logging in with username=" + username + " and password="
+ password);
_ftpClient.login(username, password);
log.info("Streaming file");
_ftpClient.put(s1.getBytes(), new_filename1);
log.info("File streamed");
log.info("Quitting client");
_ftpClient.quit();
} catch (Exception e) {
e.printStackTrace();
}
---------------------------------------------
It works great from the POJO app. When I run the SAME code from an EJB3 stateless session bean (remote and local interfaces) deployed to JBoss 5, I get the following warnings in the startup logs of JBoss:
10:11:09,109 INFO [ServerImpl] JBoss (Microcontainer) [5.0.1.GA (build: SVNTag=JBoss_5_0_1_GA date=200902232048)] Started in 19s:391ms
10:11:14,875 WARN [InterceptorsFactory] EJBTHREE-1246: Do not use InterceptorsFactory with a ManagedObjectAdvisor, InterceptorRegistry should be used via the bean container
10:11:14,875 WARN [InterceptorsFactory] EJBTHREE-1246: Do not use InterceptorsFactory with a ManagedObjectAdvisor, InterceptorRegistry should be used via the bean container
10:11:14,875 WARN [InterceptorRegistry] applicable interceptors is non-existent for public java.lang.String com.mycompany.serverapp.ftp.ejb3.FTPBean.doWork()
10:11:14,890 WARN [InterceptorRegistry] applicable interceptors is non-existent for public java.lang.String com.mycompany.serverapp.ftp.ejb3.FTPBean.doWork()
---------------------------------------------
---------------------------------------------
And I get the following error in the console log when I try to even instantiate the FTPClient class in the EJB after calling it from the POJO client application:
Exception in thread "main" javax.ejb.EJBException: Unexpected Error
java.lang.NoClassDefFoundError: com/enterprisedt/util/debug/Logger
at com.braincannon.ipublisher.ftp.ejb3.FTPBean.doWork(FTPBean.java:18)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111)
at org.jboss.ejb3.EJBContainerInvocationWrapper.invokeNext(EJBContainerInvocationWrapper.java:69)
at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.invoke(InterceptorSequencer.java:73)
at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.aroundInvoke(InterceptorSequencer.java:59)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)---------------------------------------------
EJB Code Including Instantiating FTPClient (based on the demos):
package com.mycompany.serverapp.ftp.ejb3;
import com.enterprisedt.net.ftp.FTPClient;
import com.enterprisedt.util.debug.Level;
import com.enterprisedt.util.debug.Logger;
import java.util.Vector;
import java.io.*;
import java.text.ParseException;
import javax.ejb.Stateless;
@Stateless
public class FTPBean implements FTPBeanLocal, FTPBeanRemote {
public String doWork() {
Logger log = Logger.getLogger(FTPBean.class);
Logger.setLevel(Level.INFO);
try {
String filename1 = "C://test/file1.txt";
String filename2 = "test.txt";
String hostname = "123.123.123.123";
String username = "letmein";
String password = "please!";
log.info("Creating FTP client");
FTPClient ftpClient = new FTPClient();
/*
ftpClient.setRemoteHost(hostname);
ftpClient.connect();
ftpClient.login(username,password);
ftpClient.put(filename1, filename2);
ftpClient.quit();
*/
} catch (Exception e) {
e.printStackTrace();
}