I've implemented FCKeditor in my webapp. I'm developing in eclipse and deploying to weblogic. I'm using the editor via javascript and that's working fine. I added the connector to my project as described here http://java.fckeditor.net/connector.html.
<servlet> <servlet-name>Connector</servlet-name> <servlet-class> net.fckeditor.connector.ConnectorServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Connector</servlet-name> <url-pattern> /lib/fckeditor/editor/filemanager/connectors/* </url-pattern> </servlet-mapping>
This works fine in development. Totally fine. But when attempting to deploy the war file to the managed server, I receive the following error.
[HTTP:101216]Servlet: "Connector" failed to preload on startup in Web application: "application.war". java.lang.NullPointerException at java.io.File.<init>(File.java:194) at net.fckeditor.connector.ConnectorServlet.init(ConnectorServlet.java:82) at javax.servlet.GenericServlet.init(GenericServlet.java:256)
Can anyone offer some insight?
Thanks,
Brandon Zarzoza
Re: Problem deploying a webapp with FCKeditor
Are you using FCKeditor.Java 2.4?
Did you intergrate weblogic into Eclipe WTP? If so, please try to reproduce the error.
Try to debug the source. It seems like this string is null http://dev.fckeditor.net/browser/FCKedi ... t.java#L79 for some reason which leads to the NPE in line 82.
Re: Problem deploying a webapp with FCKeditor
Brandon,
I've investigated the issue and found the reason why it really fails. JBoss, WebLogic and maybe other servers do not expand the war file on the local filesystem, the run the webapp directly off the war file. Tomcat e.g. expands them. The specification says about ServletContext#getRealPath:
But you can access resources with ServletContext#getResource or ServletContext#getResourceAsStream. Both won't do for 2 reasons, the first one returns a JNDI resource (at least in Tomcat) (Jetty simply returns null) which is useless here or I do not know how to convert to a File object. The second one returns an InputStream which works for files and not for dirs only. Now the fundamental problem is, that you cannot write to both to store files. You could access only files directly. This solution is absolutely unusuable because it's read-only and explicit.
Conclusion: The connector servlet won't work as-is in WebLogic. You have no write-access to the context. You have to work outside of the context.
What you can do (options):
See these references I have consulted: 1, 2, 3, 4, 5 and 6.
I hope this helped.
I will file a ticket which should call attention to this drawback.
EDIT: Filed as ticket #2583.
Re: Problem deploying a webapp with FCKeditor
Re: Problem deploying a webapp with FCKeditor
I am glad, I was able to help you!