packagename doesnt contain ObjectFactory.class or jaxb.index

跟風遠走 提交于 2019-12-06 05:02:10
lexicore

First of all, let's check if you have the problem with the Maven build or in the IDE.

You're saying that your build seems to work fine.

  • Do you have a simple unmarshalling test which checks that unmarshalling really works? Make one and make sure it works.
  • Check the generated war - does it have all of the generated class in WEB-INF/classes?
  • You have several executions, are all of the generated packages present there (in WEB-INF/classes)?

When problems with the maven build are ruled out, check your IDE. I think you're using Eclipse:

  • Do you see all of the generated directories as Eclipse source folders?
  • Does your simple unmarshalling test (see above) work in Eclipse?
  • Do you have to configure somehow, which folders are deployed to Tomcat?
  • Do you maybe need to redirect compilation target to WEB-INF/classes?

There's quite a couple of places this can go wrong. A simple unit test will help check every step to find out what's missing.

As I said before, maven-jaxb2-plugin does add your target directory as a compile source root (unless you explicitly configure it out which you don't do). So Maven integration plugins like m2eclipse in Eclipse are supposed to add these directories as source folders. Your project is a bit different from the 'normal' setup in a sense that you have a war project and multiple executions. But I still think this must work, maven-jaxb2-plugin does pretty standard stuff here:

    if (getAddCompileSourceRoot()) {
        getProject().addCompileSourceRoot(getGenerateDirectory().getPath());
    }

This is exactly the same what build-helper-maven-plugin does:

this.project.addCompileSourceRoot( source.getAbsolutePath() );
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!