Maven compilation fails while eclipse is successful -
i using maven3.03 , eclipse 3.5 on windows xp. converted old web project in maven configuration style.
when compile project in eclipse compile.
note: classpath contains: maven dependencies , jdk(1.6_018).
when compile command line using mvn, few errors:
1.package com.sun.xml.internal.stream.buffer.stax not exist.
2.package com.sun.xml.internal.stream.writers not exist
3.cannot find symbol - symbol : class xmldomwriterimpl
4.package com.sun.xml.internal.messaging.saaj.util not exist
5.package com.sun.xml.internal.bind.v2.runtime.unmarshaller not exist
6.cannot find symbol - symbol : class namespacecontexhelper
7.cannot find symbol symbol : class byteoutputstream
i can see sun jar. can not understand why eclipse ok , command line not.
edit: 1 of errors didn't mention in above list is:
[error]<path>\eventsviewer.java:[54,69] inconvertible types found: <br>java.util.sortedmap<java.util.date,java.util.list<com.myclass>> required: java.util.map<? extends java.util.date,? extends java.util.list<com.myotherclass>>
when see same line in eclipse warning:
type safety: unchecked cast sortedmap<date,list<myclass>> map<? extends date,? extends list<myotherclass>> in eclipse warning , in maven error. did check org.eclipse.jdt.core.prefs , see setting org.eclipse.jdt.core.compiler.problem.forbiddenreference=warning.
update: got read of of above errors. "problem" in eclipse appears unused import. stangly maven report error. after removing unused import error gone. still problem 3 , 7 occures
conclusion: guess warnings become errors in javac. since don't use supresswarnings. surprised error different. it?
this real reason maybe from maven forum's answer
" jerome right it's not recommended practice use com.sun classes rt.jar. , ones marked "internal"; you're asking trouble.
however curious this, tried out. above class can indeed accessed eclipse. compiling code on commandline using javac fails "does not exist" error. assumption sun's java compiler detects when special "internal" class being accessed, , refuses import class. eclipse uses different compiler presumably not have check.
maven uses javac compiler available in system execution path. therefore problem nothing maven @ all. it's compiler maven invoking refusing compile source. can't see public flags in javac commandline disable "blocking" of internal access, unless want avoid using sun's javac compiler you'll have avoid using internal class.
just fun, tried out jerome's suggestion of putting rt.jar on classpath: javac -cp /usr/java/jdk1.6.0_03/jre/lib/rt.jar foo.java still failed compile.
the byteoutputstream class can loaded @ runtime via class.forname("..").
interestingly, project i'm working on happen import class com.sun.org.apache.xml.internal.utils.saxsourcelocator; , works ok. warnings issued, code compiles (and yes, it's on todo list fix :-). it's not all internal classes being blocked, selected ones. "
Comments
Post a Comment